Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

卡cin cout。有意思吗

Posted by KatrineYang at 2016-11-10 10:38:57 on Problem 2992
另外素数列到433,不然RE
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int primes[1229] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433};

int g(int n, int p){
	int res = 0;
	while(n>=p){
		n/=p;
		res+=n;
	}
	return res;
}

int main() {
	int n,k;
	while(scanf("%d%d",&n,&k)>0){
		long long int gs = 1;
		for(int i = 0; primes[i] <= n && primes[i] != 0; i++){
			int p = primes[i];
			gs *= (g(n,p)-g(k,p)-g(n-k,p)+1);
		}
		printf("%I64d\n",gs);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator