杭电1017 之 A Mathematical Curiosity
来源:互联网 发布:考研数学网络课程 编辑:程序博客网 时间:2024/06/05 22:48
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
杭电上好多这种傻逼格式题,空心三角形也是,真是够了
AC代码如下:
#include <iostream>#include <cstdio>using namespace std;int n,m;bool check(int a,int b){ bool flag=false; double s=(double)(a*a+b*b+m)/(a*b); if(s==(int)s) flag=true; return flag;}int main(){ int t,coun,i=1; cin>>t; while(t--) { i=1; while(cin>>n>>m && (n||m) ) { coun=0; for(int i=1;i<n;i++) for(int j=i+1;j<n;j++) if(i<j && check(i,j)) coun++; printf("Case %d: %d\n",i++,coun); } if(t>0) cout<<endl; } return 0;}
0 0
- 杭电1017 之 A Mathematical Curiosity
- 杭电1017 A Mathematical Curiosity
- 杭电ACM 1017 A Mathematical Curiosity
- 杭电 acm 1017 A Mathematical Curiosity
- 杭电1017 A Mathematical Curiosity
- 杭电 1017 A Mathematical Curiosity
- 杭电OJ—— 1017 A Mathematical Curiosity
- 杭电acm—1017 A Mathematical Curiosity
- 杭电OJ_DIY_YTW2_1001 A Mathematical Curiosity
- 杭电ACM1017 A Mathematical Curiosity
- 1017 A Mathematical Curiosity
- 1017 A Mathematical Curiosity
- 1017 A Mathematical Curiosity
- 1017 A Mathematical Curiosity
- 1017 A Mathematical Curiosity
- 杭电1017——A Mathematical Curiosity(简单题)
- 杭电oj(Java版)——1017 A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- ubuntu 16.04 cuda 8.0 caffe 安装 及遇到的问题。
- 打造炫酷通用的ViewPager指示器
- Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
- iOS 使用AFNetworking传递复杂的POST参数(数组、键值对)
- PAT_1023 组个最小数
- 杭电1017 之 A Mathematical Curiosity
- 控制标记 flag
- 查看 KeyStore 文件详细信息命令
- 关于使用SlidingMenu时踩过的几个坑~~~
- 打造炫酷通用的ViewPager指示器
- 加密算法
- Linux 设备驱动开发 — platform设备驱动应用实例解析
- 七.Spring AOP 之增强
- 继承与组合混搭的构造和析构