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 zdker at 2005-09-27 11:42:45 on Problem 2140
#include <stdio.h>
int main()
{
	int n,i,ways;
	scanf("%d",&n);
	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;
}
这个程序能AC !!!
#include <stdio.h>
int main()
{
	int n,i,ways;
	scanf("%d",&n);
	ways = 0;
	if(n%2 != 0)ways++;
	for(i = 1;i < n;i = i + 2)
	{
                  if (i * (i + 1) / 2 > n) //加了这个语句就WA ...
                           break;
                  if(n%i == 0)
                           ways++;
	}
	printf("%d\n",ways);
	return 0;
}
它保证构造的最小一个数大于等于1 !!!
Wa ... Why !!!

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