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. java笔记之static&final&abstract

    知识需要不断回顾和重新认识 一:static static类型变量初始值只能被赋值一次,它的整个生命周期是源程序,程序结束前变量都不会被释放. 例如: for(int i = 0; i<10; ...

  2. Spring学习一----------Spring概况

    © 版权声明:本文为博主原创文章,转载请注明出处 Spring概况 Spring是为了解决企业应用开发的复杂性而创建的. Spring是一种轻量级的控制反转(IOC)和面向切面(AOP)的容器框架. ...

  3. Android OOM的解决方式

    尽量不要使用setImageBitmap或setImageResource或BitmapFactory.decodeResource来设置一张大图. 由于这些函数在完毕decode后,终于都是通过ja ...

  4. 连接redis失败,关闭防火墙即可

    因为linux上有防火墙,我用redis desktop manager 测试所以始终连接不上, 关闭防火墙: systemctl stop firewalld.service #停止firewall ...

  5. ORACLE 12C R2 RAC 安装配置指南

    >> from zhuhaiqing.info ASM磁盘空间最低要求 求12C R2相比前一版本,OCR的磁盘占用需求有了明显增长.为了方便操作,设置如下:External: 1个卷x4 ...

  6. Redis学习笔记-Redis内部数据结构

    Redis内部数据结构 Redis和其他key-value数据库的很大区别是它支持非字符串类型的value值.它支持的value值的类型如下: sds (simple dynamic string) ...

  7. springboot 中使用AOP

    网上关于AOP的例子好多,各种名词解释也一大堆,反正名词各种晦涩,自己写个最最最简单的例子入门mark一下,以后再深入学习. maven依赖 <dependency> <groupI ...

  8. Linux 安装中文man手册

    Centos 安装中文man 虽然在CentOS操作系统中具有多语言包,但其man手册是英文的,对于新手来说能够使用中文man手册将加快学习速度. .首先需要确认的是有没有安装中文支持,如果没有请安装 ...

  9. MongoDBTemplate多条件查询的问题

    问题: 在使用Spring Data MongoDB 进行条件查询数据时,发现条件判断不起作用,结果会返回所有的数据. Criteria criteria = new Criteria(); crit ...

  10. lua(简单的传参)

    #include <iostream> #include <string.h> extern "C" { /*头文件lua.h定义了Lua提供的基础函数,包 ...