Mr. Frog’s Problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 1337    Accepted Submission(s): 765


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
  1.  
2
10 10
9 27
 

Sample Output
  1.  
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,这样这道题就变得相当简单了

  1. #include <iostream>
  2. #include<stdio.h>
  3. using namespace std;
  4. typedef long long ll;
  5. int main()
  6. {
  7. int t;
  8. scanf("%d",&t);
  9. ll path=1;
  10. while(t--)
  11. {
  12. ll a,b;
  13. scanf("%lld%lld",&a,&b);
  14. if(a==b)
  15. {
  16. printf("Case #%lld:\n",path++);
  17. printf("1\n");
  18. printf("%lld %lld\n",a,b);
  19. }
  20. else if(a!=b)
  21. {
  22. printf("Case #%lld:\n",path++);
  23. printf("2\n");
  24. if(a<b)
  25. {
  26. printf("%lld %lld\n",a,b);
  27. printf("%lld %lld\n",b,a);
  28. }
  29. else if(a>b)
  30. {
  31. printf("%lld %lld\n",b,a);
  32. printf("%lld %lld\n",a,b);
  33. }
  34. }
  35. }
  36. return 0;
  37. }

hdu5924Mr. Frog’s Problem的更多相关文章

  1. 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 ...

  2. HDU5924 Mr. Frog’s Problem

    /* HDU5924 Mr. Frog’s Problem http://acm.hdu.edu.cn/showproblem.php?pid=5924 数论 * */ #include <cs ...

  3. 10.6 CCPC northeast

    1001 Minimum's Revenge 点的编号从 1 到 n ,u  v 的边权是 LCM(u,v) ,求这个图的最下生成树 搞成一颗以 1 为 根 的菊花树 ---------------- ...

  4. 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 ...

  5. ACM 第七天

    水题 B - Minimum’s Revenge There is a graph of n vertices which are indexed from 1 to n. For any pair ...

  6. 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 ...

  7. 2017年上海金马五校程序设计竞赛:Problem I : Frog's Jumping (找规律)

    Description There are n lotus leaves floating like a ring on the lake, which are numbered 0, 1, ..., ...

  8. hdu5037 Frog (贪心)

    http://acm.hdu.edu.cn/showproblem.php?pid=5037 网络赛 北京 比较难的题 Frog Time Limit: 3000/1500 MS (Java/Othe ...

  9. 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 ...

随机推荐

  1. Python模块基础

    概念: 在Python中,一个.py文件就称之为一个模块(Module) 好处: 1. 提高可维护性 2. 可重用 3. 避免函数名.变量名冲突. 每个模块有独立的命名空间,因此相同名字的函数和变量完 ...

  2. 基于HttpClient4.5.2实现的HttpClient工具类

    1.maven依赖: <dependency> <groupId>org.apache.commons</groupId> <artifactId>co ...

  3. 斯特林(Stirling)公式 求大数阶乘的位数

    我们知道整数n的位数的计算方法为:log10(n)+1n!=10^m故n!的位数为 m = log10(n!)+1 lgN!=lg1+lg2+lg3+lg4+lg5+................. ...

  4. Search Insert Position(二分查找)

    Given a sorted array and a target value, return the index if the target is found. If not, return the ...

  5. zip4j加密压缩、解压缩文件、文件夹

    原文:http://blog.csdn.net/k21325/article/details/54376188 1.首先,引用到zip4j的第三方类库,感谢作者的无私奉献,官网打不开,这里就不贴了,下 ...

  6. CentOS firewall添加开放端口

    添加 firewall-cmd --zone=public --add-port=80/tcp --permanent (–permanent永久生效,没有此参数重启后失效) 重新载入 firewal ...

  7. android 加密手机完毕后待机两分钟出现有频率的杂音

    这个音效是code里面主动加的,是为了提醒end user输入PIN的一个提示音,也标志着加密手机动作的完毕. 详细位置是在alps\packages\apps\Settings\src\com\an ...

  8. Boss OpenCart 商城自适应主题模板 ABC-0012-01

    Boss OpenCart 商城自适应主题模板 ABC-0012-01 模板特性兼容浏览器IE7, IE8, IE9, IE10, Firefox, Safari, Chrome OpenCart版本 ...

  9. firewalld filter

    实现 firewalld  的filter 功能 1. 关闭 INPUT ,关闭OUTPUT  (设置黑名单) 任何主机 都 ping 不通 本主机 1>命令 : iptables -P INP ...

  10. Hadoop之——HBASE结合MapReduce批量导入数据

    转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46463889 废话不多说.直接上代码,你懂得 package hbase; imp ...