@w616561153
2020-11-21T14:17:16.000000Z
字数 344
阅读 525
#include <cstdio>#include <cmath>#include <iostream>#define int llusing namespace std;typedef long long ll;int f(int n){return (sqrt(8 * n + 1) - 1) / 2;}int f2(int m){return (m * m + m) / 2;}signed main(){int times;scanf("%lld", ×);while(times --){int n;scanf("%lld", &n);int m = f(n);if(n - f2(m) == 0){printf("%lld\n", (m - 1) % 9 + 1);}else{printf("%lld\n", (n - f2(m) - 1) % 9 + 1);}}return 0;}