A 签到题
要输出一个\需用转义字符\
#include <iostream>
int main() {
cin>>s;
cout<<"| _ ____ _____ ________ |\n";
cout<<"| | | _ \\ / ____|_____ /|\n";
cout<<"| | | |_) | | __ / / |\n";
cout<<"| _ | | _ <| | |_ | / / |\n";
cout<<"| | |__| | |_) | |__| | / /___|\n";
cout<<"| \\____/|____/ \\_____|/________|\n";
}
B思维题
- 1、超过m米的买不到
- 2、都可以买到的情况先买便宜的再买贵的,这样买的更多。
#include"bits/stdc++.h"
using namespace std;
const int N=1e5+9;//数组大小由情况来改变
struct node{
int x,y;
};
vector<node> a;
bool cmp(node a,node b){
return a.y<b.y;
}
void slove(){
int x,n,m;
cin>>x>>n>>m;
int aa,bb;
for(int i=1;i<=n;i++){
cin>>aa>>bb;
if(aa>m)continue;//超过m米的排除
a.push_back({aa,bb});
}
sort(a.begin(),a.end(),cmp);//花费小的排前面
int ans=0;
for(auto k:a){
if(x>=k.y){ans++;x-=k.y;}
else break;
}
cout<<ans<<endl;
}
int main(){
js;
int t=1;
//cin>>t;
while(t--)slove();
}
c 博弈题
让x等于a,b中小的那一个,x=min(a,b);
- 情况一: x%3==0,x==0是chen的必败态,x无论取多少1或者2,shen都可以取相反的决策来使x%3==0,将必败态传给chen 所有shen必赢
- 情况二:x%3==1,第一种如果a==b,那么取到最后是1,1,小shen必胜,第二种a!=b,取到最后肯定是1,x(x>=2),小chen取完后,小shen无法再取,小chen获胜。
- 结论:只有当x%3==0或者(x%3==1而且a不等于b)时shen获胜 其余情况chen获胜。
long long a,b;
cin>>a>>b;
ll r=min(a,b)%3;
if(r==0)cout<<"Shen"<<endl;
else if(r==1&&a==b)cout<<"Shen"<<endl;
else cout<<"Chen"<<endl;
D签到
直接输入一个字符串,输出“元神怎么你了”即可了
E模拟
- 如果a和b的位数不同输出-1
- 其余情况模拟
string a,b;
cin>>a>>b;
int na=a.length(),nb=b.length();
if(na!=nb){cout<<-1<<endl;return;}//运算不了的情况
string ans="";
for(int i=0;i<na;i++){
int kk=(a[i]-'0')*(b[i]-'0');
if(kk>=10)ans+=kk/10+'0';
ans+=kk%10+'0';//模呀模呀模
}
cout<<ans<<endl;
D 思维题
男奇女偶
cin>>n;
int c=0,d=0;
for(int i=1;i<=n;i++)
{
cin>>x;
if(i%2==1&&x%2==0)//奇号位是女的情况
c++;
if(i%2==0&&x%2==1)//偶号位是男的情况
d++;
}
cout<<min(c,d);
全部评论
(1) 回帖