传送门:

http://acm.hdu.edu.cn/showproblem.php?pid=1017

A Mathematical Curiosity

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 47658    Accepted Submission(s): 15285

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
 
Source
分析:
直接暴力即可
code:
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4. #define max_v 105
  5. int main()
  6. {
  7. int t;
  8. int n,m;
  9. scanf("%d",&t);
  10. while(t--)
  11. {
  12. int k=;
  13. while(~scanf("%d %d",&n,&m))
  14. {
  15. if(n==&&m==)
  16. break;
  17. int c=;
  18. //直接暴力即可
  19. for(int i=; i<n-; i++)
  20. {
  21. for(int j=i+; j<n; j++)
  22. {
  23. if((i*i+j*j+m)%(i*j)==)
  24. c++;
  25. }
  26. }
  27. printf("Case %d: %d\n",k++,c);
  28. }
  29. if(t!=)
  30. printf("\n");
  31. }
  32. return ;
  33. }

HDU 1017A Mathematical Curiosity (暴力统计特殊要求个数)的更多相关文章

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

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

  2. A Mathematical Curiosity 分类: HDU 2015-06-25 21:27 11人阅读 评论(0) 收藏

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

  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. A Mathematical Curiosity

    A Mathematical Curiosity Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/O ...

  6. 牛客小白月赛5-I-区间(差分求前缀和+一次暴力统计)

    题目描述 Apojacsleam喜欢数组. 他现在有一个n个元素的数组a,而他要对a[L]-a[R]进行M次操作: 操作一:将a[L]-a[R]内的元素都加上P 操作二:将a[L]-a[R]内的元素都 ...

  7. 数位dp——统计'1'的个数

    今天去牛客网看了看 包含一 这道题,一开始没看清,以为它要统计 1~n 所有数中数字 '1' 出现的总次数,也就是说,若 n == 11,则 ans = 4:而按照题目的原意 ans 应该为 3.看错 ...

  8. 原创:C语言打开、下载、删除网页,统计网页字符个数

    本程序由本人在华夏联盟的ID闪电笨笨原创,首发地址:http://bbs.hx95.com/ 写此程序希望可以可以激发新手学习C语言的积极性! C语言代码实现功能如下:            1.实现 ...

  9. smarty中如何统计数组的个数?

    在做web前端中,很多人会遇到在smarty中如何统计数组的个数,其实很简单 比如数组$array 你只需要用{$array|@count}就可以获取.

随机推荐

  1. 《第一行代码》Android特色开发,基于位置服务,出现的问题

    手机GPS定位较慢.精度高.耗电量多,网络定位较快.精度低.耗电量少 当位置精度要求非常高的时候,使用GPS定位:一般情况下,使用网络定位. 按<第一行代码>写了一个定位程序,真机一直没有 ...

  2. 建造者(生成器)模式C++、Java实现

    1.建造者模式UML 图1. 建造者模式UML 2.C++实现 C++实现类视图: 图2. 建造者模式C++实现的类视图 其中,Product的实现代码是(ProductA和ProductB的代码不再 ...

  3. 基于Netty的NIO优化实践

    1. 浅谈React模型 2. Netty TCP 3. Netty UTP

  4. JS十进制转二进制(控制位数)

    主要需求:十进制转二进制,可以控制指定的位数. 转化显示后的二进制数为bin-bit中输入的数字宽度.dec-number为5,bin-bit为5,则转化后数字为00101.如果bin-bit小于转化 ...

  5. mysql创建用户授权

    服务器上好多库,为了不让某用户误操作别人的数据库,给他单独建个用户并授权. insert into mysql.user(Host,User,Password, ssl_cipher, x509_is ...

  6. 《火星救援》NASA惊现lisp

    duang-跳出个界面上面一个lisp程序.

  7. jQuery无刷新上传之uploadify

    引自 文章 http://www.cnblogs.com/babycool/archive/2012/08/04/2623137.html 将文章里的代码整合在了一个解决方案里,直接可以下载测试,上代 ...

  8. MySQL数据库、表的字符编码

    用MySQL命令行新建数据库和表时默认的字符编码是latin1,但是在实际开发过程中一般都是使用utf8格式的编码.操作如下: 1.修改数据库字符编码 mysql> alter database ...

  9. nginx 两台机器 出现退款失败问题

    今天早上来公司后,测试人员告诉我 退款失败了.上周五还好好的,怎么这周三就出问题了,赶快让测试发来订单号,查询数据库,查询日志,发现还是以前的问题: search hit TOP, continuin ...

  10. SpringMVC学习(三)——基于注解配置的springMVC项目

    可运行的附件地址:http://files.cnblogs.com/files/douJiangYouTiao888/springWithAnnotation.zip 项目说明: 作者环境:maven ...