The 2018 ACM-ICPC Asia Qingdao Regional Contest A题Live Love

Live Love


Time Limit: 1 Second      Memory Limit: 65536 KB


DreamGrid is playing the music game Live Love. He has just finished a song consisting of  notes and got a result sequence  ( {PERFECT, NON-PERFECT}). The score of the song is equal to the \textit{max-combo} of the result sequence, which is defined as the maximum number of continuous PERFECTs in the sequence.

Formally speaking,  { |  is an integer and there exists an integer  () such that  PERFECT}. For completeness, we define max() = 0.

As DreamGrid is forgetful, he forgets the result sequence immediately after finishing the song. All he knows is the sequence length  and the total number of PERFECTs in the sequence, indicated by . Any possible score  he may get must satisfy that there exists a sequence  of length  containing exactly  PERFECTs and  NON-PERFECTs and . Now he needs your help to find the maximum and minimum  among all possible scores.

Input

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

The only line contains two integers  and  (, , ), indicating the sequence length and the number of PERFECTs DreamGrid gets.

Output

For each test case output one line containing two integers  and , indicating the maximum and minimum possible score.

Sample Input

5
5 4
100 50
252 52
3 0
10 10

Sample Output

4 2
50 1
52 1
0 0
10 10

Hint

Let's indicate a PERFECT as  and a NON-PERFECT as .

For the first sample test case, the sequence  leads to the maximum score and the sequence  leads to the minimum score.

题意:

有长度为n的数字串,字串中有m个完美的数,则就有n-m个不完美的数,问连续的最长的完美数串和最短的完美数串的长度为多少。。

最长的当然是m个连续一起,最短可以使不完美的数尽量均匀的插在完美序列中。。。

(~~~)简单看

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int t,n,m;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&m);
        printf("%d %d\n",m,(int)ceil(1.0*m/(n-m+1)));
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/lijunyan5/article/details/82777438