| ||||||||||
| 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 | |||||||||
求N以内的完全平方数的个数,只有完全平方数才有奇数个因子/***********************************************************************
Copyright (c) 2015,wangzp
All rights no reserved.
Name: 《THE DRUNK JAILER》In PEKING UNIVERSITY ACM
ID: PROBLEM 1218
问题简述: 求N(5<=N<=100)以内的完全平方数。
5以内的完全平方数为1和4
只有完全平方数才有奇数个因子,因子都是成对儿出现的
比如4的因子有1和它本身(1*4),还有(2*2)
因子2相同,重复合并为1个2,所以有三个因子:1,4,2
Date: SEP 10, 2015
***********************************************************************/
#include <stdio.h>
int main(void)
{
int n,m,sum,i,j;
scanf("%d",&n);
for (i = 0;i < n;i++)
{
scanf("%d",&m);
sum = 0;
for (j = 1;j * j <= m;j++)
{
sum++;
}
printf("%d\n",sum);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator