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. NSNotification的几点说明

    1.NSNotification消息的同步性 ①NSNotification使用的是同步操作.即如果你在程序中的A位置post了一个NSNotification,在B位置注册了一个observer,通 ...

  2. python 读写 json文件

    json的优势: 1. 数据体积方面. JSON相对于XML来讲,数据的体积小,传递的速度更快些. 2. 传输速度方面. JSON的速度要远远快于XML 3. 数据格式 数据格式比较简单, 易于读写, ...

  3. oracle浅析导致数据库性能问题的常见原因

    ㈠ 不合理的大表全表扫描 详见:点击打开链接 v$session_longops视图记录了超过6秒的所有SQL语句        这其中绝大部是全表扫描的语句! ㈡ 语句共享性不好 常出没在OLTP, ...

  4. 安装wamp后 异常Exception Exception in module wampmanager.exe at 000F15A0

    系统环境:Windows 2008 R2 64bit 安装环境:wampserver2.4-x64 按照正常windows安装程序,完成WAMP Server程序安装,安装完成启动WAMP Serve ...

  5. 使用Highcharts实现柱状图展示

    第一步 新建页面line.html,引入HighCharts核心js文件 <script type="text/javascript" src="../../js/ ...

  6. WebView 显示网页

    1.布局 <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:androi ...

  7. 解决ubuntu中文乱码问题

    方法一: Ubuntu默认的中文字符编码为zh_CN.UTF-8,这个可以在 /etc/environment中看到:sudo gedit /etc/environment可以看到如下内容:PATH= ...

  8. uiwebview 屏幕自适应 -- 根据 内容适应或者 webview适应

    #import <UIKit/UIKit.h> @interface ViewController : UIViewController<UIWebViewDelegate,UISe ...

  9. iOS表格制作

    由于项目上的需求,需要做一个表格出来,来显示流程状态.刚开始脑子一头雾水,没有一点思路,但是靠着自己的座右铭--“世上无难事,只怕有心人”,克服了所有困难.好,不说了,讲正事. 制作表格,还是需要ta ...

  10. [原创]css设置禁止中文换行

    white-space: nowrap;   如有需要还可以设置word-break,word-wrap配合.