https://codeforces.com/contest/2026
A:
思路:我的是算最小的边mi,两个线段从原点向X,Y轴,呈L形,再不断+1直到一边大于k
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve()
{
int x, y, k;
cin >> x >> y >> k;
if (x >= k && y >= k){
cout << 0 << " " << 0 << " " << 0 << " " << k << endl;
cout << 0 << " " << 0 << " " << k << " " << 0 << endl;
return ;
}
int mi = min(x, y), p = 1;
while (mi*mi + p*p < k*k){
p++;
}
// cout << mi*mi + p*p << endl;
cout << 0 << " " << 0 << " " << p << " " << mi << endl;
cout << 0 << " " << p << " " << mi << " " << 0 << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
赛后看榜发现只要求min(𝑋, Y)的正方形的两条对角线就可以了,因为题目一定有答案,感兴趣可以试试。
B:
思路:很典的二分题
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define endl '\n'
#define fo(i,l,r) for(int i=(l);i<=(r);++i)
const int INF = 1e18;
void solve()
{
int n;
cin >> n;
vi a(n+2);
fo(i,1,n) cin >> a[i];
a[n+1] = 4e18;
auto check = [&](int x)->bool
{
int cnt = 0;
for (int i=1; i<=n; i++){
if (a[i+1]-a[i] <=x){
i++;
continue;
}
else cnt++;
}
return cnt <= 1;
};
int l = 0, r = INF;
while (l+1<r){
int mid = (l+r)/2;
if(check(mid)){
r = mid;
}
else{
l = mid;
}
}
cout << r << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
C:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define endl '\n'
#define fo(i, l, r) for (int i = (l); i <= (r); ++i)
void solve()
{
int n, m, k;
cin >> n;
string s;
cin >> s;
s = "0" + s;
if (n == 1){
cout << 1 << endl;
return ;
}
int res = 0;
int cnt=0;
for (int i = 1; i<=n; i++){
res += i;
}
for (int i = n; i >=2; i--)
{
if (s[i] == '1' && i-1>=cnt+1){
cnt++;
res -= i;
}
if (s[i]=='0'&&cnt){
cnt--;
}
}
cout << res << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
D:
思路:数学题,推公式
E:
思路:网络流,不会的得去学一手。
正在更新...