题目链接

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

#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
//#define LOCAL int main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif // LOCAL
//Start
int N;
cin>>N;
while(N--)
{
int i=;
int n,m;
while(cin>>n>>m)
{
if(n==&&m==)break;
i++;
int ans=;
for(double j=;j<n-;j++)
{
for(double k=j+;k<n;k++)
{
double t=(k*k+j*j+m)/(j*k);
if((int)t==t)ans++;
}
}
printf("Case %d: %d\n",i,ans);
}
if(N!=)printf("\n");
}
return ;
}

HDU 1017 A Mathematical Curiosity(枚举)的更多相关文章

  1. HDU 1017 A Mathematical Curiosity (枚举水题)

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

  2. HDU 1017 A Mathematical Curiosity【水,坑】

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

  3. HDU 1017 A Mathematical Curiosity (数学)

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

  4. HDU 1017 A Mathematical Curiosity【看懂题意+穷举法】

    //2014.10.17    01:19 //题意: //先输入一个数N,然后分块输入,每块输入每次2个数,n,m,直到n,m同一时候为零时  //结束,当a和b满足题目要求时那么这对a和b就是一组 ...

  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 数学题

    解题报告:输入两个数,n和m,求两个数a和b满足0<a<b<n,并且(a^2+b^2+m) % (a*b) =0,这样的a和b一共有多少对.注意这里的b<n,并不可以等于n. ...

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

    #include<stdio.h> int main() { int N; int n,m; int a,b; int cas; scanf("%d",&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. ArrayList、HashSet、HashTable、List、Dictionary的区别

    在C#中,数组由于是固定长度的,所以常常不能满足我们开发的需求. 由于这种限制不方便,所以出现了ArrayList. ArrayList.List<T> ArrayList是可变长数组,你 ...

  2. Windows 服务 Error 14001

    如果碰到 windows 服务安装不了或者启动不了,报14001的配置文件错误,那么 可以从.exe.config入手,我这次遇到的是配置中有中文注释导致的. 我把空行以及中文的注释去掉以后,整个世界 ...

  3. CentOS7安装Zabbix

    一.Zabbix简介 Zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. Zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系 ...

  4. Submission

    EI: ICIC Express Letters: http://www.icicelb.org/elb/index.html IJICIC: http://www.ijicic.net/ijicic ...

  5. css基础和心得(一)

     css开始 p{    font-size:12px;    color:red;    font-weight:blod } p为选择符p{}又称选择器,指明网页中要应用样式规则的元素.属性和值之 ...

  6. MySQL data路径为空解决方法

    CMD x:\mysql\5.7.12\bin>mysqld --initialize-insecure --user=mysql

  7. 读取HttpWebResponse流的两种方法及注意的问题

    1.  获取流 HttpWebRequest request= (HttpWebRequest)WebRequest.Create(uri); //构建http request     request ...

  8. 解决 bootstrap 在IE8下的兼容问题

    <meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="v ...

  9. bone collector hdu 01背包问题

    Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collec ...

  10. centos php 扩展安装

    1. 安装mysqli扩展 1.进入php源代码目录:# cd /home/apps/web/php/php-5.3.5/ 2.再进入要添加的mysqli扩展源码目录:# cd ext/mysqli/ ...