Pagini recente » Cod sursa (job #2407806) | Cod sursa (job #282770) | Cod sursa (job #1930725) | Cod sursa (job #873706) | Cod sursa (job #2595132)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("pascal.in");
ofstream fout("pascal.out");
const int DIM = 5e6 + 1;
int cnt2[DIM];
int cnt3[DIM];
int cnt5[DIM];
main()
{
int n, k;
fin >> n >> k;
for(int i = 2; i <= n; i += 2)
{
cnt2[i] = cnt2[i / 2] + 1;
}
for(int i = 3; i <= n; i += 3)
{
cnt3[i] = cnt3[i / 3] + 1;
}
for(int i = 5; i <= n; i += 5)
{
cnt5[i] = cnt5[i / 5] + 1;
}
for(int i = 2; i <= n; ++i)
{
cnt2[i] += cnt2[i - 1];
cnt3[i] += cnt3[i - 1];
cnt5[i] += cnt5[i - 1];
}
int ans = 0;
for(int i = 0; i <= n; ++i)
{
int nr2 = cnt2[n] - cnt2[i] - cnt2[n - i];
int nr3 = cnt3[n] - cnt3[i] - cnt3[n - i];
int nr5 = cnt5[n] - cnt5[i] - cnt5[n - i];
if(k == 2 && nr2)
++ans;
if(k == 3 && nr3)
++ans;
if(k == 4 && nr2 > 1)
++ans;
if(k == 5 && nr5)
++ans;
if(k == 6 && nr2 && nr3)
++ans;
}
fout << ans << '\n';
}