mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
16 lines
281 B
C++
16 lines
281 B
C++
|
#include<stdio.h>
|
||
|
#include<math.h>
|
||
|
int main()
|
||
|
{
|
||
|
__int64 i,t,n,m;
|
||
|
scanf("%I64d",&t);
|
||
|
while(t--)
|
||
|
{
|
||
|
scanf("%I64d",&n);
|
||
|
m=((__int64)sqrt(1+8*(n-1))-1)/2;
|
||
|
n-=m*(m+1)/2;
|
||
|
printf("%I64d\n",n%9!=0?n%9:9);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|