现在的位置: 首页 > 综合 > 正文

hdu1017-A Mathematical Curiosity

2013年03月18日 ⁄ 综合 ⁄ 共 487字 ⁄ 字号 评论关闭

http://acm.hdu.edu.cn/showproblem.php?pid=1017

注意格式,在每一组的结束输出一行空行,就是在输入n,m均为0时,

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<stdlib.h>
#include<iomanip> 
using namespace std;

int main()
{
	int Case ;
	int n , m ;
	cin >> Case ;
	int flag = 0 ;
	while( Case-- )
	{
		
		if( flag )
			cout <<endl ; 
			int temp = 1 ;
		while( cin >> n >> m )
		{
			if( !( n + m ) )
			{
				flag = 1 ;
				break ;
			}
			int ans = 0 ;
			for( int i = 1 ; i < n ; ++i )
				for( int j = i + 1 ; j < n ; ++j )
				{
					if( ( i * i + j * j + m ) % ( i * j ) ==  0 )
						ans++;			
				}
				printf( "Case %d: %d\n" , temp++ , ans ) ;
		}	
	}
	return 0 ;
}

抱歉!评论已关闭.