Advertisement
Farjana_akter

Untitled

Jan 26th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. long long int t,l,a,b,c,d,e,f,g,h,n,i,j,k;
  6. cin>>t;
  7. for(l=1;l<=t;l++)
  8. {
  9. cin>>n;
  10. a=ceil(sqrt(n));
  11. b=floor(sqrt(n));
  12. c=a*a;
  13. d=b*b;
  14. e=n-d;
  15. f=c-n;
  16. if(c==n)
  17. {
  18. if(a%2==0)
  19. cout<<"Case "<<l<<":"<<" "<<a<<" "<<1<<endl;
  20. else
  21. cout<<"Case "<<l<<":"<<" "<<1<<" "<<a<<endl;
  22. }
  23. else if(e<f)
  24. {
  25. if(d%2==0)
  26. cout<<"Case "<<l<<":"<<" "<<a<<" "<<e<<endl;
  27. else
  28. cout<<"Case "<<l<<":"<<" "<<e<<" "<<a<<endl;
  29. }
  30. else
  31. {
  32. if(c%2==0)
  33. cout<<"Case "<<l<<":"<<" "<<a<<" "<<f+1<<endl;
  34. else
  35. cout<<"Case "<<l<<":"<<" "<<f+1<<" "<<a<<endl;
  36. }
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement