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;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值