HDU 1017 A Mathematical Curiosity【看懂题意+穷举法】
//2014.10.17 01:19
//题意:
//先输入一个数N,然后分块输入,每块输入每次2个数,n,m,直到n,m同一时候为零时
//结束,当a和b满足题目要求时那么这对a和b就是一组
//注意:
//每一块的输出中间有一个回车
A Mathematical Curiosity
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.
1 10 1
20 3
30 4
0 0
Case 1: 2
Case 2: 4
Case 3: 5
#include<stdio.h>
int main()
{
int N;
int n,m;
int a,b;
int cas;
scanf("%d",&N);
while(N--)
{
cas=1;
while(scanf("%d%d",&n,&m),n||m)
{
int count=0;
for(a = 1; a < n; a++)//穷举法
{
for(b = a + 1; b < n; b++)
{
if((a*a + b*b + m) % (a * b) == 0)
count++;
}
}
printf("Case %d: %d\n",cas++,count);
}
if(N)
printf("\n");
}
return 0;
}
HDU 1017 A Mathematical Curiosity【看懂题意+穷举法】的更多相关文章
- HDU 1017 A Mathematical Curiosity (输出格式,穷举)
#include<stdio.h> int main() { int N; int n,m; int a,b; int cas; scanf("%d",&N); ...
- HDU 1017 A Mathematical Curiosity【水,坑】
A Mathematical Curiosity Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- HDU 1017 A Mathematical Curiosity (数学)
A Mathematical Curiosity Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- HDU 1017 - A Mathematical Curiosity
题目简单,格式酸爽.. #include <iostream> using namespace std; int ans,n,m,p; int main() { cin>>p; ...
- HDU 1017 A Mathematical Curiosity(枚举)
题目链接 Problem Description Given two integers n and m, count the number of pairs of integers (a,b) suc ...
- 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. ...
- HDU 1017 A Mathematical Curiosity (枚举水题)
Problem Description Given two integers n and m, count the number of pairs of integers (a,b) such tha ...
- PAT 甲级 1031 Hello World for U (20 分)(一开始没看懂题意)
1031 Hello World for U (20 分) Given any string of N (≥) characters, you are asked to form the char ...
- Hdu oj 1017 A Mathematical Curiosity
题目:pid=1017">点击打开链接 #include<stdio.h> int main() { int t; scanf("%d",&t) ...
随机推荐
- sed替换字符串中的某些字符
test.txt原文内容 http://jsldfjaslfjsldfjasl/test?jlsdfjsalfjslfd 使用sed替换 sed -ri 's/(http:\/\/)[^\/]*(\/ ...
- error: version in "./docker-compose.yml" is unsupported
#sudo rm /usr/bin/docker-compose #curl -L https://github.com/docker/compose/releases/download/1.20.0 ...
- C#中byte类型运算
首先看下面一段代码 byte x = 1; byte y = 2; byte z = x + y; Console.WriteLine(z); 可能很多人会说显示结果是3. 其实,这段代码无法运行,因 ...
- 我的MySql掉队了
本来今天高高兴兴,突然: raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)&qu ...
- JDK的4种引用类型
在java中,大致有以下几种引用类型,强引用(StrongReference).软引用(SoftReference).弱引用(WeakReference).虚引用(PhantomReference) ...
- 11. GLOBAL_VARIABLES 与 SESSION_VARIABLES
11. GLOBAL_VARIABLES 与 SESSION_VARIABLES 注意 从MySQL 5.7.6开始,show_compatibility_56系统变量的值会影响此处描述的表中的可用信 ...
- nginx 配置虚拟机 支持pathinfo
server { server_name shopx.local *.shopx.local; charset utf-8; root /Users/x/www/php/shopx.local/sho ...
- 【POJ 1061】青蛙的约会(EXGCD)
Description 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面.它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止.可是它们出发之前忘记了一件很重要的事 ...
- 【04】Firebug页面概况查看
Firebug页面概况查看 使用Firebug的概况,你可以测试Web页面导致延迟加载的文件. 通过打开页面 Firebug > Console(控制台)> Profile(概况). 你需 ...
- Leetcode 284.顶端迭代器
顶端迭代器 给定一个迭代器类的接口,接口包含两个方法: next() 和 hasNext().设计并实现一个支持 peek() 操作的顶端迭代器 -- 其本质就是把原本应由 next() 方法返回的元 ...