杭电find the night
生活随笔
收集整理的這篇文章主要介紹了
杭电find the night
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
find the night
Time Limit: 1000/1000 MS (Java/Others)????Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 9729????Accepted Submission(s): 2830
Problem Description 假設: S1 = 1 S2 = 12 S3 = 123 S4 = 1234 ......... S9 = 123456789 S10 = 1234567891 S11 = 12345678912 ............ S18 = 123456789123456789 .................. 現在我們把所有的串連接起來 S = 1121231234.......123456789123456789112345678912......... 那么你能告訴我在S串中的第N個數字是多少嗎? Input 輸入首先是一個數字K,代表有K次詢問。 接下來的K行每行有一個整數N(1 <= N < 2^31)。 Output 對于每個N,輸出S中第N個對應的數字. Sample Input 6 1 2 3 4 5 10 Sample Output 1 1 2 1 2 4 #include <iostream>using namespace std;
int main()
{
??? int a;
??? int t,n;
? cin>>t;
??? while(t--)
??? {
??????? cin>>a;
??????? n=1; //實現n-s1-s2-s3-s4.............
???????? while(a>n)
??????? {
????????????? a-=n;
????????????? n++;
??????? }
??????? a%=9;if(a==0)??? a=9;
?????? cout<<a<<endl;
??? }
??? return 0;
}
總結
以上是生活随笔為你收集整理的杭电find the night的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SpringMVC实现RESTful风格
- 下一篇: JEECG新版UI规划,主要提供H5方案