Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int L1,R1,P1,D1;
- int L2,R2,P2,D2;
- int K , mov[2]={-1,+1};
- void solve(){
- cin>>L1>>R1>>P1>>D1;
- cin>>L2>>R2>>P2>>D2;
- cin>>K;
- int ans=0;
- while( K-- ){
- if( P1 == R1 && D1==1 )D1=0;
- if( P1 == L1 && D1==0 )D1=1;
- P1 += mov[D1];
- if( P2 == R2 && D2==1 )D2=0;
- if( P2 == L2 && D2==0 )D2=1;
- P2 += mov[D2];
- ans += ( P1 == P2 );
- }
- cout<<ans<<endl;
- }
- int main(){
- int T;
- cin>>T;
- while( T-- )solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement