Pagini recente » Cod sursa (job #2036791) | Cod sursa (job #775098) | Cod sursa (job #848652) | Cod sursa (job #2819798) | Cod sursa (job #2650329)
#include<bits/stdc++.h>
#define fore(start,i,end) for(int i = start; i <= end; i++)
#define dbg(x) #x << "=" << x << " "
#define dbg2(x,y) "{" << x << "," << y << "} "
#define dbg3(x,y,k) "{" << x << "," << y << "," << k << "} "
#define dbg4(x,y,k,j) "{" << x << "," << y << "," << k << " , " << j << "} "
#define ll long long
#define f1 first
#define f2 second
#define inf 1000000005
#define debug_st(st) if (true) {cout << #st << " : "; stack<int> s123; while (!s123.empty()) cout << s123.top() << " ", s123.pop(); cout << "\n";}
#define debug_a(a,n) cout << #a << " : "; for(int i = 1; i <= n; i++) cout << a[i] << " "; cout << "\n";
#define debug_m(a,n,m) cout << #a << " :\n"; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++) cout << a[i][j] << " "; cout << "\n"; }cout << "\n";
#define debug_v(v) cout << #v << " : "; for(auto k : v) cout << k << " "; cout << "\n";
#define debug_s(s) cout << #s << " : "; for (auto k : s) cout << k < " "; cout << "\n";
#define debug_s2(s) cout << #s << " : "; for(auto k : s) cout << dbg2((*k).first,(*k).second); cout << "\n";
#define nmax 5000005
using namespace std;
ifstream in("pascal.in");
ofstream out("pascal.out");
int y,d,f2[nmax],f3[nmax],f5[nmax];
int main()
{int i,j,ans = 0;
in >> y >> d;
for (i = 1; i <= y; i++)
{
int x = i;
int nr2 = 0, nr3 = 0 , nr5 = 0;
while (x % 2 == 0)
{
nr2++;
x /= 2;
}
x = i;
while (x % 3 == 0)
{
nr3++;
x /= 3;
}
x = i;
while (x % 5 == 0)
{
nr5++;
x /= 5;
}
f2[i] = nr2 + f2[i - 1];
f3[i] = nr3 + f3[i - 1];
f5[i] = nr5 + f5[i - 1];
}
// for (i = 1; i <= y; i++)
// {
// cout << dbg(i) << dbg(f2[i]) << dbg(f3[i]) << dbg(f5[i]) << "\n";
// }
for (j = 0; j <= y; j++)
{
int nr2 = f2[y] - f2[y - j] - f2[j];
int nr3 = f3[y] - f3[y - j] - f3[j];
int nr5 = f5[y] - f5[y - j] - f5[j];
if (d == 2)
{
if (nr2 > 0) ans++;
}
if (d == 3)
{
if (nr3 > 0) ans++;
}
if (d == 4)
{
if (nr2 > 2) ans++;
}
if (d == 5)
{
if (nr5 > 0) ans++;
}
if (d == 6)
{
if (nr2 > 0 && nr3 > 0) ans++;
}
}
out << ans << "\n";
}