博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu5742——It's All In The Mind(模拟)
阅读量:2344 次
发布时间:2019-05-10

本文共 1373 字,大约阅读时间需要 4 分钟。

Problem Description

Professor Zhang has a number sequence . However, the sequence is not complete and some elements are missing. Fortunately, Professor Zhang remembers some properties of the sequence:

  1. For every , .
  2. The sequence is non-increasing, i.e. .
  3. The sum of all elements in the sequence is not zero.

Professor Zhang wants to know the maximum value of among all the possible sequences.

Input

There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case:

The first contains two integers and – the length of the sequence and the number of known elements.

In the next lines, each contains two integers and , indicating that .

Output

For each test case, output the answer as an irreducible fraction “/”, where , are integers, .

Sample Input

2
2 0
3 1
3 1

Sample Output

1/1
200/201

题意很简单,前两个数要尽可能大,后面的数要尽可能小,序列又是非递增的,最大值为200

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 0x3f3f3f3f#define MAXN 1010#define mod 1000000007using namespace std;long long gcd(long long a,long long b){ if(b==0) return a; else return gcd(b,a%b);}int a[MAXN];int main(){ int t,n,m,x,y; scanf("%d",&t); while(t--) { memset(a,-1,sizeof(a)); scanf("%d%d",&n,&m); if(m==0) { printf("1/1\n"); continue; } for(int i=0; i

转载地址:http://gicvb.baihongyu.com/

你可能感兴趣的文章
剖析Windows消息处理机制
查看>>
多线程入门教程(二)基本概念
查看>>
多线程入门教程(三)线程控制
查看>>
多线程入门教程(四)线程间通信
查看>>
多线程入门教程(五)MFC的多线程
查看>>
多线程入门教程(六)综合实例
查看>>
C/C++ 多线程学习心得
查看>>
C/C++四种退出线程的方法
查看>>
多线程编程要点
查看>>
c++CreateEvent函数在多线程中使用及实例
查看>>
c++多线程同步(1)
查看>>
Windows 下 C/C++ 多线程编程入门参考范例
查看>>
浅析stack around the variable was corrupted
查看>>
RGB与YUV转换
查看>>
YUV转RGB的相关函数
查看>>
ES(Elasticsearch)排序与相关性
查看>>
ES(Elasticsearch)分片内部原理
查看>>
Java IO(概述)
查看>>
Java IO(文件、管道、字节和字符数组)
查看>>
Java IO(流、Reader And Writer、异常处理)
查看>>