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) ...
随机推荐
- ie8兼容性
ie8下不支持css的nth-child()样式解决方法一:使用jQuery的nth-child()方法例:$(".ability-head-list ul li:nth-child(1) ...
- js 函数节流和防抖
js 函数节流和防抖 throttle 节流 事件触发到结束后只执行一次. 应用场景 触发mousemove事件的时候, 如鼠标移动. 触发keyup事件的情况, 如搜索. 触发scroll事件的时候 ...
- OpenSSH高级功能之端口转发(Port Forwarding)
在RedHat提供的系统管理员指南中提到OpenSSH不止是一个安全shell,它还具有X11转发(X11 Forwarding)和端口转发(Port Forwarding)的功能.X11功能一般用于 ...
- hdu3376 Matrix Again
最大费用最大流 咋写?取个相反数就可以了-- #include <iostream> #include <cstring> #include <cstdio> #i ...
- (二)java集合框架综述
一集合框架图 说明:对于以上的框架图有如下几点说明 1.所有集合类都位于java.util包下.Java的集合类主要由两个接口派生而出:Collection和Map,Collection和Map是Ja ...
- Centos6.5安装Oracle11.2.0.4 RAC(完整版)
环境参数:Linux:Centos6.5 Grid和Oracle:11.2.0.4 一.环境配置 1.配置Node1和Node2两个节点之间的网卡 Node1: [root@rac1 network- ...
- [CTSC2007]数据备份Backup 题解
题意: 一维直线上有n个点,任取2k个互不相同的点组成k条链,求链的最小总长 思路: 1.最优时链不相交,相邻两两相减,将题目转化为:在n-1个数中取互不相邻的k个数使总和最小. 2.贪心取最小的“数 ...
- git clone, push, pull, fetch 的用法
Git是目前最流行的版本管理系统,学会Git几乎成了开发者的必备技能. Git有很多优势,其中之一就是远程操作非常简便.本文详细介绍5个Git命令,它们的概念和用法,理解了这些内容,你就会完全掌握Gi ...
- bzoj3142[Hnoi2013]数列 组合
Description 小 T最近在学着买股票,他得到内部消息:F公司的股票将会疯涨.股票每天的价格已知是正整数,并且由于客观上的原因,最多只能为N.在疯涨的K天中小T观察 到:除第一天外每天的股价都 ...
- ubuntu使用git提交github时,执行pull或者push命令要重新输入用户名和密码
ubuntu使用git提交github时,执行pull或者push命令要重新输入用户名和密码: 1:问题现象: hlp@hlp:~/code/github_code/catch_imooc1$ git ...