A Mathematical Curiosity

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 87   Accepted Submission(s) : 23

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

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
    #include<iostream>
using namespace std;
int main()
{
        int a,b,m,n,k,j,i,ans,num;
        cin>>k;
        for(b=0;b<k;b++)
        {    num=0;
            
            if(b)
                cout<<endl;
            while(cin>>n>>m&&m||n)
            {ans=0;
            
                for(i=1;i<n;i++)
                    for(j=i+1;j<n;j++)
                    {
                        if((i*i+j*j+m)%(i*j)==0)
                            ans++;                     }
                    cout<<"Case "<<++num<<": "<<ans<<endl;
            }
        } return 0;
}

A Mathematical Curiosity的更多相关文章

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

  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 1017A Mathematical Curiosity (暴力统计特殊要求个数)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1017 A Mathematical Curiosity Time Limit: 2000/1000 M ...

  5. HDU 1017 A Mathematical Curiosity【看懂题意+穷举法】

    //2014.10.17    01:19 //题意: //先输入一个数N,然后分块输入,每块输入每次2个数,n,m,直到n,m同一时候为零时  //结束,当a和b满足题目要求时那么这对a和b就是一组 ...

  6. HDOJ 1017 A Mathematical Curiosity

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

  7. HDOJ-1017 A Mathematical Curiosity(淼)

    http://acm.hdu.edu.cn/showproblem.php?pid=1017 # include <stdio.h> int find(int n, int m) { in ...

  8. HDU 1017 - A Mathematical Curiosity

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

  9. 杭电OJ_DIY_YTW2_1001 A Mathematical Curiosity

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

随机推荐

  1. table显示边框问题,隐藏行线,列线

    只显示上边框 <table frame=above> 只显示下边框 <table frame=below> 只显示左.右边框 <table frame=vsides> ...

  2. OC-Protocol实现业务代理

    创建一个Protocol,相当于java的接口,但,有些方法不必实现,例如以下 #import <Foundation/Foundation.h> @protocol MyProtocol ...

  3. Android开发 更改返回button的图标

    非常多的Android应用左上角都有返回button 在默认的情况下 ADT会默认给一个返回图标 而作为开发需求 非常多都要求定制一个新的图标 在Android的站点上 发现了2种能够更改的方法 1. ...

  4. jquery在元素上收购事件

    jquery的给元素绑定的事件能够用data方法取出来 通过$(element).data("events")来获取 // 比方给一个button绑定两个click事件 $(&qu ...

  5. Hasor:生命周期

    首先引用Wiki的介绍一下Hasor:     “Hasor是一款开源框架.它是为了解决企业模块化开发中复杂性而创建的.Hasor遵循简单的依赖.单一职责,在开发多模块企业项目中更加有调理.然而Has ...

  6. 使用MYCAT作为Mysql HA的中间件(转)

    记得在上一篇文章“Java集群--大型网站是怎样解决多用户高并发访问的”的结尾处本人阐述了数据库的高可用的一种方案----实现主从部署,那么今天,就让我聊聊本人关于数据库的一些所思所想吧! 下面是本人 ...

  7. ArrayList线程不安全?

    ArrayList是线程不安全的,轻量级的.如何使ArrayList线程安全? 1.继承Arraylist,然后重写或按需求编写自己的方法,这些方法要写成synchronized,在这些synchro ...

  8. NLP 苏图南 打破自我设限 突破自我—在线播放—优酷网,视频高清在线观看

    http://v.youku.com/v_show/id_XNTAyNDg3MTky.html?x

  9. 最牛B的编程套路

    最近,我大量阅读了Steve Yegge的文章.其中有一篇叫“Practicing Programming”(练习编程),写成于2005年,读后令我惊讶不已: 与你所相信的恰恰相反,单纯地每天埋头于工 ...

  10. 从Rational Rose 到IBM Rational Software Architect和IBM Rational Rhapsody

    2014/10/27 RSA升级,重装,不知怎么搞的,不能添加某些图(比如,活动图),重试了几次都不行,在其它电脑上没有问题.后来把其它电脑上的workspace复制过来,问题攻克了,原来是works ...