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 ...
随机推荐
- 【BZOJ4868】期末考试(整数三分)
题意: 有n位同学,每位同学都参加了全部的m门课程的期末考试,都在焦急的等待成绩的公布.第i位同学希望在第ti天 或之前得知所.有.课程的成绩.如果在第ti天,有至少一门课程的成绩没有公布,他就会等待 ...
- HDU 2222 (AC自动机)
HDU 2222 Keywords search Problem : 给若干个模式串,询问目标串中出现了多少个模式串. Solution : 复习了一下AC自动机.需要注意AC自动机中的fail,和n ...
- nyoj_308_Substring_201405091611
Substring 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 You are given a string input. You are to ...
- Query on a string
You have two strings SS and TT in all capitals. Now an efficient program is required to maintain a o ...
- JSP的会话(Session)跟踪
以下内容引用自http://wiki.jikexueyuan.com/project/jsp/session-tracking.html: 会话(Session) HTTP是一个“无状态”协议,这意味 ...
- react 项目实战(五)渲染用户列表
现在我们需要一个页面来展现数据库中记录的用户. 在/src/pages下新建UserList.js文件. 创建并导出UserList组件: import React from 'react'; cla ...
- Kafka跨集群同步工具——MirrorMaker
MirrorMaker是为解决Kafka跨集群同步.创建镜像集群而存在的.下图展示了其工作原理.该工具消费源集群消息然后将数据又一次推送到目标集群. watermark/2/text/aHR0cDov ...
- OpenLayers 3+Geoserver+PostGIS实现点击查询
WebGIS开发中,点击查询是最经常使用的一种查询方式,在ArcGIS api 中.这样的查询叫IdentifyTask,主要作用是前台提交參数.交ArcServer查询分析返回. 本文从开源框架的角 ...
- spring中编程式事务控制
step1:配置xml文件 <!-- 事务管理bean --> <bean id="transactionManager" class="org.spr ...
- mssql 中的二进制返回数据