总结
T1
评测结果:
错误代码:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
constexpr int N = 1e5+5;
using namespace std;
int n,maxn=0,t[N],minn=2147483647;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1;i<=n;i++){
int x;
while(cin>>x){
maxn=max(maxn,x);
minn=min(minn,x);
t[x]++;
}
}
for(int i = minn;i<=maxn;i++){
if(t[i]!=1) cout << i << ' ';
}
return 0;
}
/*
2
5 6 8 11 9
10 12 9
*/题意分析:
正确代码:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
constexpr int N = 1e5+5;
using namespace std;
int n,maxn=0,t[N],minn=2147483647;//序列数量/最大值/桶/最小值
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;//录入
for(int i = 1;i<=n;i++){
int x;//每个序列中的每个元素
while(cin>>x){//输入序列
maxn=max(maxn,x);//得出最大值
minn=min(minn,x);//得出最小值
t[x]++;//记录至桶
}
}
for(int i = minn;i<=maxn;i++){//寻找未出现数
if(t[i]==0) {cout << i << ' ';break;}//找到了就退出循环
}
for(int i = minn;i<=maxn;i++){//寻找重复数
if(t[i]>1) {cout << i << ' ';return 0;}//找到了就结束程序
}
return 0;
}
/*
2
5 6 8 11 9
10 12 9
*/T2
评测成绩:
错误代码:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
constexpr int N = 1e5+5;
using namespace std;
int t;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> t;
while(t--){
int n;
cin >> n;
for(int i = 1;i<=n;i++){
int x;
cin >> x;
}
if(n%2==0) cout << "NO";
else cout << "YES";
cout << endl;
}
return 0;
}
题意分析:
正确代码:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
constexpr int N = 1e5+5;
using namespace std;
int t;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> t;//测试数据
while(t--){
int n;//数列长度
cin >> n;//录入
int cnt=0;//异或结果
for(int i = 1;i<=n;i++){//开始异或
int x;
cin >> x;
cnt^=x;
}
if(cnt!=0) cout << "NO";//判断并输出
else cout << "YES";
cout << endl;
}
return 0;
}
T3
评测成绩:
题意分析:
正确代码:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
constexpr int N = 1e5+5;
using namespace std;
int n;
map<int,string>tiga;//天干
map<int,string>dizh;//地支
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
tiga[0]="geng";//初始化
tiga[1]="xin";
tiga[2]="ren";
tiga[3]="gui";
tiga[4]="jia";
tiga[5]="yi";
tiga[6]="bing";
tiga[7]="ding";
tiga[8]="wu";
tiga[9]="ji";
dizh[8]="chen";
dizh[9]="si";
dizh[10]="wu";
dizh[11]="wei";
dizh[0]="shen";
dizh[1]="you";
dizh[2]="xu";
dizh[3]="hai";
dizh[4]="zi";
dizh[5]="chou";
dizh[6]="yin";
dizh[7]="mao";
cin >> n;//输入
int tg=n%10,dz=n%12;
cout << tiga[tg] << dizh[dz];//输出
return 0;
}
T4
评测成绩:
错误代码:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
constexpr int N = 1e5+5;
using namespace std;
int n;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
int m;
cin >> m;
if(m==10) cout << 10;
else cout << 8;
return 0;
}
题意分析:
正确代码:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e8+10;
int t,n,a,b,c,e,f,g;//数据数/一天的/h/六个时间
int ans1,ans2,day;//D1的时间D2的时间/一天的时间
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>t;//录入
while(t--){
ans1 = 0,ans2 = 0,day = 0;
cin >> n >> a >> b >> c >> e >> f >> g;
for(int i = 0;i<n;i++)
day+=i+1+i*(i+1)/2*10;//计算一天的时间
for(int i = 0;i<a;i++)
ans1+=i+1+i*(i+1)/2*10;//计算2天的时间
ans1+=b+b*(b-1)/2*10;
ans1+=c;
for(int i =0;i<e;i++)
ans2+=i+1+i*(i+1)/2*10;
ans2+=f+f*(f-1)/2*10;
ans2+=g;
cout << (ans2-ans1+day)%day << endl;//输出
}
return 0;
}
T5
评测成绩:
错误代码:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
constexpr int N = 1e5+5;
using namespace std;
ll W,H,w,h;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> W >> H >> w >> h;
if(H<h&&W<h) {cout <<-1;return 0;}
if(H<w&&W<w) {cout <<-1;return 0;}
if(H<h) swap(H,W);
ll cnt=0;
while(H!=h){
if(H/2<=h){
cnt+=1;
break;
}else{
cnt+=1;
H-=max(H/2,h);
}
}
while(W!=w){
if(W/2<=w){
cnt+=1;
break;
}else{
cnt+=1;
W-=max(W/2,w);
}
}
cout << cnt;
return 0;
}
题意分析:
正确代码:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
constexpr int N = 1e5+5;
using namespace std;
int calc(int W,int w,int H,int h){//对折函数
if(W<w||H<h) return 2147483647;//不能折
int cnt=0;
while(W>w){//折纸
cnt++;
W=(W+1)/2;
}
int cnt1=0;
while(H>h){//折纸
cnt1++;
H=(H+1)/2;
}
return cnt1+cnt;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
ll W,H,w,h;cin >> W >> H >> w >> h;//录入
ll c=min(calc(W,w,H,h),calc(W,h,H,w));//得出答案
if(c==2147483647) {cout << -1;return 0;}//输出
cout << c;
return 0;
}T5
评测成绩:
错误代码:
文件丢失题意分析:
正确代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
cin >> n >> k;//输入
if(k==0) cout << -1 << endl;//不符合
else {
for(int i = 1;i<=k;i++){//生成序列
cout << i%k+1 << ' ';//前k个需调换元素
}
for(int i = k+1;i<=n;i++){
cout << i << ' ';//后n-k+1个不需调换元素
}
}
return 0;
}