2025.5.27训练课总结
这是劳资在星期一晚凌晨一点熬出来的,就不多写什么话了
T613585 25 之和
水题,是个人都会
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
ll l, r;
int t;
int main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin >> t;
l = 25 * t + 300;
cout << l;
return 0;
}T613418 对面的人
就是个if+else能解决的,但太吃大脑性能了代码如下:
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
int t, a, b, c, x, n;
int main(){
ios::sync_with_stdio(false) ,cin.tie(0),cout.tie(0);
cin >> t;
while(t--){
cin >> a >> b >> c;
x = abs(a - b);
n = x * 2;
if(a > n || b > n || c > n){
cout << -1 << endl;
continue;
}
if(c <= n / 2) cout << c + x << endl;
else if(c > n / 2) cout << c - x << endl;
}
return 0;
}T613438 n个数中选m个
深搜罢了,没写出来有点不应该啊~~~
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
int he[40], n, m, vis[50];
void dfs(int u, int pre){
if(u > m){
for(int i = 1; i <= m; i++){
cout <<he[i]<<' ';
}cout << endl;
return ;
}
for(int i = pre + 1; i <= n; i++){
if(vis[i] == 0){
vis[i] = 1;
he[u] = i;
dfs(u + 1, i);
vis[i] = 0;
}
}
}
int main(){
ios::sync_with_stdio(false) ,cin.tie(0),cout.tie(0);
cin >> n >> m;
dfs(1, 0);
return 0;
}T613493 弹珠
二分题目,有点难度,有时间的话还能拼一拼!
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
const int N = 1e6 + 5;
ll n, m, l, r;
int a[N], maxn;
bool check(int h){
ll sum = 0;
for(ll i = 1; i <= m; i++){
sum += a[i] / h;
if(a[i] % h != 0) sum++;
}
return sum <= n;
}
int main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= m; i++){
cin >> a[i];
maxn = max(maxn, a[i]);
}
ll l = 0, r = maxn + 1, mid;
while(l + 1 < r){
mid = (l + r) / 2;
if(check(mid)) r = mid;
else l = mid;
}
cout << r;
return 0;
}内容就到此结束了,感谢观看😊
###困得不行了,劳资要睡觉了!
ZZZZZZZZZZZZZZZZZZZZZZZZZ