//2014.10.17    01:19

//题意:

//先输入一个数N,然后分块输入,每块输入每次2个数,n,m,直到n,m同一时候为零时 

//结束,当a和b满足题目要求时那么这对a和b就是一组

//注意:

//每一块的输出中间有一个回车

A Mathematical Curiosity

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 27177    Accepted Submission(s): 8651

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 1
20 3
30 4
0 0
 
Sample Output
Case 1: 2
Case 2: 4
Case 3: 5
 
Source
 

#include<stdio.h>
int main()
{
int N;
int n,m;
int a,b;
int cas;
scanf("%d",&N);
while(N--)
{
cas=1;
while(scanf("%d%d",&n,&m),n||m)
{
int count=0;
for(a = 1; a < n; a++)//穷举法
{
for(b = a + 1; b < n; b++)
{
if((a*a + b*b + m) % (a * b) == 0)
count++;
}
}
printf("Case %d: %d\n",cas++,count);
}
if(N)
printf("\n");
}
return 0;
}

HDU 1017 A Mathematical Curiosity【看懂题意+穷举法】的更多相关文章

  1. HDU 1017 A Mathematical Curiosity (输出格式,穷举)

    #include<stdio.h> int main() { int N; int n,m; int a,b; int cas; scanf("%d",&N); ...

  2. HDU 1017 A Mathematical Curiosity【水,坑】

    A Mathematical Curiosity Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  3. HDU 1017 A Mathematical Curiosity (数学)

    A Mathematical Curiosity Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  4. HDU 1017 - A Mathematical Curiosity

    题目简单,格式酸爽.. #include <iostream> using namespace std; int ans,n,m,p; int main() { cin>>p; ...

  5. HDU 1017 A Mathematical Curiosity(枚举)

    题目链接 Problem Description Given two integers n and m, count the number of pairs of integers (a,b) suc ...

  6. HDU 1017 A Mathematical Curiosity 数学题

    解题报告:输入两个数,n和m,求两个数a和b满足0<a<b<n,并且(a^2+b^2+m) % (a*b) =0,这样的a和b一共有多少对.注意这里的b<n,并不可以等于n. ...

  7. HDU 1017 A Mathematical Curiosity (枚举水题)

    Problem Description Given two integers n and m, count the number of pairs of integers (a,b) such tha ...

  8. PAT 甲级 1031 Hello World for U (20 分)(一开始没看懂题意)

    1031 Hello World for U (20 分)   Given any string of N (≥) characters, you are asked to form the char ...

  9. Hdu oj 1017 A Mathematical Curiosity

    题目:pid=1017">点击打开链接 #include<stdio.h> int main() { int t; scanf("%d",&t) ...

随机推荐

  1. Hibernate5.x版本HQL限定查询 Legacy-style query parameters (`?`) are no longer supported

    在此版本的限定查询和4.0版本的限定查询: 如果查询语句是: String hql = "select u from User u where u.gender = ?"; 会出现 ...

  2. spring注解开发-扩展原理(源码)

    1.BeanFactoryPostProcessor BeanPostProcessor:bean后置处理器,bean创建对象初始化前后进行拦截工作的; BeanFactoryPostProcesso ...

  3. 基于jquery的自定义显示消息数量

    根据需求简单的实现一个小功能控件,暂时不支持扩展 $("xxxxxxx").iconCountPlugin(options, start, isOffset) {//三个参数,自定 ...

  4. Shell数值比较

    Shell数值比较 比较 描述 n1 -eq n2 检查n1是否与n2相等 n1 -ge n2 检查n1是否大于或等于n2 n1 -gt n2 检查n1是否大于n2 n1 -le n2 检查n1是否小 ...

  5. 每日命令:(14)tune2fs

    tune2fs简介 tune2fs是调整和查看ext2/ext3文件系统的文件系统参数,Windows下面如果出现意外断电死机情况,下次开机一般都会出现系统自检.Linux系统下面也有文件系统自检,而 ...

  6. JS 获取字符串中的url并返回其下标索引

    //获取字符串中的url极其下标索引 function getHttpUrlArray(s) { var s1 = s.match(/http.*/); if(s1 == null) { return ...

  7. Struts2的线程安全性

    [什么是线程安全性?] 在多线程并发访问的情况下,如果一个对象中的变量的值不会随访问的线程而变化则是线程安全的.反之则称为非线程安全的. [Servlet是线程安全的吗?] [非线程安全的] publ ...

  8. JavaScript中上传文件为图片如何读取+JS中如何使用clip()剪切指定区域(UI组件之图片剪裁器)

    File读取和FileReader() //获取上传的文件/图片 function getFile(){ var files,len; var reader = new FileReader(); v ...

  9. Exact Change(01背包)

    描述 Seller: That will be fourteen dollars. Buyer: Here's a twenty. Seller: Sorry, I don't have any ch ...

  10. oracle导出多CSV文件的靠谱的

    oracle导出多CSV文件的问题 ---------------------------------------------------------------------- 用ksh脚本从orac ...