Python3(3.5.2) 解法, 执行用时: 19ms, 内存消耗: 3548K, 提交时间: 2018-09-06 22:28:18
import math def chk(x, y) : return math.log(2 * math.pi * x) / 2 + x * math.log(x) - x <= y * math.log(y) n = int(input()) l, r = 1, 10000000000 while l < r : mid = (l + r) >> 1 if chk(mid, n) : l = mid + 1 else : r = mid print(l)
Pascal(fpc 3.0.2) 解法, 执行用时: 2ms, 内存消耗: 256K, 提交时间: 2018-10-26 13:49:39
var x,l,r,mid:int64;ans1:double; begin read(x);ans1:=ln(x)*x; l:=0;r:=2*x; while l<r do begin mid:=(l+r)div 2; if ln(sqrt(2*pi*mid))+mid*(ln(mid)-ln(exp(1)))>ans1 then r:=mid else l:=mid+1; end; write(l); end.
C++14(g++5.4) 解法, 执行用时: 4ms, 内存消耗: 480K, 提交时间: 2018-09-06 22:13:36
#include<bits/stdc++.h> using namespace std; int main() { long long a[15] = {10,94,892,8640,84657,834966,8267019,82052137,815725636,8118965902}; string ss;cin>>ss; cout<<a[ss.size()-1]<<endl; }
C(clang 3.9) 解法, 执行用时: 2ms, 内存消耗: 232K, 提交时间: 2018-09-07 00:26:09
#include<stdio.h> int main(){long long a[12]={0,0,10,94,892,8640,84657,834966,8267019,82052137,815725636,8118965902LL};printf("%lld",a[fread(a,1,11,stdin)]);}
C++11(clang++ 3.9) 解法, 执行用时: 4ms, 内存消耗: 476K, 提交时间: 2018-09-07 00:29:34
#include<iostream> int main(){long long a[12]={0,0,10,94,892,8640,84657,834966,8267019,82052137,815725636,0x1e3ed968e};std::cout<<a[fread(a,1,11,stdin)];}