A Mathematical Curiosity

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

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

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
 
题意:
先输入一个数N然后会分N块输入,每块输入每次2个数,n,m,知道n=m=0时结束,当a和b满足0<a<b<n且使(a^2+b^2 +m)/(ab) 的值为整数时,那么这对a和b就是一组

解 输出每次n和m对应的所有解的个数,但是要注意在每一块的输出中间有空行。

第一个输入的N的作用是 是有几个CASE的意思

代码:

 #include <stdio.h>
#include <math.h> int main()
{
int N;
scanf("%d",&N);
while(N--){
int k=;
int m,n;
while(scanf("%d %d",&n,&m),n||m)
{
int i,j,num=;
double t;
for(i=;i<n;i++)
for(j=i+;j<n;j++)
{
t = (i*i+j*j+m)*1.0/(i*j);
if(fabs(t-(int)t)<0.00000001)//这两句还可以这样处理 (i*i+j*j+m)*1.0%(i*j)==0
num++;
}
printf("Case %d: %d\n",k++,num);
}
if(N)
printf("\n");
}
return ;
}

弄清题意

hdu_1017_A Mathematical Curiosity_201310280948的更多相关文章

  1. [转]Mathematical Induction --数学归纳法1

    Mathematical Induction Mathematical Induction is a special way of proving things. It has only 2 step ...

  2. [中英双语] 数学缩写列表 (List of mathematical abbreviations)

    List of mathematical abbreviations From Wikipedia, the free encyclopedia 数学缩写列表 维基百科,自由的百科全书 This ar ...

  3. A Mathematical Curiosity 分类: HDU 2015-06-25 21:27 11人阅读 评论(0) 收藏

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

  4. Part 14 Mathematical functions in sql server

    Part 29 Mathematical functions in sql server

  5. Applied Functional Analysis(Applications to Mathematical Physics ) E.Zeidler

     Applied Functional Analysis(Applications to Mathematical Physics )   E.Zeidler More: QQ565055403

  6. NVIDIA CG语言 函数之所有数学类函数(Mathematical Functions)

    数学类函数(Mathematical Functions) abs(x) 返回标量和向量x的绝对值 如果x是向量,则返回每一个成员的绝对值 acos(x) 返回标量和向量x的反余弦 x的范围是[-1, ...

  7. 《Principles of Mathematical Analysis》-chaper1-实数系与复数系

    今天我们开始简单的介绍数学分析这门课程,参考教材是Walter Rudin著的<Principles of Mathematical Analysis> 对于一门新课你最开始可能会问的是: ...

  8. 《Mathematical Olympiad——组合数学》——染色问题

    恢复  继续关于<Mathematical Olympiad——组合数学>中问题的分析,这一篇文章将介绍有关染色的问题. 问题一: 将一些石头放入10行14列的矩形方格表内,允许在每个单元 ...

  9. A Mathematical Curiosity

    A Mathematical Curiosity Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/O ...

随机推荐

  1. 使用Keras做OCR时报错:ValueError: Tensor Tensor is not an element of this graph

    现象 项目使用 Flask + Keras + Tensorflow 同样的代码在机器A和B上都能正常运行,但在机器C上就会报如下异常.机器A和B的环境是先安装的,运行.调试成功后才尝试在C上跑. F ...

  2. JavaScript--关闭窗口(window.close)

    close()关闭窗口 用法: window.close(); //关闭本窗口 或 <窗口对象>.close(); //关闭指定的窗口 例如:关闭新建的窗口. <script typ ...

  3. DataFrame入门案例(集团公司对人事信息处理场景)

    我用一个集团公司对人事信息处理场景的简单案例,来作为入门,详细分析DataFrame上的各种常用操作,包括集团子公司的职工人事信息的合并,职工的部门相关信息查询.职工信息的统计.关联职工与部门信息的统 ...

  4. 无法定位程序输入点_except_handler4_common于动态链接库msvcrt.dll

    这是由于sp3加载的驱动造成的:只需要将C:\WINDOWS\system32\dwmapi.dll重新命名一下即可以解决. 可以调试程序当系统加载到“c:\Program Files\China M ...

  5. 单例模式在多线程环境下的lazy模式为什么要加两个if(instance==null)

    刚才在看阿寻的博客”C#设计模式学习笔记-单例模式“时,发现了评论里有几个人在问单例模式在多线程环境下为什么lazy模式要加两个if进行判断,评论中的一个哥们剑过不留痕,给他们写了一个demo来告诉他 ...

  6. 如何扒取一个网站的HTML和CSS源码

    一个好的前端开发,当看到一个很炫的页面的时候会本着学习的心态,想知道网站的源码.以下内容只是为了大家更好的学习,拒绝抄袭,支持正版. 1 首先我们要有一个chrome浏览器 2 在本地创建相关文件夹 ...

  7. JavaScript 封装插件学习笔记(一)

    此篇只是笔记,在借鉴.参考.模仿的过程,可能不完整,请多指教! 定义插件名称要注意命名冲突,防止全局污染. 1.第一种Javascript对象命名:(Javascript语言是“先解析,后运行”,解析 ...

  8. FFmpeg编译Android版本

    FFmpeg是很好用的一个音视频库,功能强大,但是用起来并不是很方便.之前一直不想用FFmpeg,因为感觉编译太麻烦,但是到了不得不用的时候了,没办法,参考了网上大神的方法,在这里自己也记录一下方便以 ...

  9. XSS攻击前端需注意

    XSS攻击,在WEB安全领域已经是老生常谈的问题,每每提到安全问题,也会首当其冲拿出来说事. 针对XSS攻击的解决方案,也非常成熟,主要就是:对用户输入信息的地方进行转义处理,当然我这里要提起的一个点 ...

  10. CSS——img

    img标签初始化:在低版本的ie浏览器会自带边框,所以建议border:0px.