A Live Love

#include <algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 1;

int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        int n,m;
        scanf("%d%d",&n,&m);
        if(m==0){
            printf("0 0\n");
            continue;
        }
        if(n==m){
            printf("%d %d\n",n,m);
            continue;
        }
        if(n>=2*m-1){
            printf("%d %d\n",m,1);
            continue;
        }
        for(int i=2;i<=m;i++) {
            if (n - m >= (m / i + (m % i != 0)) - 1) {
                printf("%d %d\n", m, i);
                break;
            }
        }
    }
    return 0;
}
View Code

相关文章:

  • 2018-11-13
  • 2021-11-14
  • 2021-07-24
  • 2021-09-17
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2021-10-11
猜你喜欢
  • 2022-12-23
  • 2021-04-07
  • 2022-12-23
  • 2021-08-28
  • 2021-10-18
  • 2021-12-21
相关资源
相似解决方案