Saleh127

Lightoj 1008

Jun 15th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. int main()
  6. {
  7.  
  8. ll ca=1;
  9. test
  10. {
  11. ll a;
  12. scanf("%lld",&a);
  13. ll r=0,c=0;
  14. ll cell = ceil(sqrt(a));
  15. ll flr = floor(sqrt(a));
  16. ll sqcell = (cell*cell) - a;
  17. ll sqflr = a - (flr*flr);
  18. if(cell>sqcell)
  19. {
  20. c=sqcell + 1;
  21. r=cell;
  22. }
  23. else
  24. {
  25. c=cell;
  26. r=sqflr;
  27. }
  28.  
  29. if(cell%2==0)
  30. {
  31. swap(c,r);
  32. }
  33. printf("Case %lld: %lld %lld\n",ca++,c,r);
  34.  
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment