| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我按照这个思路求奇约数的个数。。。为什么不对阿~~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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator