1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #!/usr/bin/bc -l define mod(n, l) { auto oldscale,ret oldscale=scale scale=0 ret=(n/l)*l scale=oldscale return n-ret } define logfactorial(n) { auto i,res if (n<1000000) { res=0 for (i=1;i<=n;i++) { res+=l(i) } return res/l(10) } res=n*l(n)-n+1/2*l(2*a(1)*4*n)+1/12/n-1/360/(n^3)+1/1260/(n^5)-1/1680/(n^7)+1/1188/(n^9)-691/2730/12/11/(n^11)+7/6/14/13/(n^13) return res/l(10) } define firstdigits(n,k) { auto log log=logfactorial(n) log=mod(log,1)+k-1+10^(-42) return e(log*l(10)); } define lastdigits(n,l) { auto i,res,pow10l res=1 pow10l=10^l if (n>1000 && l<150) { return 0 } for (i=2;i<=n;i++) { res=mod(res*i,pow10l) if (res==0) break; } return res } define output(n, c) { auto log,ciphers,i,oldscale if (n==0) { for (i=0;i<c;i++) { print "0" } return } log=l(n)/l(10) ciphers=log+10^(-42)-mod(log+10^(-42),1)+1 for (i=0;i<c-ciphers;i++) { print "0" } oldscale=scale scale=0 print n/1 scale=oldscale } scale=70 t=read() while (t--) { n=read() k=read() l=read() b=lastdigits(n,l) a=firstdigits(n,k) dummy=output(a,k) print " " dummy=output(b,l) print "\n" } |
-
upload with new input
-
result: Time limit exceeded time: ∞ memory: 2284 kB signal: 24 (SIGXCPU)
1 10000 0 249
-
result: Time limit exceeded time: ∞ memory: 2388 kB signal: 24 (SIGXCPU)
1 1000000 0 9999
-
result: Time limit exceeded time: ∞ memory: 2968 kB signal: 24 (SIGXCPU)
1 1000000 0 249999
-
result: Time limit exceeded time: ∞ memory: 2284 kB signal: 24 (SIGXCPU)



