[关闭]
@w616561153 2020-11-21T22:17:16.000000Z 字数 344 阅读 451
  1. #include <cstdio>
  2. #include <cmath>
  3. #include <iostream>
  4. #define int ll
  5. using namespace std;
  6. typedef long long ll;
  7. int f(int n)
  8. {
  9. return (sqrt(8 * n + 1) - 1) / 2;
  10. }
  11. int f2(int m)
  12. {
  13. return (m * m + m) / 2;
  14. }
  15. signed main()
  16. {
  17. int times;
  18. scanf("%lld", &times);
  19. while(times --){
  20. int n;
  21. scanf("%lld", &n);
  22. int m = f(n);
  23. if(n - f2(m) == 0){
  24. printf("%lld\n", (m - 1) % 9 + 1);
  25. }
  26. else{
  27. printf("%lld\n", (n - f2(m) - 1) % 9 + 1);
  28. }
  29. }
  30. return 0;
  31. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注