General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
121270476 Practice:
pedrovictor48
1542B - 11 GNU C++17 (64) Time limit exceeded on test 2 3000 ms 0 KB 2021-07-04 02:45:13 2021-07-04 02:45:13
 
 
→ Source
#include <bits/stdc++.h>
#define int long long 
using namespace std;

bool rec(int x, int a, int b) {
    if(x < 0) return false;
    if(a == 1) return ((x - 1) % b == 0);
    if (x == 1 || (x -1) % b == 0) return true;
    if (x % a != 0) return rec(x - b, a, b);
    return rec(x/a, a, b);
}
 
void run_test_case() {
    int n, a, b;
    cin >> n >> a >> b;
    if(rec(n, a, b)) cout << "Yes\n";
    else cout << "No\n";
}
 
int32_t main () {
 
    ios::sync_with_stdio(0);
    cin.tie(0);
 
    int test_cases; cin >> test_cases; while(test_cases--) 
        run_test_case();
 
}
 
//CHEK:
//  OUT OF BONDS
//  PRECISION
//  DIVISIONS BY ZERO
//  COMPLEXITY
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details