Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void make_everything_ok(vector <bool>& dp, vector <bool>& c, int x){
- c[x]=1;
- if (!dp[x]){
- return;
- }
- dp[(x*7+2)%10000]=dp[x];
- if (!c[(x*7+2)%10000]){
- make_everything_ok(dp, c, (x*7+2)%10000);
- }
- dp[(x*2+7)%10000]=dp[x];
- if (!c[(x*2+7)%10000]){
- make_everything_ok(dp, c, (x*2+7)%10000);
- }
- }
- int main(){
- int a, b;
- cin>>a>>b;
- vector <bool> dp(10001);
- dp[a]=true;
- vector <bool> c(10001);
- make_everything_ok(dp, c, a);
- if (dp[b]){
- cout<<"Yes"<<endl;
- }
- else{
- cout<<"No"<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement