Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这当然有问题。。。In Reply To:最新发现.~~~....请HAWK解释一下. Posted by:cannie at 2005-10-19 12:13:23 > #include <stdio.h> > #include <math.h> > #include <iostream.h> > long long finda(long long k){ > char s[30]; > long long tot, i, res, m; > long long d[30] = {0, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, > 100000000, 1000000000}; > tot = 0; > for (i = 1;; i++){ > //if (i >= 29) while (1); > if (tot + i * (d[i+1] - d[i]) >= k - tot) > break; > tot = tot + i * (d[i+1] - d[i]); > } > res = k - tot; > m = (res - 1) % i; > res = (res - 1) / i; > res += d[i]; > sprintf(s, "%lld", res); > return s[m] - '0'; > } > long long findb(long long k){ > char s[30]; > long long tot, i, res, m; > long long d[30] = {0, 1, 4, 10, 32, 100, 317, 1000, 3163, 10000, 31623, > 100000, 316228, 1000000, 3162278, 10000000, 31622777, > 100000000, 316227767, 1000000000}; > tot = 0; > for (i = 1;; i++){ > //if (i >= 29) while (1); > if (i * (d[i+1] - d[i]) >= k - tot) > break; > tot = tot + i * (d[i+1] - d[i]); > } > res = k - tot; > m = (res - 1) % i; > res = (res - 1) / i; > res += d[i]; > sprintf(s, "%lld", res * res); > return s[m] - '0'; > } > int main(){ > long long k, res, tmp; > // freopen("in.txt", "r", stdin); > // freopen("out.txt", "w", stdout); > k = 0; /////////注意这: 如果把这句去了TLE,不去就WA............难道这也是程序问题????///////希望HAWK能够解释一下. > while (scanf("%lld", &k) == 1 && k > 0){ > if (k > 2147483647) while (1); > //if (k == 0) break; > > res = finda(k) + findb(k); > k++; > tmp = finda(k) + findb(k); > while (tmp == 9){ > k++; > tmp = finda(k) + findb(k); > } > if (tmp > 9) > res ++; > printf("%lld\n", res % 10); > } > } > Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator