HDU 1017 A Mathematical Curiosity【水,坑】

A Mathematical Curiosity

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


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
分析:一道水题被我写的乱七八糟的,各种格式不对,首先m,n只要有一个为0就break,然后就是这个输出空行,输出格式输错了,GG!
下面给出AC代码:
复制代码
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int n,m;
 4 int main()
 5 {
 6     int t;
 7     scanf("%d",&t);
 8     while(t--)
 9     {
10         int k=1;
11         while(scanf("%d%d",&n,&m)&&n||m)
12         {
13             int ans=0;
14             for(int i=1;i<n;i++)
15             {
16                 for(int j=i+1;j<n;j++)
17                 {
18                     if((i*i+j*j+m)%(i*j)==0)
19                         ans++;
20                 }
21             }
22            printf("Case %d: %d\n",k++,ans);
23          }
24          if(t)
25             printf("\n");
26     }
27     return 0;
28 }
复制代码

 

posted @   Angel_Kitty  阅读(237)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示
哥伦布
14°
14:09发布
哥伦布
14:09发布
14°
大雨
南风
3级
空气质量
相对湿度
93%
今天
中雨
14°/19°
周日
中雨
5°/19°
周一
1°/11°