传送门:

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. 1.JDBC基础

    JDBC全称Java Database Connectivity,即Java数据库连接.(以下以MySQL为例,使用MySQL语句) Sun公司提供了标准JDBC API接口,没有实现具体类.各个数据 ...

  2. JBPM学习第1篇:入门与安装

    1.相关关键词 BPM:全称Business Process Management,即业务流程管理 BPEL:全称为Business Process Execution Language,即业务流程执 ...

  3. Effective C++ .15,16获取原始资源和成对使用同类型new和delete

    15. 智能指针可以通过get操作 #include <iostream> #include <cstdlib> #include <memory> using n ...

  4. 第11章 Media Queries 与Responsive 设计

    Media Queries--媒体类型(一) 随着科学技术不断的向前发展,网页的浏览终端越来越多样化,用户可以通过:宽屏电视.台式电脑.笔记本电脑.平板电脑和智能手机来访问你的网站.尽管你无法保证一个 ...

  5. struts2 国际化语言转换

    学习struts2,了解了使用struts2的配置文件可以走向国际化,实现页面的语言转换.我已中文和英文为例,简单的实现登录页面的国际化 废话不多说,上代码 一,login.jsp页面 使用s标签&l ...

  6. asp.net 日期转换为大写汉字

    //年份转换为大写汉字 public static string numtoUpper(int num) { return "零壹贰叁肆伍陆柒捌玖"[num].ToString() ...

  7. ccf-201709-2 公共钥匙盒

    问题描述 有一个学校的老师共用N个教室,按照规定,所有的钥匙都必须放在公共钥匙盒里,老师不能带钥匙回家.每次老师上课前,都从公共钥匙盒里找到自己上课的教室的钥匙去开门,上完课后,再将钥匙放回到钥匙盒中 ...

  8. 前端学习之路之CSS (一)

    Infi-chu: http://www.cnblogs.com/Infi-chu/ 简介:    CSS 指层叠样式表 (Cascading Style Sheets)    样式定义如何显示 HT ...

  9. ajax方法XHR.readyState五种状态与示例

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. Keras 时序模型

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/Thinking_boy1992/article/details/53207177 本文翻译自 时序模 ...