Tranvick

Untitled

Jan 8th, 2012
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1. #pragma comment(linker, "/STACK:65777216")
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cstdlib>
  5. #include <ctime>
  6. #include <cstdio>
  7. #include <algorithm>
  8. #include <cmath>
  9. #include <vector>
  10. #include <set>
  11. #include <stack>
  12. #include <map>
  13. #include <queue>
  14. #include <string>
  15. #include <memory.h>
  16. #include <iterator>
  17. #define mem(A,X) memset(A,X,sizeof(A))
  18. #define memo(A) memset(A,0,sizeof(A))
  19. #define forn(I,B) for (int I=1;I<=(B);I++)
  20. #define forg(H,V) for (int H=first[V];h;h=next[H])
  21. #define rep(I,B) for (int I=0;I<(B);I++)
  22. #define labs(X) (((X)>0)?(X):(-(X)))
  23. #define ropen(X) freopen(X,"r",stdin)
  24. #define wopen(X) freopen(X,"w",stdout)
  25. #define pb push_back
  26. #define mp make_pair
  27. #define all(X) (X).begin(),(X).end()
  28. #define sqr(X) ((X)*(X))
  29.  
  30. using namespace std;
  31.  
  32. typedef pair <int,int> pii;
  33. typedef pair <long long,long long> pll;
  34. typedef double ld;
  35. typedef long long ll;
  36. typedef vector<int> vi;
  37. const int N=111111;
  38. const int INF=111111111;
  39. const double eps=1e-9;
  40. const double pi=3.14159265358979;
  41.  
  42. int ys[N];
  43.  
  44. int main(){
  45.     int a,x,y;
  46.     cin>>a>>x>>y;
  47.     if (y%a==0 || x>=a || x<=-a){
  48.         cout<<-1;
  49.         return 0;
  50.     }
  51.     ys[1]=a;ys[2]=a+a;
  52.     ys[3]=ys[4]=a+a+a;         
  53.     for (int i=1;;i++){
  54.         if (i>=5){
  55.             if (i%3==2) ys[i]=ys[i-1]+a;
  56.             if (i%3==1) ys[i]=ys[i-2]+a;
  57.             if (i%3==0) ys[i]=ys[i-1]+a;
  58.         }
  59.         if (ys[i]>y){
  60.             if (i%3==2 || i==1 || i==2){
  61.                 if (2*x>=a || 2*x<=-a){
  62.                     cout<<-1;
  63.                     return 0;
  64.                 } else {
  65.                     cout<<i;
  66.                     return 0;
  67.                 }
  68.             } else {
  69.                 if (x==0){
  70.                     cout<<-1;
  71.                     return 0;
  72.                 } else {
  73.                     if (x<0 && x>-a){
  74.                         cout<<i;
  75.                         return 0;
  76.                     } else {
  77.                         cout<<i+1;
  78.                         return 0;
  79.                     }
  80.                 }
  81.             }
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment