题目链接:传送门

Strange Optimization

Bobo is facing a strange optimization problem. Given  n,m , he is going to find a real number  α  such that  f(12+α)  is maximized, where  f(t)=mini,j∈Z|in−jm+t| . Help him!

Note: It can be proved that the result is always rational.

Input

The input contains zero or more test cases and is terminated by end-of-file.

Each test case contains two integers  n,m .

  • 1≤n,m≤109
  • The number of tests cases does not exceed  104 .

Output

For each case, output a fraction  p/q  which denotes the result.

Sample Input

1 1
1 2

Sample Output

1/2
1/4

Note

For the first sample,  α=0  maximizes the function.

解题思路:f(t) = 1/Icm(n,m)*2

|i/n-j/m|所能表示的最小值为1/Icm(n,m),令其为p,当t>=p,f(t)=0。当t<p,只有t=p/2时,f(t)才能取到最大值p/2。

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
using namespace std;
typedef  __int64 ll;
const int N = 100100;
const int M = 20;
const int INF = 0x3fffffff;int gcd( int a , int b )
{if( b == 0 ) return a;else return gcd( b , a%b );
}int main()
{ll n,m;while( ~scanf("%I64d%I64d",&n,&m) ){ll p = n/gcd(n,m)*m*2;printf("%d/%I64d\n",1,p);}return 0;
}

2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛:I— Strange Optimization相关推荐

  1. 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛 Highway

    Highway Accepted : 122   Submit : 393 Time Limit : 4000 MS   Memory Limit : 65536 KB Highway In ICPC ...

  2. 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛 Partial Sum

    Partial Sum Accepted : 124   Submit : 450 Time Limit : 3000 MS   Memory Limit : 65536 KB  Partial Su ...

  3. 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛 Strange Optimization

    Strange Optimization Accepted : 89   Submit : 350 Time Limit : 1000 MS   Memory Limit : 65536 KB  St ...

  4. 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛:H—Highway

    题目链接:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1267 Highway In ICPCCamp there wer ...

  5. 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛:E—Partial Sum

    题目链接:传送门 Partial Sum Bobo has a integer sequence  a1,a2,-,an  of length  n . Each time, he selects t ...

  6. XTU 1264 Partial Sum 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛(湖南)

    Partial Sum   Accepted : 87   Submit : 366 Time Limit : 3000 MS   Memory Limit : 65536 KB Partial Su ...

  7. xtu 1268 Strange Optimization 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛(湖南)

    Strange Optimization Bobo is facing a strange optimization problem. Given  n,m , he is going to find ...

  8. XTU 1268 Strange Optimization 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛(湖南)

    Strange Optimization   Accepted : 65   Submit : 286 Time Limit : 1000 MS   Memory Limit : 65536 KB S ...

  9. 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛(湖南) 暨 第九届湘潭市大学生程序设计比赛H.Highway(树的直径)

    Highway Accepted : 122   Submit : 393 Time Limit : 4000 MS   Memory Limit : 65536 KB Highway In ICPC ...

最新文章

  1. ROS学习笔记—-- catkin
  2. Android镜像文件的拆解
  3. 【BLE】TI CC2640R2F片内OAD实验
  4. 5、Power Map—实例:填充地图
  5. linux是数据库软件么,什么是适用于Linux的良好数据库ERD工具?
  6. java axmlprinter_安卓xml配置文件解析工具-AXMLPrinter2.jar(androidmanifest.xml 反编译)下载官方最新版-西西软件下载...
  7. Permissions for id_rsa are too open
  8. rlwrap解决sqlplus上下键和backspace键找历史命令
  9. 一个简单的mysql服务检测启动脚本
  10. OpenDrive学习笔记
  11. paint.net ps证件照背景色
  12. 在线头像制作网站FaceYourManga
  13. 雷霆战机服务器维护公告,雷霆战机停服公告 4月11日服务器维护
  14. python缺失值处理 fillna_python 处理缺失值
  15. maven的jar包引入成功却仍然爆红
  16. 数据库查询时报错com.mysql.jdbc.exceptions.jdbc4.MySQLDataException: ‘1.7725000000E10‘ in column ‘17‘ is outs
  17. 浅谈MySQL中优化sql语句查询常用的30种方法
  18. goto在golang中的用法
  19. 天才如周杰伦与周星驰也难逃孤独
  20. 狼人杀个人理解玩法之(守卫)

热门文章

  1. find中的德摩根定律和条件权限perm
  2. 小程序代理商是如何赚钱的?
  3. forward 和 redirect 的区别
  4. 物联网LoRa系列-1:物联网系统分层架构
  5. Tomcat 的session管理
  6. 女孩子会因为什么喜欢一个男孩子?
  7. word2007怎么从第三页开始设置页码
  8. 五级数据挖掘工程师,你处在哪一级?
  9. [附源码]计算机毕业设计springboot家庭教育app
  10. java ftpclient 池_FTPClient,连接池实现