Round 1 G
来源:互联网 发布:内存条js 编辑:程序博客网 时间:2024/05/17 23:39
题目链接:https://vjudge.net/contest/168327#problem/G
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<bits/stdc++.h>typedef long long ll;using namespace std;#define LOCALint main(){#ifdef LOCAL freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);#endif ll n,m; ll T; scanf("%lld",&T); ll kase=1; ll flag=1,f=1; string s; getline(cin,s); getline(cin,s); while(getline(cin,s)){ if(f){ if(flag) flag=0; else puts(""); } stringstream a(s); if(s==""){ f=1; // tt++; continue; }else f=0; a>>n>>m; if(n==0&&m==0){ return 0; } printf("Case %lld: ",kase++); ll cnt=0; for(ll a=1;a<n;a++){ for(ll b=a+1;b<n;b++){ if((a*a+b*b+m)%(a*b)==0){ cnt++; } } } printf("%lld\n",cnt); } return 0;}
- Round 1 G
- Round 3 G
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) G
- Educational Codeforces Round 21-G
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) G
- Codeforces Round #438 (Div. 1 + Div. 2 combined)(除G)解题报告
- 玲珑Round #4-G -- See car
- 玲珑杯round#11G题
- Educational Codeforces Round 25A-G题解
- Educational Codeforces Round 25 G. Tree Queries
- Educational Codeforces Round 32 G. Xor-MST
- 1G/2G/2.5G/3G
- round 1
- Codeforces Beta Round #38 G Queue 动态树
- Problem G B. Calendar Codeforces Round #183 (Div. 2)
- Codeforces Round #346 (Div. 2) G 递推
- “玲珑杯”ACM比赛 Round #4 G -- See car
- 玲珑杯”ACM比赛 Round #4 G -- See car【Set】
- ubuntu16.04lts突然不能联网解决方法
- HDOJ2024C语言合法标识符
- USACO-Section2.2 Preface Numbering【暴力枚举】
- Android源码博文集锦2
- modelsim与debussy联调环境的搭建
- Round 1 G
- LintCode编程题汇总(更新中)
- java学习笔记:面向对象编程之工具类的创建与单例设计模式
- php学习笔记--文件操作
- 前端面试经典题目
- 上楼梯
- [LintCode]166.链表倒数第n个节点
- 连接sqlite数据库操作C#版
- 约瑟夫环