题目链接

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

  1. #include <cstdio>
  2. #include <iostream>
  3. #include <string>
  4. #include <cstring>
  5. #include <stack>
  6. #include <queue>
  7. #include <algorithm>
  8. #include <cmath>
  9. #include <map>
  10. using namespace std;
  11. //#define LOCAL
  12.  
  13. int main()
  14. {
  15. #ifdef LOCAL
  16. freopen("in.txt", "r", stdin);
  17. #endif // LOCAL
  18. //Start
  19. int N;
  20. cin>>N;
  21. while(N--)
  22. {
  23. int i=;
  24. int n,m;
  25. while(cin>>n>>m)
  26. {
  27. if(n==&&m==)break;
  28. i++;
  29. int ans=;
  30. for(double j=;j<n-;j++)
  31. {
  32. for(double k=j+;k<n;k++)
  33. {
  34. double t=(k*k+j*j+m)/(j*k);
  35. if((int)t==t)ans++;
  36. }
  37. }
  38. printf("Case %d: %d\n",i,ans);
  39. }
  40. if(N!=)printf("\n");
  41. }
  42. return ;
  43. }

HDU 1017 A Mathematical Curiosity(枚举)的更多相关文章

  1. HDU 1017 A Mathematical Curiosity (枚举水题)

    Problem Description Given two integers n and m, count the number of pairs of integers (a,b) such tha ...

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

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

  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

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

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

  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 oj 1017 A Mathematical Curiosity

    题目:pid=1017">点击打开链接 #include<stdio.h> int main() { int t; scanf("%d",&t) ...

  9. HDOJ 1017 A Mathematical Curiosity

    Problem Description Given two integers n and m, count the number of pairs of integers (a,b) such tha ...

随机推荐

  1. python之实现缓存环

    看了CodeBokk 第二版通过python实现缓存环,吸收之后记录下,方便以后查阅. 任务: 定义一个固定尺寸的缓存,当它填满的时候,新加入的元素会覆盖第一个(最老的)元素.这种数据结构在存储日志和 ...

  2. wpf 界面线程 添加项

    foreach (var r in sec.Records) { listView.Dispatcher.Invoke((new Action(delegate() { listView.Items. ...

  3. iOS GCD基础篇 - 同步、异步,并发、并行的理解

    1.关于GCD - GCD全称是Grand Central Dispatch  - GCD是苹果公司为多核的并行运算提出的解决方案  - GCD会自动利用更多的CPU内核(比如双核.四核)  - GC ...

  4. Ajax实现页面动态加载,添加数据

    前台代码: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Products ...

  5. 斗地主 (NOIP2015 Day1 T3)

    斗地主 张牌,因为它可以连在K后, 总体思路为 先出炸弹和四带二 再出三带一 再把对牌和单牌出完 记录并更新Answer,后枚举顺子,并继续向下搜索. 注意:弄明白题意,题目描述不太清楚....另外, ...

  6. Oracle 锁模式

    0:none  1:null 空  2:Row-S 行共享(RS):共享表锁  3:Row-X 行专用(RX):用于行的修改  4:Share 共享锁(S):阻止其他DML操作  5:S/Row-X ...

  7. 面试题-Java基础-异常部分

    1.Java中的两种异常类型是什么?他们有什么区别? Java中有两种异常:受检查的(checked)异常和不受检查的(unchecked)异常.不受检查的异常不需要在方法或者是构造函数上声明,就算方 ...

  8. C#第十天

    1.c#中的访问修饰符 public :公开的公共的 private:私有的,只能在当前类的内部访问 protected:受保护的,只能在当前类的内部以及该类的子类中访问. internal:只能在当 ...

  9. JPG 图片在IE下不能显示的问题

    最近碰到一些客户说,我传的产品图片怎么在网站上无法显示啊.图片也是正常的jpg格式呢.    是的,你传的图片是JPG的,但是怎么就显示不出来呢?    你找深圳网站建设的公司给你建了一个网站,然后在 ...

  10. selenium+python在Windows的环境搭建

    1 python下载安装 python早已安装,不再多说.因为开发使用的python2.7,所以同样使用2.7 2 打开Powershell, 输入python -m pip install sele ...