SHOW:
|
|
- or go back to the newest paste.
1 | #include<bits/stdc++.h> | |
2 | using namespace std; | |
3 | int main(){ | |
4 | int x, y; | |
5 | cin>>x>>y; | |
6 | int m=y; | |
7 | int a=0; | |
8 | int s=32; | |
9 | int qn=0; | |
10 | int qn1=0; | |
11 | int ans=1; | |
12 | for(int i=0; i<30; i++) | |
13 | { | |
14 | ans=ans<<1; | |
15 | ans=ans|1; | |
16 | } | |
17 | //cout<<ans<<endl; | |
18 | while(s){ | |
19 | qn=m&1; | |
20 | if(qn==1 && qn1==0){ | |
21 | a=a-x; | |
22 | }else if(qn==0 && qn1==1){ | |
23 | a=a+x; | |
24 | } | |
25 | int temp=a&1; | |
26 | temp=(temp<<31); | |
27 | qn1=m&1; | |
28 | a=a>>1; | |
29 | m=m>>1; | |
30 | m=m&ans; | |
31 | m=m|temp; | |
32 | s--; | |
33 | cout<<a<<" "<<m<<endl; | |
34 | } | |
35 | //int finAns = | |
36 | long int acc=a; | |
37 | long int finAns=(acc<<31)|m; | |
38 | cout<<m<<" "<<finAns<<endl; | |
39 | } |