Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n;
- int opus(int i)
- {
- if(i==1) return 2;
- return 1;
- }
- int Solutie(int poz)
- {
- if(poz==1) return 1;
- if(poz==2) return 2;
- if(poz==3) return 2;
- if(poz==4) return 1;
- int p=4, k=1;
- while(p<n)
- {
- p*=4;
- k++;
- }
- int sfert = p/4;
- int cadran;
- if(poz>=1 && poz<=sfert) cadran=1;
- if(poz>sfert && poz<=2*sfert) cadran=2;
- if(poz>sfert*2 && poz<=3*sfert) cadran=3;
- if(poz>sfert*3 && poz<=sfert*4) cadran=4;
- //if(cadran==1) cadranul niciodata nu va fi 1
- //return Solutie(poz);
- if(cadran==2)
- return opus(Solutie(poz - sfert*1));
- if(cadran==3)
- return opus(Solutie(poz - sfert*2));
- //if(cadran==4)
- return Solutie(poz - sfert*3);
- }
- int main()
- {
- cin>>n;
- cout<<Solutie(n)<<"\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement