今天只写了一题签到。。
我补!
H题
CodeForces - 750C(思维)_codeforces查看等级分-CSDN博客
这题不难的呀 就是一开始想错方向了就会一直困在那里,我经常这样 就是一个方法错了不太有勇气去想一个新方法, 只是固执的认为自己有点小错误,继续细化这个代码 后来代码就会
变得很长。。而且很有可能自己都看不懂了。。下次尝试开新路。
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
const int inf=0x3f3f3f3f;
int c,d;
int d1=-inf,d2=inf;
int main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int t,n,sum=0,x=2e7+10;
cin>>t;
n=t;
for(int i=1;i<=n;i++)
{
cin>>c>>d;
if(d==1)
{
d1=max(d1,1900-sum);
}
else if(d==2)
{
d2=min(d2,1899-sum);
}
sum+=c;
}
if(d1>d2)
cout<<"Impossible"<<endl;
else if(d2==inf)
cout<<"Infinity"<<endl;
else
cout<<d2+sum<<endl;
return 0;
}
D题
我这么一看才发现自己当时题目理解错掉了。。
Sum of Two Numbers (CodeForces - 1788B )-CSDN博客
把数字看成字符串。
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
cin>>n;
while(n--)
{
string a;
cin>>a;
int sum=0;
for(auto i:a){
sum+=i-'0';
}
int mid=sum/2;
string minstr;
for(int i=a.length()-1;i>=0;i--){
if(mid>a[i]-'0'){
mid-=a[i]-'0';
minstr+=a[i];
a[i]='0';
}else{
minstr+=mid+'0';
a[i]-=mid;
mid-=mid;
}
if(mid==0){
break;
}
}
reverse(minstr.begin(),minstr.end());
cout<<a<<" "<<minstr<<endl;
}
return 0;
}
其他的打标签
A题
dfs序 没听说过 有空看看 LCA
CodeForces - 1328 E. Tree Queries 最近公共祖先lca_1328e - tree queries-CSDN博客
codeforces 1328E Tree Queries 思维 dfs序 LCA_codeforces1328e-CSDN博客
E题
线段树 区间异或+区间和
Codeforces 242E-XOR on Segment (线段树 + 区间异或修改、求和)_线段树区间异或-CSDN博客
怎么又是线段树!
线段树 从入门到进阶(超清晰,简单易懂)_进阶线段树-CSDN博客
F题
DP 可以看看
Codeforces1221 D. Make The Fence Great Again(DP)_p - make the fence great again(dp)-CSDN博客