Pagini recente » Cod sursa (job #2791037) | Cod sursa (job #323865) | Cod sursa (job #2808838) | Cod sursa (job #2192582) | Cod sursa (job #3137737)
// https://infoarena.ro/problema/pascal
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
ifstream fin("pascal.in");
ofstream fout("pascal.out");
const int MAXR=5000005;
short cnt[MAXR][3], s[MAXR][3];
int main() {
int r, d;
fin>>r>>d;
for (int i=1; i<=r; ++i) {
if (i%2==0) cnt[i][0] = cnt[i/2][0]+1;
if (i%3==0) cnt[i][1] = cnt[i/3][1]+1;
if (i%5==0) cnt[i][2] = cnt[i/5][2]+1;
}
for (int i=1; i<=r; ++i) {
s[i][0] = s[i-1][0]+cnt[i][0];
s[i][1] = s[i-1][1]+cnt[i][1];
s[i][2] = s[i-1][2]+cnt[i][2];
}
int ans=0;
for (int i=0; i<=r; ++i) {
array<int,3> p{};
for (int j=0; j<3; ++j) {
p[j] = s[r][j] - s[r-i][j] - s[i][j];
}
bool ok=true;
for (int j=0; j<3; ++j) {
if (p[j]>=0) ok &= (p[j] >= cnt[d][j]);
}
ans += ok;
}
fout<<ans;
}