标签:
Description
Input
Output
Sample Input
5 1 6 3 10 4
Sample Output
2 6 16
Source
#include <iostream> #include <sstream> #include <fstream> #include <string> #include <vector> #include <deque> #include <queue> #include <stack> #include <set> #include <map> #include <algorithm> #include <functional> #include <utility> #include <bitset> #include <cmath> #include <cstdlib> #include <ctime> #include <cstdio> #include <cstring> using namespace std; typedef long long int ll; typedef pair<int, int> P; int read() { int x=0,f=1; char ch=getchar(); while(ch<‘0‘||ch>‘9‘) { if(ch==‘-‘)f=-1; ch=getchar(); } while(ch>=‘0‘&&ch<=‘9‘) { x=x*10+ch-‘0‘; ch=getchar(); } return x*f; } const double pi=3.14159265358979323846264338327950288L; const double eps=1e-6; const int mod = 1e9 + 7; const int INF = 0x3f3f3f3f; const int INT = 0x7fffffff; const int MAXN = 433; const int xi[] = {0, 0, 1, -1}; const int yi[] = {1, -1, 0, 0}; int N, T; int a[MAXN], cnt;//cnt记录素数的个数 void init() {//求素数 cnt = 0; for(int i = 2; i <=431 ; i++) { int flag = 1; for(int j = 2; j*j <= i; j++) { if(i%j == 0) { flag = 0; break; } } if(flag) { a[cnt++] = i; } } } inline int cal(int n, int k){//计算指数的个数 if(n < k) return 0; return n/k + cal(n/k, k); } int main() { init(); int n, k; while(~scanf("%d%d", &n, &k)){ ll res = 1LL; for(int i = 0; i < cnt; i++){//遍历 res *= 1LL*(cal(n, a[i]) - cal(k, a[i]) - cal(n-k, a[i]) + 1); } printf("%lld\n", res); } return 0; }
标签:
原文地址:http://www.cnblogs.com/cshg/p/5779090.html