标签:中文翻译 space bit amp keyword 直接 nbsp 最小 else
b题:b其实不难题意就是不让k个连续字符成为一个周期。这提给我的教训就是中文翻译应该结合英文题目一起看,
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
using namespace std;
const ll nl=1e5+5;
#define speed_up ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
speed_up;
ll n,p;
cin>>n;
cin>>p;
ll i;
string m;
cin>>m;
ll num=0;
for(i=0;i<n-p;i++){
if(m[i]!=m[i+p]||(m[i]==‘.‘&&m[i+p]==‘.‘)){
num=1;
}
if(num==1){
if(m[i]!=m[i+p]&&m[i]!=‘.‘&&m[i+p]!=‘.‘){
break;
}
if(m[i]==‘.‘&&m[i+p]==‘.‘){
m[i]=‘0‘;
m[i+p]=‘1‘;
break;
}
if(m[i]==‘.‘&&m[i+p]!=‘.‘){
if(m[i+p]==‘1‘){
m[i]=‘0‘;
}else if(m[i+p]==‘0‘){
m[i]=‘1‘;
}
break;
}
if(m[i+p]==‘.‘&&m[i]!=‘.‘){
if(m[i]==‘1‘){
m[i+p]=‘0‘;
}else if(m[i]==‘0‘){
m[i+p]=‘1‘;
}
break;
}
}
}
if(num==0){
cout<<"No"<<endl;
}else{
for(i=0;i<n;i++){
if(m[i]==‘.‘){
m[i]=‘0‘;
}
cout<<m[i];
}
}
cout<<endl;
}
e题用到了数学知识,log一下简减少数字大小接即可。
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
using namespace std;
const ll nl=1e5+5;
#define speed_up ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
speed_up;
ll x,y;
cin>>x;
cin>>y;
if(x*log(y)>y*log(x)){
cout<<"<"<<endl;
}else if(x*log(y)<y*log(x)){
cout<<">"<<endl;
}else{
cout<<"="<<endl;
}
}
f题:按顺序找到满足si<sj<sk,计算最小花费,直接硬做会超时,要用到dp;
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=3005;
int main(){
int n;
int ans=INF;
int val[maxn],cost[maxn],f[maxn][4];
cin>>n;
for(int i=0;i<n;i++)
cin>>val[i];
for(int i=0;i<n;i++)
cin>>cost[i];
memset(f,INF,sizeof(f));
for (int i=0;i<n;i++)
{
f[i][0]=cost[i];
for (int j=0;j<i;j++)
if (val[j]<val[i])
f[i][1]=min(f[i][1],f[j][0]+cost[i]);
for (int j=0;j<i;j++)
if (val[j]<val[i])
f[i][2]=min(f[i][2],f[j][1]+cost[i]);
}
for(int i=0;i<n;i++)
ans=min(ans,f[i][2]);
if(ans!=INF)
cout<<ans<<endl;
else
cout<<-1<<endl;
}
2020.10.9个人赛补题
标签:中文翻译 space bit amp keyword 直接 nbsp 最小 else
原文地址:https://www.cnblogs.com/yyscn/p/13836658.html