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
欢迎参加IJCAI 2020麻将智能体竞赛,大奖等你拿!Welcome to IJCAI 2020 Mahjong AI competition with amazing prizes!

求N以内的完全平方数的个数,只有完全平方数才有奇数个因子

Posted by wzp_moon at 2015-09-10 17:22:08 on Problem 1218
/***********************************************************************
    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:
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