Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int step3[10] = {1, 3, 9, 27, 81, 243, 729, 2187, 6561};
- int main()
- {
- int n;
- cin >> n;
- bool flag = false;
- for (int i = 8; i >= 0; i--)
- {
- if (n >= step3[i]) n = n - step3[i];
- //if (n == 0) flag = true;
- }
- if (n == 0) flag = true;
- if (flag) cout << "YES\n";
- else cout << "NO\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement