C - 3

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

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<stdio.h>
#include<string.h>
#include<math.h> #define N 110 int main()
{
int i, j, t, n, m, f = 0; scanf("%d", &t); while(t--)
{
int k = 1; if(f == 1)
printf("\n"); while(scanf("%d%d", &n, &m), n+m)
{
int ans=0; for(i = 1; i < n; i++)
{
for(j = 1; j < n; j++)
{
if((i*i+j*j+m) % (i*j) == 0 && (i < j))
ans++;
} }
printf("Case %d: %d\n", k++,ans);
} f = 1;
}
return 0;
}

HDU 1017 直接暴力。的更多相关文章

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

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

  2. HDU 1017 - A Mathematical Curiosity

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

  3. HDU 1017 A Mathematical Curiosity(枚举)

    题目链接 Problem Description Given two integers n and m, count the number of pairs of integers (a,b) suc ...

  4. HDU 1017(** **)

    题意是给定 n,m,问有多少组(a,b)满足 0 < a < b < n 而且 (a ^ 2 + b ^ 2 + m) / ( a * b ) 是整数. 直接模拟即可. 代码如下: ...

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

  6. HDU 1017 A Mathematical Curiosity (数学)

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

  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 1017 A Mathematical Curiosity (枚举水题)

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

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

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

随机推荐

  1. Android栈溢出漏洞利用练习

    在Github上看到一个Linux系统上的栈溢出漏洞利用练习项目: easy-linux-pwn.在原项目基础上,我稍微做了一些改动,将这个项目移植到了Android 9.0系统上: easy-and ...

  2. stars-one原创工具——蓝奏云批量下载工具

    一款可以批量下载蓝奏云分享的文件夹下的所有文件 基于HtmlUnit和okhttp开源库,所以打包后的jar包文件有点大 蓝奏云下载地址 github地址 需求 之前找电子书资源的时候,网友分享的蓝奏 ...

  3. spring boot+spring security 使用随笔

    本人最近接受的新任务是从零搭一个管理系统的权限管理模块,从零开始学习了spring security,已完成绝大部分设计和开发,和大家分享一些学习和开发心得. 首先是数据库的设计,这里是 按照产品的需 ...

  4. 网站 cache control 最佳实践

    推荐阅读: 2020年软件开发趋势 高并发案例 - 库存超发问题 负载均衡的分类及算法 异地多活架构 Postman 的替代品来了 有时,当第二次访问网站时,看起来比较怪,样式不正常. 通常,是因为 ...

  5. IDEA中springboot的热部署

    在pom.xml文件中添加依赖 <!--添加热部署--> <dependency> <groupId>org.springframework.boot</gr ...

  6. 【Flink】Flink作业调度流程分析

    1. 概述 当向Flink集群提交用户作业时,从用户角度看,只需要作业处理逻辑正确,输出正确的结果即可:而不用关心作业何时被调度的,作业申请的资源又是如何被分配的以及作业何时会结束:但是了解作业在运行 ...

  7. python 安装虚拟环境virtualenv

    1.sudo apt install virtualenv 安装失败 2.sudo apt-get update 更新失败 提示: E: 仓库 “http://mirrors.aliyun.com/u ...

  8. Nito.AsyncEx 这个库

    有一个非常聪明的小伙子 (我高度赞扬) 叫 Stephen Cleary ,他写了一个很棒的 Extension 集,共同参与开发的还有 Stephen Toub (他显然是经验丰富的),所以我充分信 ...

  9. 解决 C# GetPixel 和 SetPixel 效率问题(转)

    在对Bitmap图片操作的时候,有时需要用到获取或设置像素颜色方法:GetPixel 和 SetPixel, 如果直接对这两个方法进行操作的话速度很慢,这里我们可以通过把数据提取出来操作,然后操作完在 ...

  10. springIOC源码接口分析(二):ConfigurableBeanFactory

    一 继承功能 1 SingletonBeanRegistry接口 此接口是针对Spring中的单例Bean设计的.提供了统一访问单例Bean的功能,类中定义了以下方法: 2 HierarchicalB ...