Advertisement
erfanul007

LOJ 1008

Dec 2nd, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. long long int t,i,n,x,y,sq,tmp;
  6. freopen("input.txt","r",stdin);
  7. scanf("%lld",&t);
  8. for(i=1;i<=t;i++){
  9. scanf("%lld",&n);
  10. sq=ceil(sqrt((double)(n)));
  11. if(sq*sq-n<sq){
  12. x=sq;
  13. y=sq*sq-n+1;
  14. }
  15. else{
  16. x=-sq*sq+2*sq+n-1;
  17. y=sq;
  18. }
  19. if(sq&1){
  20. tmp=x;
  21. x=y;
  22. y=tmp;
  23. }
  24. printf("Case %lld: %lld %lld\n",i,x,y);
  25. }
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement