标签:des style blog color java os io strong
6 1 2 3 4 5 10
1 1 2 1 2 4
#include<cstdio> #include<string> #include<cmath> #include<cstring> #include<cctype> #include<cstdlib> #include<vector> #include<set> #include<map> #include<stack> #include<queue> #include<list> #include<algorithm> #include<iostream> #include<sstream> using namespace std; int main() { int cas; int n; int sum; scanf("%d", &cas); while( cas-- ) { scanf("%d", &n); sum = 0; for(int i=1; ; i++) { sum += i; if( sum >= n ) { sum -= i; break; } } int ans = n - sum; if( ans % 9 == 0 ) printf("9\n"); else printf("%d\n", ans%9); } return 0; }
HDU 1597:find the nth digit,布布扣,bubuko.com
标签:des style blog color java os io strong
原文地址:http://blog.csdn.net/u013487051/article/details/38536337