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

Re:所以说数据不弱,题弱

Posted by kin2141539 at 2008-09-12 18:29:16 on Problem 1306
In Reply To:用__int64和用double都能过,因为题目说了输出结果 32位的最大值,所以当n==100时候,测试数据k最多到12 Posted by:kin2141539 at 2008-09-12 18:28:30
> /****************************************************
> 
> 
> 用64可以这样写
> ****************************************************/
> 
> #include<iostream>
> using namespace std;
> 
> 
>  __int64 kin_Cnk(int n,int k){
> 	__int64 sum1 = 1;
> 	__int64 sum2 = 1;
> 	int time = k;
> 	while(time--){
> 	   sum1 *= n--;
> 	   if(sum1%k==0){
> 		   sum1 /= k--;
> 	   }
> 	} 
> 	while(k)
> 		sum2 *= k--; 
> 	return sum1 / sum2;
> }
> 
> int main()
> {
> int n,k,temp;
> __int64 sum;
> while(scanf("%d%d",&n,&k)){
>    if(!n && !k) break;
>    if(k> n/2) temp = n - k;
>    else temp = k;
>    sum = kin_Cnk(n,temp);
>    printf("%d things taken %d at a time is %I64d exactly.\n"
> 			,n,k,sum);
> }
> 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