Advertisement
ekzolot

Untitled

Apr 20th, 2022
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. void make_everything_ok(vector <bool>& dp, vector <bool>& c, int x){
  5.     c[x]=1;
  6.     if (!dp[x]){
  7.         return;
  8.     }
  9.     dp[(x*7+2)%10000]=dp[x];
  10.     if (!c[(x*7+2)%10000]){
  11.         make_everything_ok(dp, c, (x*7+2)%10000);
  12.     }
  13.     dp[(x*2+7)%10000]=dp[x];
  14.     if (!c[(x*2+7)%10000]){
  15.         make_everything_ok(dp, c, (x*2+7)%10000);
  16.     }
  17. }
  18. int main(){
  19.     int a, b;
  20.     cin>>a>>b;
  21.     vector <bool> dp(10001);
  22.     dp[a]=true;
  23.     vector <bool> c(10001);
  24.     make_everything_ok(dp, c, a);
  25.     if (dp[b]){
  26.         cout<<"Yes"<<endl;
  27.     }
  28.     else{
  29.         cout<<"No"<<endl;
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement