Cod sursa(job #1849884)
Utilizator | Data | 17 ianuarie 2017 22:14:15 | |
---|---|---|---|
Problema | Pascal | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <bits/stdc++.h>
using namespace std;
int i, n, d, rs;
int cnt(int x) {
int ans = 0, y = d;
while(x >= y) ans += x / y, y *= d;
return ans;
}
int main()
{
ifstream cin("pascal.in");
ofstream cout("pascal.out");
ios_base::sync_with_stdio(0);
cin >> n >> d;
for(i = 1; i < n; ++i)
if(cnt(n) - cnt(i) - cnt(n - i) > 0 ) ++rs;
cout << rs << '\n';
return 0;
}