Cod sursa(job #2840088)
| Utilizator | Data | 27 ianuarie 2022 09:06:04 | |
|---|---|---|---|
| Problema | Pascal | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
/* [A][M][C][B][N] / [K][R][I][P][6][8] */
#include <bits/stdc++.h>
using namespace std;
const int mod = 104659, inf = 0x3f3f3f3f;
const char sp = ' ', nl = '\n';
ifstream fin("pascal.in");
ofstream fout("pascal.out");
int f(int n, int d) {
int cnt = 0;
while (n) n /= d, cnt += n;
return cnt;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int r, d;
fin >> r >> d;
int cnt = 0;
for (int i = 0; i <= r; ++i) {
if (f(r, d) - f(i, d) - f(r -i, d) > 0)
cnt++;
}
fout << cnt;
}
