hdu5924Mr. Frog’s Problem
Mr. Frog’s ProblemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Problem Description
One day, you, a clever boy, feel bored in your math class, and then fall asleep without your control. In your dream, you meet Mr. Frog, an elder man. He has a problem for you.
He gives you two positive integers A and B, and your task is to find all pairs of integers (C, D), such that A≤C≤B,A≤D≤B and AB+BA≤CD+DC
Input
first line contains only one integer T (T≤125),
which indicates the number of test cases. Each test case contains two integers A and B (1≤A≤B≤1018).
Output
For each test case, first output one line "Case #x:", where x is the case number (starting from 1).
Then in a new line, print an integer s indicating the number of pairs you find. In each of the following s lines, print a pair of integers C and D. pairs should be sorted by C, and then by D in ascending order.
Sample Input
2
10 10 9 27
Sample Output
Case #1:
1 10 10 Case #2: 2 9 27 27 9
Source
|
题目大意:A≤C≤B,A≤D≤B and A/B+B/A≤C/D+D/C,z找到满足关系式的c,d对数
解题思路:其实经过一些实验你会发现,如果A,B相等,那满足式子的只有一对,即c,d,与a,,b相等,如果两个数不相等,则只有两对,c=a,d=b或c=b,d=a,这样这道题就变得相当简单了
#include <iostream>
#include<stdio.h>
using namespace std;
typedef long long ll;
int main()
{
int t;
scanf("%d",&t);
ll path=1;
while(t--)
{
ll a,b;
scanf("%lld%lld",&a,&b);
if(a==b)
{
printf("Case #%lld:\n",path++);
printf("1\n");
printf("%lld %lld\n",a,b);
}
else if(a!=b)
{
printf("Case #%lld:\n",path++);
printf("2\n");
if(a<b)
{
printf("%lld %lld\n",a,b);
printf("%lld %lld\n",b,a);
}
else if(a>b)
{
printf("%lld %lld\n",b,a);
printf("%lld %lld\n",a,b);
}
}
}
return 0;
}
hdu5924Mr. Frog’s Problem的更多相关文章
- HDU 5924 Mr. Frog’s Problem 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
Mr. Frog's Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- HDU5924 Mr. Frog’s Problem
/* HDU5924 Mr. Frog’s Problem http://acm.hdu.edu.cn/showproblem.php?pid=5924 数论 * */ #include <cs ...
- 10.6 CCPC northeast
1001 Minimum's Revenge 点的编号从 1 到 n ,u v 的边权是 LCM(u,v) ,求这个图的最下生成树 搞成一颗以 1 为 根 的菊花树 ---------------- ...
- 2019省赛训练组队赛3.26周二---FJUT 2016
A.Minimum’s Revenge There is a graph of n vertices which are indexed from 1 to n. For any pair of di ...
- ACM 第七天
水题 B - Minimum’s Revenge There is a graph of n vertices which are indexed from 1 to n. For any pair ...
- CF #305 (Div. 2) C. Mike and Frog(扩展欧几里得&&当然暴力is also no problem)
C. Mike and Frog time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- 2017年上海金马五校程序设计竞赛:Problem I : Frog's Jumping (找规律)
Description There are n lotus leaves floating like a ring on the lake, which are numbered 0, 1, ..., ...
- hdu5037 Frog (贪心)
http://acm.hdu.edu.cn/showproblem.php?pid=5037 网络赛 北京 比较难的题 Frog Time Limit: 3000/1500 MS (Java/Othe ...
- HDU 5926 Mr. Frog's Game 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
Mr. Frog's Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
随机推荐
- hdu - 1627 Krypton Factor (dfs)
http://acm.hdu.edu.cn/showproblem.php?pid=1627 给定 n 和 L 找出第n个范围在0-L之内的字符串,字符串要求没有相邻的子串是相同的. 按照格式输出. ...
- Ubuntu 16.04安装RapidSVN
使用RabbitVCS有一些不完美,比如没有把文件增加到版本库的功能,导致无法提交等问题,现在再次安装RapidSVN来弥补这些缺点. 安装: sudo apt-get install rapidsv ...
- 2、Java并发性和多线程-多线程的优点
以下内容转自http://ifeve.com/benefits/: 尽管面临很多挑战,多线程有一些优点使得它一直被使用.这些优点是: 资源利用率更好 程序设计在某些情况下更简单 程序响应更快 资源利用 ...
- 基于Token的身份验证——JWT(转)
本文转自:http://www.cnblogs.com/zjutzz/p/5790180.html 感谢作者 初次了解JWT,很基础,高手勿喷.基于Token的身份验证用来替代传统的cookie+se ...
- Windows上安装Mac OS
在windows上开发ios程序,是一件比較痛苦的事情.由于: 开发android程序,使用eclipse.eclipse有windows版同一时候也有mac版,所以mac上开发android程序和w ...
- CentOS 查看日志命令
cat tail -f 日 志 文 件 说 明 /var/log/message 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一 /var/log/secure 与安 ...
- VMware实用技巧
1.VM快照管理 这个功能实在太常用,不用我多废话.这里只是提醒一下还没有用过快照的同学,赶紧的给自己的VM保存点快照吧,这样VM里的系统出了问题或是有其它需要很容易让你还原到原来的某个点,这功能可比 ...
- POJ 3260 The Fewest Coins(多重背包+全然背包)
POJ 3260 The Fewest Coins(多重背包+全然背包) http://poj.org/problem?id=3260 题意: John要去买价值为m的商品. 如今的货币系统有n种货币 ...
- 仅仅需一步教你解决Win10下Android Studio terminal无法使用的问题
Android Studio集成和加入了一些有用的工具.当中一个便是terminal. 在Windows平台下Android Studio中的terminal在原理上实际使用的是window中的cmd ...
- Use of implicitly declared global variable
https://stackoverflow.com/questions/7604419/resharper-javascript-use-of-implicitly-declared-global-v ...