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:兄弟,21=1+2+3+4+5+6,怎么不算对..

Posted by z12y12l12 at 2007-03-23 17:15:14 on Problem 2140
In Reply To:请问大牛:这道题输入21应该输出什么? Posted by:xuezaiyue at 2005-05-30 22:04:00
> 我觉得应该输出3
> 21=21
> 21=10+11
> 21=6+7+8
> 答案21=0+1+2+3+4+5+6应该是不对的。
> 
> 
> 下面有两段代码,
> 第一段代码是我同学做的,我用mj试过,这段程序是能够AC的,但是输入21,输出是4
> 第二段是我的程序,对于数据21,输出是3,我觉得没错,但是wa了,请教大牛,怎么回事?
> 
> /*********代码1**************/
>  #include <stdio.h>
>  int main()
>  {
>  	int n,i,ways;
>  	while(scanf("%d",&n)!=EOF)
> 	{
>  	ways = 0;
>  	if(n%2 != 0)ways++;
>  	for(i = 1;i < n;i = i + 2)
>  	{
>  		if(n%i == 0)
> 			ways++;
>  	}
>  	printf("%d\n",ways);
> 	}
>  	return 0;
>  }
> 
> 
> 
> 
> /************代码2************/
> #include <stdio.h>
> main()
> {
> 	long n;
> 	long i;
> 	long num;
> 
> 
> 	while(scanf("%ld",&n)!=EOF)
> 	{
> 		num=0;
> 		for(i=0;i*(2*i+1)<=n;i++)
> 			if(n%(2*i+1)==0 && n/(2*i+1)>i)
> 				num++;
> 		i=1;
> 		while((n/i)%2==0)
> 		{
> 			i=i*2;
> 		}
> 
> 		if(n/i>2*i)
> 			num++;
> 
> 
> 		printf("%ld\n",num);
> 	}
> }
> 
> 

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