Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. /*
  2.  * File:   main.cpp
  3.  * Author: antimax
  4.  *
  5.  * Created on 7 Ноябрь 2010 г., 22:01
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <math.h>
  10. using namespace std;
  11.  
  12. /*
  13.  *
  14.  */
  15. int kv( int x, int y)
  16. {
  17.     int i;
  18.     //i= pow(x,2)*1000;
  19.     i= (pow(x,2) - pow(y,2));
  20.     return i;
  21. }
  22. int main(int argc, char** argv) {
  23.     long long x=2070;
  24.     long long y=1980;
  25.     int q[4];
  26.     q[0]=150;
  27.     q[1]=152;
  28.     q[2]=155;
  29.     q[3]=160;
  30.     for(int i=3;i>-1;i--)
  31.     {   long long w=q[i]*q[i];
  32.         bool f= true;
  33.         while(f)
  34.         {
  35.             long long a=kv(x,y);
  36.  
  37.             if((a-w)>-2 && (a-w)<2) f=false;
  38.             else if (a>q[i])
  39.             {
  40.                 x-=1;
  41.                 y+=1;
  42.                 //printf("%i %i\n",x,y);
  43.             }
  44.             else
  45.             {
  46.                 x+=1;
  47.                 y-=1;
  48.                 //printf("%i %i\n",x,y);
  49.             }
  50.         }
  51.         printf("%i %i\n",x,y);
  52.     }
  53.  
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement