社区讨论
30pts!求条
P14166 [Algo Beat Contest 002.5 A] 题目分配 (divide)参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mhj31msu
- 此快照首次捕获于
- 2025/11/03 19:54 4 个月前
- 此快照最后确认于
- 2025/11/03 19:54 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
int t,n,m;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 3) + (x << 1) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
inline void write(int x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin>>t;
while(t--){
cin>>n>>m;
int s=(n+1)*n/2;
if(s>m) cout<<"-1 -1\n";
else{
int diff=m-s;
cout<<n+diff-1<<" ";
int other=diff%n;
cout<<n+other-1<<"\n";
}
}
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...