Pagini recente » Cod sursa (job #2646950) | Cod sursa (job #2464884) | Cod sursa (job #1390155) | Cod sursa (job #2507117) | Cod sursa (job #3157521)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("pascal.in");
ofstream fout("pascal.out");
pair< int, pair<int, int> > c[5000001];
int main(){
cin.tie(0);ios::sync_with_stdio(0);
//1.
int r, d;
int c2 = 0, c3 = 0, c5 = 0;
//2.
fin >> r >> d;
//3.
for(int i = 1; i <= 5000000; i++){
c2 = 0, c3 = 0, c5 = 0;
int i1 = i;
while(i1 % 2 == 0){
c2++;
i1 /= 2;
}
while(i1 % 3 == 0){
c3++;
i1 /= 3;
}
while(i1 % 5 == 0){
c5++;
i1 /= 5;
}
c[i].first = c2;
c[i].second.first = c3;
c[i].second.second = c5;
}
/*
for(int i = 1; i <= 10; i++){
cout << i << " : " << c[i].first << " " << c[i].second.first << " " << c[i].second.second << endl;
}
*/
for(int i = 2; i <= 5000000; i++){
c[i].first += c[i - 1].first;
c[i].second.first += c[i - 1].second.first;
c[i].second.second += c[i - 1].second.second;
}
int cnt = 0;
for(int i = 1; i <= r; i++){
c2 = c[r].first - c[i].first - c[r - i].first;
c3 = c[r].second.first - c[i].second.first - c[r - i].second.first;
c3 = c[r].second.second - c[i].second.second - c[r - i].second.second;
//cout << "i = " << i << " c2 = " << c2 << " c3 = " << c3 << " c5 = " << c5 << endl;
if(d == 2 && c2 > 0) cnt++;
else if(d == 3 && c3 > 0) cnt++;
else if(d == 4 && c2 > 1) cnt++;
else if(d == 5 && c5 > 0) cnt++;
else if(d == 6 && c2 > 0 && c3 > 0) cnt++;
}
fout << cnt << endl;
return 0;
}