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

不是 整数分解因式吗?怎么感觉大家的想法和我不一样你?

Posted by namewchwch at 2009-11-04 23:25:02 on Problem 1011
#include<iostream>
using namespace std;
int main()
{
   int n ,k ,max=0,sum=0;
   while(cin>>n)
   {
	   if(!n){break;}
	   while(n--)
	   {
		   cin>>k;
		   if(max<k){max=k;}     //记录最大的数
		   sum=sum+k;
	   }
	   max=max+1;       //从比最大的数  大1个单位开始。
	   for(;;max++)     //木棒是等长的 所以只能整除即可 	   {
	    if(sum%max==0){cout<<max<<endl;break;}
	   }
	   max=0;sum=0;
   }
   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