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. ios 访问隐私信息 info.plist 中的字段

    1.iOS10相册相机闪退bug: iOS10系统下调用系统相册,相机功能,遇到闪退的情况,描述如下: This app has crashed because it attempted to acc ...

  2. ABP .Net Core API和Angular前端APP集成部署

    前言:在ABP官网(https://aspnetboilerplate.com)生成的.Net Core + Angular项目前后端是两个独立的项目,我们可以分开部署,也可以将前端和Web API一 ...

  3. P、NP、NP完全问题

    如果一个算法的最差时间效率属于O(p(n)),则该算法可以在多项式的时间内对问题进行求解,其中p(n)是输入规模n的一个多项式函数. 可以在多项式时间内求解的问题是易解的.不能在多项式时间内求解的问题 ...

  4. BZOJ 4553 Tjoi2016&Heoi2016 序列

    Tjoi2016&Heoi2016序列 Description 佳媛姐姐过生日的时候,她的小伙伴从某宝上买了一个有趣的玩具送给他.玩具上有一个数列,数列中某些项的值 可能会变化,但同一个时刻最 ...

  5. java方式连接数据操作数据库

    package com.bdqn.dao.impl; import java.io.IOException;import java.io.InputStream;import java.io.Seri ...

  6. iOS XIB等比例适配

    选择两个视图使其等宽高,再去约束里面就可以设置乘数因子. 简单的一个例子: 要求:设置白色视图的宽度为蓝色视图的一半 1.点击白色视图连线到父视图,选择 Equal Widths     2.选择右边 ...

  7. chmod 命令详解

    chmod 作用:修改目录或文件权限(= 赋值不管存在与否, + 增加权限)符号链接的权限无法变更, 如果用户对符号链接修改权限, 其改变会作用在被链接的原始文件. 参数: -R: 递归修改处理 -v ...

  8. Netty-Websocket 根据URL路由,分发机制的实现

    最近在做netty整合websocket,发现网上很多项目都是最简单的demo,单例的一个项目. 然而公司的项目需要接受几个不同功能的ws协议消息,因此最好是用URL来区分,让页面上采用不同的链接方式 ...

  9. websocket(二) websocket的简单实现,识别用户属性的群聊

    没什么好说的,websocket实现非常简单,我们直接看代码. 运行环境:jdk8 tomcat8 无须其他jar包. 具体环境支持自己百度 package com.reach.socketContr ...

  10. python中输出内容颜色得控制

    参考:http://www.jb51.net/article/51237.htm 颜色代码 1)代码列表 格式:\[显示方式;前景色;背景色m 说明: 前景色 背景色 颜色 ------------- ...