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
 
  WA点在于格式控制!!

!细致审题

#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 (枚举水题)的更多相关文章

  1. HDU 1017 A Mathematical Curiosity【水,坑】

    A Mathematical Curiosity Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  2. HDU 1017 A Mathematical Curiosity(枚举)

    题目链接 Problem Description Given two integers n and m, count the number of pairs of integers (a,b) suc ...

  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. 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. ...

  6. HDU 1017 - A Mathematical Curiosity

    题目简单,格式酸爽.. #include <iostream> using namespace std; int ans,n,m,p; int main() { cin>>p; ...

  7. HDU 1017 A Mathematical Curiosity (输出格式,穷举)

    #include<stdio.h> int main() { int N; int n,m; int a,b; int cas; scanf("%d",&N); ...

  8. HDU 2096 小明A+B --- 水题

    HDU 2096 /* HDU 2096 小明A+B --- 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen(&quo ...

  9. poj1873 The Fortified Forest 凸包+枚举 水题

    /* poj1873 The Fortified Forest 凸包+枚举 水题 用小树林的木头给小树林围一个围墙 每棵树都有价值 求消耗价值最低的做法,输出被砍伐的树的编号和剩余的木料 若砍伐价值相 ...

随机推荐

  1. 什么是虚假唤醒 spurious wakeup

    解释一下什么是虚假唤醒? 说具体的例子,比较容易说通. pthread_mutex_t lock; pthread_cond_t notempty; pthread_cond_t notfull; v ...

  2. [Android]APK一键反编译

    每次反编译就是件很烦的事情,烦了就开始偷懒.直接写成脚本节省操作. 使用apktool,d2j-dex2jar进行反编译 脚本:reseve-complie-apk.py import os impo ...

  3. Quotes

    A man's gotta do what a man's gotta do.

  4. 负载平衡(cogs 741)

    «问题描述:G 公司有n 个沿铁路运输线环形排列的仓库,每个仓库存储的货物数量不等.如何用最少搬运量可以使n 个仓库的库存数量相同.搬运货物时,只能在相邻的仓库之间搬运.«编程任务:对于给定的n 个环 ...

  5. 支线剧情(bzoj 3876)

    Description [故事背景] 宅男JYY非常喜欢玩RPG游戏,比如仙剑,轩辕剑等等.不过JYY喜欢的并不是战斗场景,而是类似电视剧一般的充满恩怨情仇的剧情.这些游戏往往 都有很多的支线剧情,现 ...

  6. .NET and php

    原文发布时间为:2011-12-29 -- 来源于本人的百度文章 [由搬家工具导入] http://www.php-compiler.net/blog/2011/phalanger-3-0

  7. quartz的配置

    Quartz.Net中的概念:计划者(IScheduler).工作(IJob).触发器(Trigger).给计划者一个工作,让他在Trigger(什么条件下做这件事)触发的条件下执行这个工作 将要定时 ...

  8. 为什么mfc的入口是InitInstance()而没有WinMain() (转)

    学过PE文件格式,就明白,程序在进入WinMain之前要做很多事情,比如初始Dos头,分配函数表,初始化全局变量,之后才进入程序入口(WinMain) MFC对WindowsAPI进行了封装.在用向导 ...

  9. 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---27

    以下为阅读<Linux命令行与shell脚本编程大全 第3版>的读书笔记,为了方便记录,特地与书的内容保持同步,特意做成一节一次随笔,特记录如下:

  10. 设置div自适应高度滚动

    <body> <div id="divc" style="overflow: auto;"> </div> <a id ...