注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Minary_Acdream

http://f10.moe/

 
 
 

日志

 
 

[hdu]1017 A Mathematical Curiosity  

2012-08-13 14:22:42|  分类: HDU |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

水题。。略过

A Mathematical Curiosity

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16446    Accepted Submission(s): 5122


Problem Description
Given two integers n and m, count the number of pairs of integers (a,b) such that 0 < a < b < n and (a^2+b^2 +m)/(ab) is an integer.

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.
 

Input
You will be given a number of cases in the input. Each case is specified by a line containing the integers n and m. The end of input is indicated by a case in which n = m = 0. You may assume that 0 < n <= 100.
 

Output
For each case, print the case number as well as the number of pairs (a,b) satisfying the given property. Print the output for each case on one line in the format as shown below.
 

Sample Input
1  

10 
20 3 
30 4 
0 0
 

Sample Output
Case 1: 2 
Case 2: 4 
Case 3: 5
 

Source
 

Recommend
JGShining
 



#include<iostream>
using namespace std;

int main()
{
int N;
cin>>N;
while(N--)
{
int n,m;
int t = 0;
while(cin>>n>>m,!(n==0 && m==0))
{
t++;
int count = 0;
printf("Case %d: ",t);
for(int a = 1;a < n;a ++)
{
for(int b = a + 1;b < n;b ++)
{
if((a * a + b * b + m) % (a * b) == 0)
count ++;
}
}
printf("%d\n",count);
}
if(N)cout<<endl;
}
}

/*
n m,
count the number of pairs of integers (a,b)
0 < a < b < n and (a^2+b^2 +m)/(ab) is an integer.
Sample Input
1

10 1
20 3
30 4
0 0


Sample Output
Case 1: 2
Case 2: 4
Case 3: 5
*/



  评论这张
 
阅读(120)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018