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. codevs1004四子连棋

    1004 四子连棋  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold     题目描述 Description 在一个4*4的棋盘上摆放了14颗棋子,其中有7颗白 ...

  2. ThreadLocal原理及用法详解

    背景 一直以来对ThreadLocal用法模棱两可,不知道怎么用今天好好研究了下给大家分享下. 1.讲解ThreadLocal之前先回顾下什么是取模.x^y.弱引用. 1. 取模运算实际上是计算两数相 ...

  3. 悼念512汶川大地震遇难同胞——老人是真饿了 hdu 2187

    在此对 曾经 努力参加 救援的人 致以深深的敬意 . 这一道题 挺简单的 就是简单的  结构体+贪心 而已 不过 用英文 注释  是一个 很大的 进步 ,  以后 要习惯 http://acm.hdu ...

  4. 24Pointgame-----24点游戏

    题意简单     第一行是  测试数据有几组   然后分别有  几行  第一个数字是  有几个数字  第二个是 需要配出来的数字 下面附上我的代码   ---   我感觉 我这个代码 和其他人的都不一 ...

  5. $tsinsenA1067$

    \(problem\) 这种题目需要一个定理 \(a[1]+a[2]+a[3]+a[4]...=(a[1]%mod)+...\) 本人出奇的懒 然后 动态规划?(恰似枚举) #include < ...

  6. ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/pod

    因为突然要用到cocospod,突然发现在使用pod install的时候出现 -bash: pod: command not found 我去-不知道为什么,然后我就想重新安装下cocospod,在 ...

  7. JavaScript 计时器

    在JavaScript中,我们可以在设定的时间间隔之后来执行代码,而不是在函数被调用后立即执行.计时器类型:一次性计时器:仅在指定的延迟时间之后触发一次.间隔性触发计时器:每隔一定的时间间隔就触发一次 ...

  8. HTTP协议头部字段释义

    1. Accept:告诉WEB服务器自己接受什么介质类型,*/* 表示任何类型,type/* 表示该类型下的所有子类型,type/sub-type. 2. Accept-Charset: 浏览器申明自 ...

  9. 实现PC延迟执行函数

    头文件内容: #pragma once typedef function<void ()> DelayClickHandler; typedef void (*pDelayFun)(); ...

  10. html——细线表格

    细线: 1.table表格设置背景色 2.table中设置单元格距离 3.tr标签设置另外一种背景色 <!DOCTYPE html> <html> <head lang= ...