HDU 1017 A Mathematical Curiosity 水题 格式控制
来源:互联网 发布:找不到网络打印机 编辑:程序博客网 时间:2024/05/29 17:10
A Mathematical Curiosity
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 38898 Accepted Submission(s): 12464
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.
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
110 120 330 40 0
Sample Output
Case 1: 2Case 2: 4Case 3: 5
Source
East Central North America 1999, Practice
Recommend
JGShining | We have carefully selected several similar problems for you: 1018 1021 1004 1019 1020
题意很明确,就是求出来 0 < a < b < n and (a^2+b^2 +m)/(ab) is an intege
求出来a,b的个数。
题目很水,就是输出格式得控制一下,每两个n之间价格空格!!!
ac代码:
#include <stdio.h>int main(){int n,a,b,i,j;int cnt,num;scanf("%d",&n);while(n--){num=0;while(scanf("%d%d",&a,&b),a||b){cnt=0;for(i=1;i<a;i++){//printf("******\n");for(j=i+1;j<a;j++){//printf("#########\n");if(((i*i+j*j+b)%(i*j))==0){cnt++;}}}++num;printf("Case %d: %d\n",num,cnt);}if(n)printf("\n");} return 0;}
1 0
- HDU 1017 A Mathematical Curiosity 水题 格式控制
- hdu 1017 A Mathematical Curiosity【枚举+格式】
- hdu 1017 A Mathematical Curiosity(水题)
- hdu 1017 A Mathematical Curiosity(数学:水题)
- HDU ACM 1017 A Mathematical Curiosity 水题
- HDU 1017 A Mathematical Curiosity【水题】
- HDU 1017 A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- HDU 1017A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- HDU--1017--A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- HDU:1017 A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- linux中怎么从root用户切换到普通用户
- 小应用 请求网络和解析数据
- php---mysql
- 类和类之间的关系
- Banner轮放
- HDU 1017 A Mathematical Curiosity 水题 格式控制
- SSM整合教程Spring+SpringMVC+MyBatis :
- 利用顶点着色插件做地形及红旗飘动
- JAVA-猜数题
- C#三态及可禁用TreeView树形视图实现
- Android 5.0(Lollipop)中的SurfaceTexture,TextureView, SurfaceView和GLSurfaceView
- struts标签中select标签的参数传递分析
- 基于STM32的OLED与TFTLCD详解1(IC驱动及FSMC初探)
- Java HashMap学习笔记(持续更新)