传送门:

http://acm.hdu.edu.cn/showproblem.php?pid=1017

A Mathematical Curiosity

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

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
分析:
直接暴力即可
code:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define max_v 105
int main()
{
int t;
int n,m;
scanf("%d",&t);
while(t--)
{
int k=;
while(~scanf("%d %d",&n,&m))
{
if(n==&&m==)
break;
int c=;
//直接暴力即可
for(int i=; i<n-; i++)
{
for(int j=i+; j<n; j++)
{
if((i*i+j*j+m)%(i*j)==)
c++;
}
}
printf("Case %d: %d\n",k++,c);
}
if(t!=)
printf("\n");
}
return ;
}

HDU 1017A 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. 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 ...

  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. A Mathematical Curiosity

    A Mathematical Curiosity Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/O ...

  6. 牛客小白月赛5-I-区间(差分求前缀和+一次暴力统计)

    题目描述 Apojacsleam喜欢数组. 他现在有一个n个元素的数组a,而他要对a[L]-a[R]进行M次操作: 操作一:将a[L]-a[R]内的元素都加上P 操作二:将a[L]-a[R]内的元素都 ...

  7. 数位dp——统计'1'的个数

    今天去牛客网看了看 包含一 这道题,一开始没看清,以为它要统计 1~n 所有数中数字 '1' 出现的总次数,也就是说,若 n == 11,则 ans = 4:而按照题目的原意 ans 应该为 3.看错 ...

  8. 原创:C语言打开、下载、删除网页,统计网页字符个数

    本程序由本人在华夏联盟的ID闪电笨笨原创,首发地址:http://bbs.hx95.com/ 写此程序希望可以可以激发新手学习C语言的积极性! C语言代码实现功能如下:            1.实现 ...

  9. smarty中如何统计数组的个数?

    在做web前端中,很多人会遇到在smarty中如何统计数组的个数,其实很简单 比如数组$array 你只需要用{$array|@count}就可以获取.

随机推荐

  1. 基数排序——Java实现

    一.基数排序思想 相比其它排序,主要是利用比较和交换,而基数排序则是利用分配和收集两种基本操作.基数 排序是一种按记录关键字的各位值逐步进行排序的方法.此种排序一般适用于记录的关键字为整数类型的情况. ...

  2. Java--详解WebService技术

    Java--详解WebService技术 一.什么是 webservice WebService是一种跨编程语言和跨操作系统平台的远程调用技术. 所谓跨编程语言和跨操作平台,就是说服务端程序采用jav ...

  3. spring 代理

    java动态代理实现 1. Java自带的动态代理,反射生成字节码 2. Cglib调用asm生成子类 spring 中代理实现 1. 如果类实现了接口,使用java动态代理 2. 没有实现接口,使用 ...

  4. untiy3d小工具——修改scene与prefab中的sprite

    坑1:因为替换图片要获取所有包含image的组件,开始我使用的是gameobject.getComponents<Image>()和FindObjectsOfType<Image&g ...

  5. PAT 1071. Speech Patterns

    又是考输入输出 #include <cstdio> #include <cstdlib> #include <string> #include <vector ...

  6. curl POST JSON

    1. 场景 Controller接收json格式数据 封装bean @RequestMapping(value = "/bb", method = RequestMethod.PO ...

  7. Grunt实例

    module.exports = function(grunt) { // 项目配置 grunt.initConfig({ pkg: grunt.file.readJSON('package.json ...

  8. string 替换字符串

    C++的string提供了replace方法来实现字符串的替换,但是对于将字符串中某个字符串全部替换这个功能,string并没有实现,我们今天来做的就是这件事.首先明白一个概念,即string替换所有 ...

  9. 如何修改settings.xml的镜像

    今天在下载一个maven依赖包时候,下载后一直显示的是upload的jar包,然后检查了下自己的settings.xml配置,发现依赖的还是以前的内网nexus得配置.所以下载不下来,现在改为ali的 ...

  10. CCF201412-1 门禁系统

    试题编号: 201412-1 试题名称: 门禁系统 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 涛涛最近要负责图书馆的管理工作,需要记录下每天读者的到访情况.每位读者有一个 ...