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 ...
随机推荐
- JQuery判断radio是否选中并获取选中值的示例代码
这篇文章主要介绍了JQuery判断radio是否选中并获取选中值的方法,代码很简单,但很实用,需要的朋友可以参考下 其他对radio操作功能,以后在添加.直接上代码,别忘记引用JQuery包 ? 1 ...
- cogs——2419. [HZOI 2016]公路修建2
2419. [HZOI 2016]公路修建2 ★☆ 输入文件:hzoi_road2.in 输出文件:hzoi_road2.out 简单对比时间限制:1 s 内存限制:128 MB [题 ...
- 洛谷 P3984 高兴的津津
P3984 高兴的津津 题目描述 津津上高中了.她在自己的妈妈的魔鬼训练下,成为了一个神犇,每次参加一次OI比赛必拿Au虐全场.每次她拿到一个Au后就很高兴.假设津津不会因为其它事高兴,并且她的高兴会 ...
- JSP的EL表达式语言
以下内容引用自http://wiki.jikexueyuan.com/project/jsp/expression-language.html: JSP表达式语言(EL)可以方便地访问存储在JavaB ...
- ASPNET Core 部署 Linux — 使用 Jexus Web Server
第一步 安装.Net Core环境 安装 dotnet 环境参见官方网站 https://www.microsoft.com/net/core. 选择对应的系统版本进行安装.安装完成过后 输入命令查看 ...
- Windows上安装Mac OS
在windows上开发ios程序,是一件比較痛苦的事情.由于: 开发android程序,使用eclipse.eclipse有windows版同一时候也有mac版,所以mac上开发android程序和w ...
- phpunit 单元测试框架-代码覆盖率
"phpize not found" 的解决办法: apt-get install php5-dev http://jeffreysambells.com/2010/04/08/r ...
- kafka-manager 的编译和使用(附安装包)
kafka-manager 的编译和使用(附安装包) 学习了:https://my.oschina.net/wangjiankui/blog/653139
- [React] Preview and edit a component live with React Live
In this lesson we'll use React Live to preview and edit a component directly in the browser. React L ...
- C#高级编程四十八天----列表
C#中的List C#中deList怎么样?List<T>类是ArrayList类的泛型等效类,该类使用大小可按需动态增长的数组实现List<T>泛型接口. 泛型的优点:它为使 ...