Advertisement
STANAANDREY

sarituri (10)

Dec 28th, 2021
1,204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. constexpr int NMAX = 1e3 + 3;
  4. bitset<NMAX> canArriveAt;
  5.  
  6. signed main() {
  7.     int x, y, z;
  8.     cin >> x >> y >> z;
  9.     canArriveAt[0] = true;
  10.     for (int i = 0; i <= z; i++) {
  11.         if (canArriveAt[i]) {
  12.             canArriveAt[i + x] = true;
  13.             canArriveAt[i + y] = true;
  14.         }
  15.     }
  16.  
  17.     if (canArriveAt[z]) {
  18.         puts("DA");
  19.     } else {
  20.         puts("NU");
  21.     }
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement