A Mathematical Curiosity

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

Total Submission(s): 25871    Accepted Submission(s): 8174

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
 
Recommend
JGShining   |   We have carefully selected several similar problems for you:  1013 

pid=1018" target="_blank">1018 1005 

pid=1021" target="_blank">1021 

pid=1012" target="_blank">1012




对这道题不解释。题目的例子错了,那个1后面根本不要空行,还是看讨论区才知道。

代码:78MS

 #include<iostream>
using namespace std;
int main(){
int
n,m,cont=0,num=0;
int
T;
cin>>T;
while(
T--)
{
while(
cin>>n>>m&&n!=0)
{
int
a,b;
for(
a=1;a<=n;++a){
for(
b=a+1;b<n;++b){
if((
a*a+b*b+m)%(a*b)==0)
cont++;
}
}

cout<<"Case "<<++num<<": "<<cont<<endl; //没打空格的同学伤不起啊。 。 。
cont=0;
}

num=0;
if(
T)
cout<<endl;
}
}

HDU 1017 A Mathematical Curiosity (数学)的更多相关文章

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

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

  2. HDU 1017 A Mathematical Curiosity【看懂题意+穷举法】

    //2014.10.17    01:19 //题意: //先输入一个数N,然后分块输入,每块输入每次2个数,n,m,直到n,m同一时候为零时  //结束,当a和b满足题目要求时那么这对a和b就是一组 ...

  3. HDU 1017 - A Mathematical Curiosity

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

  4. HDU 1017 A Mathematical Curiosity(枚举)

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

  5. 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. ...

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

    #include<stdio.h> int main() { int N; int n,m; int a,b; int cas; scanf("%d",&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. Hdu oj 1017 A Mathematical Curiosity

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

  9. HDOJ 1017 A Mathematical Curiosity

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

随机推荐

  1. 怎样用Java代码来把SSL的证书自己主动导入到Java的秘钥存储文件(keystore)

    我们在开发或者使用SSL的过程中,非常多的软件须要我们提供java的keystore.特别是一些基于Java的中间件产品. 我们常规的做法是JDK自带的工具命令(keytool)去做.比方,以下的样例 ...

  2. C#子类如何调用父类

    C#中子类是如何调用父类的?带着这个问题,体验如下: □ 通过子类无参构造函数创建子类实例 创建父类Person和子类Student. public class Person { public Per ...

  3. MVC扩展ActionInvoker,自定义ActionInvoker,根据请求数据返回不同视图

    ActionInvoker的作用是:根据请求数据(HttpPost,HttpGet等)和action名称,来激发响应的action,再由action渲染视图.本文通过自定义ActionInvoker, ...

  4. SimpleDateFormat in Java is not Thread-Safe Use Carefully

    SimpleDateFormat in Java  very common and used to format Date to String and parse String into Date i ...

  5. ztree使用系列三(ztree与springmvc+spring+mybatis整合实现增删改查)

    在springmvc+spring+mybatis里整合ztree实现增删改查,上一篇已经写了demo,以下就仅仅贴出各层实现功能的代码: Jsp页面实现功能的js代码例如以下: <script ...

  6. Linux架构和目录-基础篇

    1.Linux目录结构 2. /boot/ 存放系统内核文件,如vmlinuz,initrd,System.map等.其中, a. vmlinuz是可引导的.压缩的内核,“vm”即“Virtual M ...

  7. 第六章 字节码执行方式--解释执行和JIT

    注:主要参考自<分布式java应用:基础与实践><深入理解Java虚拟机(第二版)> 1.两种执行方式: 解释执行(运行期解释字节码并执行) 强制使用该模式:-Xint 编译为 ...

  8. 第四章 CopyOnWriteArraySet源码解析

    注:在看这篇文章之前,如果对CopyOnWriteArrayList底层不清楚的话,建议先去看看CopyOnWriteArrayList源码解析. http://www.cnblogs.com/jav ...

  9. Windows环境搭建Red5流媒体服务器

    Windows环境搭建Red5流媒体服务器指南 测试环境:Windows 7 一.   下载安装程序 red5-server 下载地址 https://github.com/Red5/red5-ser ...

  10. effective C++中条款37:绝不又一次定义继承而来的缺省參数值

    virtual 函数会动态绑定,而virtual函数的缺省參数值是静态绑定的. 用一个base类型的指针p去指向一个derived类对象.通过p调用虚函数时,会动态绑定到实际所指对象中的函数:用一个d ...