B solution report
It's a regular question., x y z-x-y-Z.
Note that if the number is less than 0, you must first modulo the negative number and then modulo it. You cannot directly add mod, but it may still be a negative number.
The stamp code for me is kneeling ,,,
#include <iostream>#include <cstring>#include <cstdio>using namespace std;long long x,y,z;long long n;int main(){ cin>>x>>y; cin>>n; z=y-x; long long t; t=(n-1)/3; if(t%2==0) { n%=3; if(n==0) { if(z>=0) cout<<z%1000000007; else cout<<(z%1000000007+1000000007)%1000000007; } else if(n==1) { if(x>=0) cout<<x%1000000007; else cout<<(x%1000000007+1000000007)%1000000007; } else { if(y>=0) cout<<y%1000000007; else cout<<(y%1000000007+1000000007)%1000000007; } } else { x=-x; y=-y; z=-z; n%=3;if(n==0) { if(z>=0) cout<<z%1000000007; else cout<<(z%1000000007+1000000007)%1000000007; } else if(n==1) { if(x>=0) cout<<x%1000000007; else cout<<(x%1000000007+1000000007)%1000000007; } else { if(y>=0) cout<<y%1000000007; else cout<<(y%1000000007+1000000007)%1000000007; } } return 0;}
Jzzhu and sequencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Jzzhu has sorted Ted a kind of sequences, they meet the following property:
You are givenXAndY, Please calculateFNModulo 1000000007 (109? +? 7 ).
Input
The first line contains two integersXAndY(|X| ,? |Y|? ≤? (109). The second line contains a single integerN(1? ≤?N? ≤? 2 · 109 ).
Output
Output a single integer representingFNModulo 1000000007 (109? +? 7 ).
Sample test (s) Input
2 33
Output
1
Input
0 -12
Output
1000000006
Note
In the first sample,F2? =?F1? +?F3, 3? =? 2? +?F3,F3? =? 1.
In the second sample,F2? = ?? -? 1 ;? -? 1 modulo (109? +? 7) equals (109? +? 6 ).