Mai intai trebuie sa te autentifici.
Cod sursa(job #2108212)
| Utilizator | Data | 17 ianuarie 2018 23:34:36 | |
|---|---|---|---|
| Problema | Pascal | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include<fstream>
using namespace std;
ifstream in ("pascal.in");
ofstream out ("pascal.out");
int sol,k,d,i,j,y,x;
char fact[5000005];
int main (void) {
in >> k >> d;
for (int i = 1; i <= k; i ++) {
fact[i] += fact[i-1];
x = i;
while (x%d ==0) {
fact[i] ++;
x/=d;
}
}
i = k;
for (int j = 0; j <= k/2; j ++) {
if (fact[i] - fact[i-j] - fact[j] > 0) {
sol ++;
}
}
sol *= 2;
if (k % 2 == 0) {
sol --;
}
out << sol;
}
