HDU 1017 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<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int main()
{
int a,b,mod,n,m,t,number,ans;
scanf("%d",&t);
while(t--) {
number=0;
while(scanf("%d%d",&n,&m)!=EOF){
if(n==0 && m==0) break;
ans=0;
for(a=1;a<n;a++) {
for(b=a+1;b<n;b++) {
if((a*a+b*b+m)%(a*b)==0) ans++;
}
}
printf("Case %d: %d\n",++number,ans);
}
if(t) printf("\n");
}
return 0;
}
HDU 1017 A Mathematical Curiosity (枚举水题)的更多相关文章
- 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(枚举)
题目链接 Problem Description Given two integers n and m, count the number of pairs of integers (a,b) suc ...
- 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【看懂题意+穷举法】
//2014.10.17 01:19 //题意: //先输入一个数N,然后分块输入,每块输入每次2个数,n,m,直到n,m同一时候为零时 //结束,当a和b满足题目要求时那么这对a和b就是一组 ...
- 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
题目简单,格式酸爽.. #include <iostream> using namespace std; int ans,n,m,p; int main() { cin>>p; ...
- HDU 1017 A Mathematical Curiosity (输出格式,穷举)
#include<stdio.h> int main() { int N; int n,m; int a,b; int cas; scanf("%d",&N); ...
- HDU 2096 小明A+B --- 水题
HDU 2096 /* HDU 2096 小明A+B --- 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen(&quo ...
- poj1873 The Fortified Forest 凸包+枚举 水题
/* poj1873 The Fortified Forest 凸包+枚举 水题 用小树林的木头给小树林围一个围墙 每棵树都有价值 求消耗价值最低的做法,输出被砍伐的树的编号和剩余的木料 若砍伐价值相 ...
随机推荐
- 【bzoj4555】[Tjoi2016&Heoi2016]求和 NTT
题目描述 在2016年,佳媛姐姐刚刚学习了第二类斯特林数,非常开心. 现在他想计算这样一个函数的值: S(i, j)表示第二类斯特林数,递推公式为: S(i, j) = j ∗ S(i − 1, j) ...
- [HNOI2004][bzoj1212] L语言 [Trie+dp]
题面 传送门 思路 无后效性 显然,不管某个前缀的理解方式是怎么样的,如果它能被理解,那么前面的决策对于后面的决策而言都是等价的 因此这题可以DP DP方程 令$dp[i]$表示前缀i是否能被理解 那 ...
- webstorm卡顿
http://blog.csdn.net/qq673318522/article/details/50583831 http://www.xiaobai8.com/Blog/1000.html
- vue中echarts 在element-ui的tab 切换时 width 为100px 时的解决方式
最近在项目中遇到了这种情况,需要在tab控件上渲染多个echart图标,然后切换查看时,发现图表的宽度不正确 原因:在页面进行加载时,隐藏的图表找不到对应的div大小,所以默认给了一个大小.所以要做的 ...
- 洋媳妇Susan教育孩子的方法
洋媳妇Susan教育孩子的方法 一个中国婆婆跟我说:「我的儿子去美国留学,毕业后定居美国. 还给我找了个洋媳妇Susan. 如今,小孙子Toby已经3岁了. 今年夏天,儿子為我申请了探亲签证. 在美国 ...
- Replacing Accented characters(Diacritic) .NET
原文发布时间为:2012-02-17 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Collections.Generic;using Syste ...
- ToolTip特效 JavaScript 盗取厦门人才网的特效
原文发布时间为:2009-05-17 -- 来源于本人的百度文章 [由搬家工具导入] 源代码:http://www.xmaspx.com/Services/FileAttachment.ashx?At ...
- Java中的内存机制及管理
1. Java根据虚拟机以及平台的版本不同而在内存中开辟不同大小的内存,通常不会关注这个大小. 2. 程序中的对象存储在内存的堆(heap)中 3. 程序中的方法和局部变量存储在内存的栈(Stack) ...
- linux 实现共享内存同步
本文主要对实现共享内存同步的四种方法进行了介绍. 共享内存是一种最为高效的进程间通信方式,进程可以直接读写内存,而不需要任何数据的拷贝.它是IPC对象的一种. 为了在多个进程间交换信息,内核专门留出了 ...
- LeetCode OJ-- Divide Two Integers *
https://oj.leetcode.com/problems/divide-two-integers/ 在不使用乘法.除法.求余的情况下计算除法. 使用减法计算,看看减几次. 刚开始寻思朴素的暴力 ...