标签:des style color java os io 数据 for
6 1 2 3 4 5 10
1 1 2 1 2 4
#include<stdio.h> #include<iostream> using namespace std; int main () { int T,n; int i,j; for(i=1;i<n;i++) n-=i; if(n%9) cout<<n%9<<endl; else cout<<9<<endl; } return 0; }
#include<stdio.h> #include<iostream> using namespace std; int main () { int T,n; int i,j,k; __int64 a[10000],sum[10000]; memset(sum,0,sizeof(sum)); for(i=1;i<=10000;i++) sum[i]=(1+i)*i/2; scanf("%d",&T); while(T--) { scanf("%d",&n); for(i=1;i<=10000;i++) { if(sum[i]<n && n<sum[i+1]) { k=(n-sum[i])%9; break; } if(sum[i]==n) { k=i%9; break; } } if(k==0) cout<<9<<endl; else cout<<k<<endl; } return 0; }
hdu 1597 find the nth digit,布布扣,bubuko.com
标签:des style color java os io 数据 for
原文地址:http://blog.csdn.net/fyxz1314/article/details/38536977