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 Zeor at 2008-11-18 14:29:20 on Problem 2140
In Reply To:Re:算法是有的!!!!!!acm 50 发帖庆祝 ! Posted by:19850317 at 2007-09-06 15:37:31
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
	int n,m;
	while (scanf ("%d",&n)!=EOF)
	{
		int count=0;
		m=(int)(sqrt(n*1.0));
		for (int i=3;i<=m;i+=2)
		{
			if(n%i==0)
			   count+=2;
		}
		if(n%2)
			count++;
		if(m%2&&m*m==n)///完全平方切方根为奇数。。。
			count--;
		printf ("%d\n",count+1);///考虑自己加一次的情况。。。
	}
}

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