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
 
Sample Way
 

#include <stdio.h>
int main()
{
  int n,m,N,a,b,i,count,j;
  scanf("%d",&N);
  for(i=0;i<N;i++)
  {
  j=0;
    while(scanf("%d%d",&n,&m)!=EOF&&(n!=0||m!=0))
    {
      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",++j,count);
    }
  if(i<N-1) printf("\n");
  }
return 0;
}

析:

非常狗血的一道题,简单的数学问题,给出一个区间(m,n),求在这个区间之内有多少对满足0<a<b<n并且 (a^2+b^2 +m)/(ab)是整数这个条件的a,b。

下面是这道题的槽点——输出格式,我费了半天劲,终于搞明白了,要求你输入一个整数N,在这之后是一个空行,接下来有N个输入块,每个输入块都以0 0的输入为结束标志,然后每个输入块中你要输入m和n,注意在你输入0 0之前,这个输入块是不会结束的。所以Sample Input的意思是只有一个输入块,然后0 0的时候就结束了,结束的时候没有空行,也就是暗示你程序最后一个输入块结束时不需要空行,之前的输入块之间都有空行ToT。

hd acm1017的更多相关文章

  1. ATI Radeon HD 5450 with full QE/CI Support ( 转载 )

    ATI Radeon HD 5450 with full QE/CI Support - DSDT (Contains HDMI Audio Edit Too) & AGPM included ...

  2. XPS 15 9530使用Windows10频繁发生Intel HD Graphics 4600驱动奔溃的一种解决方法

    本人使用XPS 15 9530.集成显卡为Intel HD Graphics 4600.操作系统Windows 10 Pro,使用过程当中经常会发生集成显卡奔溃的问题,错误提示如下: Display ...

  3. Radeon HD 7850 vs Radeon R9 270X

    Radeon HD 7850 vs Radeon R9 270X  HW compare   Intro The Radeon HD 7850 comes with a GPU core speed ...

  4. 电影TS、TC、SCR、R5、BD、HD等版本是什么意思

    在很多电影下载网站的影片标题中我们都能看到,比如<刺杀希特勒BD版>.<游龙戏凤TS版>等,这些英文缩写都是什么意思呢?都代表什么画质?以下就是各个版本的具体含义: 1.CAM ...

  5. stm32类型cl、vl、xl、ld、md、hd的含义

    - startup_stm32f10x_ld_vl.s: for STM32 Low density Value line devices - startup_stm32f10x_ld.s: for ...

  6. 瑞昱Realtek(Realtek HD Audio Driver)音频声卡驱动R2.49 for Win7_Vista

    不管是在高端系列主板上,还是在低端系列主板上,我们都能看到Realtek瑞昱的身影,Realtek HD Audio Driver能够支持所有的Realtek HD Audio音频驱动.Realtek ...

  7. cocos2d-x 2.0.3 设置高清模式注意事项(已移除-hd方式)

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=304 在cocos2d-x 2. ...

  8. %hd %d %ld %u ......

    %d 有符号10进制整数 %ld 长整型 %hd短整型%md,m指定的是输出字段的宽度,默认左补空格, 如果数据的位数小于m,则左端补以空格,若大于m,则 按实际位数输出,如: printf(&quo ...

  9. 求刷Kindle Fire HD的方法

    前几天入手了台Amazon Kindle Fire HD 其系统是经过Amazon尝试改造过的Android,用起来很不爽,想刷个CM10之类的,求教程和工具.

随机推荐

  1. int byte转换

    //命令码0x8001转为int为32769,发送时反序 ] { 0x01, 0x80 }; ); //int to byte[] ; byte[] b = BitConverter.GetBytes ...

  2. unity4.6 Beta版 UI控件之Button

    近期需求,须要用到4.6版本号uGui了,所以抽时间来学习学习,就UI控件在Unity工具里创建预设这块来说相比較于NGUI,我认为是没有什么太大的差别的. 比方:Canvas--Camera . T ...

  3. Struts2学习之拦截器

    © 版权声明:本文为博主原创文章,转载请注明出处 拦截器: - Struts2大多数核心功能都是通过拦截器实现的,每个拦截器完成某项功能 - 拦截器方法在Action执行之前或之后执行 工作原理: - ...

  4. 初识C++之虚函数

    1.什么是虚函数 在基类中用virtual关键字修饰.并在一个或多个派生类中被又一次定义的成员函数.使用方法格式为: virtual 函数返回类型 函数名(參数表) { 函数体 } 虚函数是实现多态性 ...

  5. 【Oracle】使用BBED跳过丢失的归档

    在recover datafile的过程其中假设丢失了须要的归档将使得recover无法进行.使用bbed工具能够跳过丢失的归档进行recover datafile. 实验步骤例如以下: SYS@OR ...

  6. java编写socket使用bufferedReader.readLine()问题研究

    不写java代码好久,临时写个socket通讯竟然失败,郁闷之下仔细研究了下. 客户端使用BufferedReader来读取数据,在while中调用BufferedReader.readLine()函 ...

  7. 【MIG专项测试组】如何准确评测Android应用的流畅度?

    转自 腾讯Bugly 叶方正,2008年加入腾讯,就职于无线研发部[专项测试组].曾经负责多个产品的性能优化工作,积累大量的移动终端平台优化以及评测经验. 怎样获取SM值? 前文我们分析了通过测量应用 ...

  8. [转]const指针与指向const的指针

    经常忘记,保存一下.. #include <iostream> using namespace std; int main(int argc, char *argv[]) { ; int ...

  9. MIC中函数和变量的声明

    c++/c使用 __declspec(target(mic))函数或变量声明 或 __attribute__((target(mic)))函数或变量声明 举例如下: __attribute__((ta ...

  10. window 杀死已开任务启命令

    1. 查询已开启的端口号 C:\Users\Administrator>netstat -ano | findstr 如果被占用会查询出相关信息,如果没有被占用则不会输出任何信息,查询到已开启信 ...