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. Android之NDK开发(转载)

    http://www.cnblogs.com/devinzhang/archive/2012/02/29/2373729.html 一.NDK产生的背景 Android平台从诞生起,就已经支持C.C+ ...

  2. Rails mysql数据库连接的小坑

    基本上直接clone下来的话,数据库连接必失败.   注意,把用户名密码写在.env文件下

  3. [Swift通天遁地]六、智能布局-(6)其他几种约束关系:父视图/Corner/Edge/AnchorAndFillEdge

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  4. JavaScript--什么是函数

    函数是完成某个特定功能的一组语句.如没有函数,完成任务可能需要五行.十行.甚至更多的代码.这时我们就可以把完成特定功能的代码块放到一个函数里,直接调用这个函数,就省重复输入大量代码的麻烦. 如何定义一 ...

  5. mysql触发器的操作

    一.创建触发器 1.创建有一条执行语句的触发器 CREATE TRIGGER trigger_name BEFORE|AFTER trigger_EVENT(INSERT|DELETE|UPDATE) ...

  6. CF126B Password

    思路: kmp略作修改. 实现: #include <iostream> #include <cstdio> using namespace std; ; int neXt[M ...

  7. hibernate 级联删除报更新失败的问题(org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update)

    首先hibernate级联删除的前提是,首先需要在映射文件中配置,配置多表之间的关联关系: 下面以部门表(Dept)和员工表(Emp)为例: 1.在Emp.hbm.xml映射文件中配置many-to- ...

  8. SQL基本操作——HAVING

    HAVING:在 SQL 中增加 HAVING 子句原因是,WHERE 关键字无法与合计函数一起使用. 我们拥有下面这个 "Orders" 表: O_Id OrderDate Or ...

  9. Windows Server 2008无法远程连接

    Server 2008 R2依次配置好之后,重启发现总是远程桌面时而连接不上.具体现象如下: 偶尔可以通过桌面远程连接连接到Server.以为是防火墙的问题,各种设置——甚至关闭,依然无法连接.反复重 ...

  10. jenkins执行python脚本

    参考: https://blog.csdn.net/qq_39247153/article/details/81003244 https://blog.csdn.net/huashao0602/art ...