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

面对一个特殊的优化挑战,Bob需要找到一个实数α,使得f(12+α)最大化,其中f(t)=mini,j∈Z|in−jm+t|。本问题确保了解总是有理数,并提供了输入输出示例及解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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,jZ|injm+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.

  • 1n,m109
  • 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.


Source

XTU OnlineJudge


#include<stdio.h>  
  
#define ll __int64  
ll gcd(ll a,ll b)  
{  
    return a%b==0?b:gcd(b,a%b);  
}  
  
int main()  
{  
    ll a,b;  
    while(~scanf("%I64d %I64d",&a,&b))  
    {  
        printf("1/%I64d\n",2*a*b/gcd(a,b));  
    }  
    return 0;  
}  


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值