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. python 读写数据

    开源标准数据集 —— mnist(手写字符识别) 下载地址:mnist.pkl.gz 1. 使用 python 读取和解析 mnist.pkl.gz import pickle import gzip ...

  2. js 元素Dom新建并插入页面createElement

    纯js var o = document.createElement('script'); o.type = 'text/template'; o.id = 'demo'; document.docu ...

  3. Eureka 源码编译安装部署---Eureka运行eureka-server服务

    ---恢复内容开始--- 折腾了几天,终于运行好了,两个字:佩服 首先感谢这个大佬的博客支持:https://www.cnblogs.com/lifuping/p/5663127.html 1.首先在 ...

  4. sublime使用技巧(2)-- 实用插件推荐【持续更新】

    1.Auto semicolon 在括号内输入分号,会自动把光标移到行尾然后再输入分号. 2.DocBlockr 补全注析格式,例如在函数上面输入/** + Enter,就会自动补全函数的注析说明. ...

  5. memcached使用总结

    我的linux版本信息:Linux version 4.4.0-78-generic (buildd@lgw01-11) (gcc version 5.4.0 20160609 (Ubuntu 5.4 ...

  6. 2015年Android开发新技术盘点

    又到年末. 利用中午的时间,汇总盘点一下今年Android开发方面的新技术.感觉如今Android开发没有曾经那么纯粹了,出现了非常多新的开发模式. 2015年影响比較普遍的新技术应该就是Materi ...

  7. cxf 创建动态webService

    D:\developTools\apache-cxf-2.5.2\samples\wsdl_first_dynamic_client CXF 方法 cxf方法 serviceInfo.getBindi ...

  8. bat命令遍历文件和bat参数说明

    **************************************************************************************************** ...

  9. PHP基础知识学习总结

    从今天开始过一遍PHP的基础知识   加油  地址:http://www.runoob.com/php/php-mail.html   该看:PHP发送电子邮件 2017年5月23日23:38:30 ...

  10. scp命令需要指定端口时要紧跟在scp后

      问题来源:我本地是Ubuntu操作系统,有时需要更新一些文件到服务器.但是,为了安全起见我们都是将服务器的sshd端口修改的,通常不使用默认的22号端口. 如果我们使用scp命令时:scp upl ...