2018 ACM 青島區域賽區 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.
#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;
}