【HDOJ】1597 find the nth digit
生活随笔
收集整理的這篇文章主要介紹了
【HDOJ】1597 find the nth digit
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
二分。
1 #include <stdio.h> 2 #include <math.h> 3 4 int main() { 5 int case_n; 6 double n, tmp, l, r; 7 int m; 8 9 scanf("%d", &case_n); 10 11 while (case_n--) { 12 scanf("%lf", &n); 13 tmp = sqrt(n+n); 14 tmp = ceil(tmp); 15 l = (tmp*tmp-tmp)/2; 16 r = (tmp*tmp+tmp)/2; 17 while ( !(l<n && r>=n) ) { 18 --tmp; 19 l = (tmp*tmp-tmp)/2; 20 r = (tmp*tmp+tmp)/2; 21 } 22 m = (int)(n-l); 23 m %= 9; 24 if (m==0) m=9; 25 printf("%d\n", m); 26 } 27 28 return 0; 29 }?
轉載于:https://www.cnblogs.com/bombe1013/p/3683209.html
總結
以上是生活随笔為你收集整理的【HDOJ】1597 find the nth digit的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VS2008 JS脚本调试总是调试旧代码
- 下一篇: vim常用命令表