fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. void solve()
  5. {
  6. int n, row = 1;
  7. cin >> n;
  8. while (n > 0){
  9. if (n > row)
  10. n -= row;
  11. else break;
  12. row++;
  13. }
  14. cout << row <<" "<< n << endl;
  15. }
  16. int main()
  17. {
  18. int t;
  19. cin >> t;
  20. while (t--)
  21. solve();
  22. return 0;
  23. }
Success #stdin #stdout 0s 3100KB
stdin
5
1
3
5
7
9
stdout
1 1
2 2
3 2
4 1
4 3