Pagini recente » Cod sursa (job #1949975) | Cod sursa (job #2499914) | Cod sursa (job #3165549) | Cod sursa (job #1501131) | Cod sursa (job #3137743)
// 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;
int cnt[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;
}
array<int,3> pd{};
pd[0] = cnt[d][0];
pd[1] = cnt[d][1];
pd[2] = cnt[d][2];
for (int i=1; i<=r; ++i) {
cnt[i][0] += cnt[i-1][0];
cnt[i][1] += cnt[i-1][1];
cnt[i][2] += cnt[i-1][2];
}
int ans=0;
for (int i=1; i<=r; ++i) {
array<int,3> p{};
for (int j=0; j<3; ++j) {
p[j] = cnt[r][j] - cnt[r-i][j] - cnt[i][j];
}
bool ok=true;
for (int j=0; j<3; ++j) ok &= (p[j] >= pd[j]);
ans += ok;
}
if (r==0) fout<<0;
else fout<<ans;
}