A Mathematical Curiosity

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

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
分析:一道水题被我写的乱七八糟的,各种格式不对,首先m,n只要有一个为0就break,然后就是这个输出空行,输出格式输错了,GG!
下面给出AC代码:
 #include <bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int k=;
while(scanf("%d%d",&n,&m)&&n||m)
{
int ans=;
for(int i=;i<n;i++)
{
for(int j=i+;j<n;j++)
{
if((i*i+j*j+m)%(i*j)==)
ans++;
}
}
printf("Case %d: %d\n",k++,ans);
}
if(t)
printf("\n");
}
return ;
}

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 (枚举水题)

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

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

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

  5. HDU 1017 - A Mathematical Curiosity

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

  6. HDU 1017 A Mathematical Curiosity(枚举)

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

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

  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. Parallels Desktop 12 for Mac 破解版

    Parallels Desktop for Mac 是功能最强大灵活度最高的虚拟化方案,无需重启即可在同一台电脑上随时访问Windows和Mac两个系统上的众多应用程序.从仅限于PC的游戏到生产力软件 ...

  2. windows server 2008 R2服务器安装IIS并添加网站

    一.连接远程计算机 1.因为我的电脑是win7系统,故这里以win7为例,其他windows系统大同小异,首先点开开始菜单栏,在windows附件下找到远程桌面连接 或者采用通用的方法,利用快捷键wi ...

  3. Udacity并行计算课程笔记-The GPU Programming Model

    一.传统的提高计算速度的方法 faster clocks (设置更快的时钟) more work over per clock cycle(每个时钟周期做更多的工作) more processors( ...

  4. geoserver发布地图服务WMTS

    WMTS: 切片地图web服务(OpenGIS Web Map Tile Service) WMTS提供了一种采用预定义图块方法发布数字地图服务的标准化解决方案.WMTS弥补了WMS不能提供分块地图的 ...

  5. DNS查询相关

    本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/45 一种简单的设计方式是在因特网上使用一个DNS服务器,该服务器 ...

  6. Windows as a Service(1)—— Windows 10服务分支

    前言 作为公司的IT管理员,管理全公司Windows 10操作系统的更新一直是工作中的头疼之处.微软提供了很多方法来帮助我们管理公司的Windows 10更新,比如Windows Server Upd ...

  7. 记录一笔关于PHPEXCEL导出大数据超时和内存溢出的问题

    通过查阅资料可以找到PHPEXCEL本身已经有通过缓存来处理大数据的导出了.但是昨晚一直没有成功,这可捉急了.最后想来想去就替换了phpExcel的版本了.最后就成功了.话不多说,代码附上 <? ...

  8. 【liferay】3、liferay 添加spring支持

    1.添加对应的spring的jar 地址:https://spring.io/projects 选中springframework 进入git源码的地方,看简介 我们需要编译好的jar 当然也可以自己 ...

  9. git环境搭建以及第一个PHP程序

    使用mac下的sublime等编辑器帮助代码编写,然后到linux下运行网页代码.可以通过/vagrant共享目录完成,但是默认apache默认目录为/var/www/html,不想改变该目录,同时为 ...

  10. golang 数组反转

    我做hackerearth上题目记录,具体的题目描述是这样的: Given the size and the elements of array A, print all the elements i ...