题目链接
P14166 [Algo Beat Contest 002.5 A] 题目分配 (divide)
思路
- 输入 ,表示 组数据;
- 定义变量 和 并输入。
- 定义 。
- 如果 ,直接输出 并且退出循环。
- 定义 ,代表最小值。
- 定义 ,代表最大值。
- 如果 ,则 加一(上取整)。
- 输出 和 。
代码
#include<bits/stdc++.h>
#define int unsigned long long//long long 过不了
using namespace std;
main()
{
int T;
cin>>T;
while(T--)
{
int n,m;
cin>>n>>m;
int a=n*(n+1)/2;
if(m<a)
{
cout<<"-1 -1\n";
continue;
}
int e=n+(m-a)/n-1-(m-a)/n;
int f=m-(a-n)-1;
if((m-a)%n>0) e++;
cout<<f<<" "<<e<<endl;
}
return 0;
}本文工具使用说明
本文使用洛谷题解格式化工具检查格式。