前
题目还是偏简单的 我是零零碎碎用上课时间写的
所以当时可能处理细节不太到位吧 才提交了很多遍
但其实思路都比较简单 就是部分题有坑点吧
中
A
签到题(出题人说的)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<sstream>
using namespace std;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin);
#define LL long long
#define INF 2147483647
#define eps 1e-7
void read(int &x) {
char c = getchar(); x = 0;
while(c < '0' || c > '9') c = getchar();
while(c <= '9' && c >= '0') x = x*10+c-48, c = getchar();
}
int main() {
printf("deer");
return 0;
}
B
有一个坑点没注意到 2102 这种数据
就是不一定满足在1和26之间就要 因为后面的0没处放
所以0一定要和前面那个一起
//a1 b2 c3 d4 e5 f6 g7 h8
//i9 j10 k11 l12 m13 n14 o15
//p16 q17 r18 s19 t20 u21 v22 w23 x24 y25 z26
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<sstream>
using namespace std;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin);
#define LL long long
#define INF 2147483647
#define eps 1e-7
void read(int &x) {
char c = getchar(); x = 0;
while(c < '0' || c > '9') c = getchar();
while(c <= '9' && c >= '0') x = x*10+c-48, c = getchar();
}
int len , x , top;
string s;
int main() {
// fin
cin>>s;
len = s.length();
top = 0;
while(1) {
if(top!=len-1) {
x = (s[top]-'0')*10+(s[top+1]-'0');
if(x>=1&&x<=26&&s[top+2]!='0')
top += 2;
else {
x = (s[top]-'0');
top++;
}
} else {
x = (s[top]-'0');
top++;
}
printf("%c",(char)(x+'a'-1));
if(top>=len)
break;
}
return 0;
}
C
直接统计每个方向的移动次数
然后乘每个方向对xy的操作
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<sstream>
using namespace std;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin);
#define LL long long
#define INF 2147483647
#define eps 1e-7
void read(int &x) {
char c = getchar(); x = 0;
while(c < '0' || c > '9') c = getchar();
while(c <= '9' && c >= '0') x = x*10+c-48, c = getchar();
}
LL num[130] , len , x , y;
string s;
//N 78 E 69 S 83 W 87
int main() {
// fin
cin>>s;
len = s.length();
for(int i=0; i<len; i++)
num[s[i]]++;
x -= num[87];
x += num[69];
y -= num[83];
y += num[78];
printf("%lld %lld",x,y);
return 0;
}
F
简单排序
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<sstream>
using namespace std;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin);
#define LL long long
#define INF 2147483647
#define eps 1e-7
#define L 1005
void read(int &x) {
char c = getchar(); x = 0;
while(c < '0' || c > '9') c = getchar();
while(c <= '9' && c >= '0') x = x*10+c-48, c = getchar();
}
int n , num[L] , m;
bool cmp(int a , int b) {
return a>b;
}
int main() {
// fin
read(n); read(m);
for(int i=1; i<=n; i++)
read(num[i]);
sort(num+1 , num+n+1 , cmp);
printf("%d",num[m]);
return 0;
}
H
行和列如果能除尽就去除数的最小值
原理就是稍微平移一下就可以满足条件
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<sstream>
using namespace std;
typedef long long LL;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin)
#define INF 2147483647
#define eps 1e-7
#define L 1005
#define Fo(i,a,b) for(LL i=(a),_=(b); i<=_; i++)
#define Ro(i,a,b) for(LL i=(b),_=(a); i>=_; i--)
inline LL read() {
LL x=0,f=1;char c=getchar();
while(!isdigit(c)) {
if(c=='-')f=-f;c=getchar();}
while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48ll),c=getchar();
return x*f;
}
int n , m , ans;
int main() {
// fin;
n=read();m=read();
Fo(i,2,n)
if(n%i==0) {
ans = i;
break;
}
Fo(i,2,m)
if(m%i==0) {
int x=i;
ans=min(ans,x);
break;
}
printf("%d",ans);
return 0;
}
I
暴力就可以过啊
宏定义写的有点难看……
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<sstream>
using namespace std;
typedef long long LL;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin);
#define INF 2147483647
#define eps 1e-7
#define L 1005
#define Fo(i,a,b) for(LL i=(a),_=b; i<=_; i++)
#define Ro(i,a,b) for(LL i=(b),_=(a); i>=_; i--)
#define _min minn = INF
#define _maxx maxx = -1
#define umin(_,__) _ = min(_ , __)
#define umax(_,__) _ = max(_ , __)
#define pr(_) printf("%d",_)
inline LL read() {
LL x=0,f=1;char c=getchar();
while(!isdigit(c)) {
if(c=='-')f=-f;c=getchar();}
while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48ll),c=getchar();
return x*f;
}
int n , minn = INF , ans , maxx = -1 , num[L];
int main() {
// fin
n=read();
Fo(i,1,n) num[i]=read();
Fo(i,1,n) {
_min;
Fo(j,1,i)
umin(minn,num[j]);
umax(ans,num[i]-minn);
}
pr(ans);
return 0;
}
J
用STL里string的操作模拟就行
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<sstream>
using namespace std;
typedef long long LL;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin)
#define INF 2147483647
#define eps 1e-7
#define L 1005
#define Fo(i,a,b) for(LL i=(a),_=(b); i<=_; i++)
#define Ro(i,a,b) for(LL i=(b),_=(a); i>=_; i--)
inline LL read() {
LL x=0,f=1;char c=getchar();
while(!isdigit(c)) {
if(c=='-')f=-f;c=getchar();}
while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48ll),c=getchar();
return x*f;
}
queue<LL>z;
queue<LL>a;
LL tim;
string s;
int main() {
// fin;
s="";
Fo(i,1,52) {
int x=read();
if(i%2!=0)
z.push(x);
else
a.push(x);
}
while(1) {
LL op , v;
tim++;
v=z.front();
z.pop();
op=(LL)s.find(v+'0');
if(op==-1)
s+=(v+'0');
else {
string del=s.substr(op,s.size()-op);
s.erase(op,s.size()-op);
int len=del.size();
Fo(i,0,len-1) {
int x=del[i]-'0';
z.push(x);
}
z.push(v);
}
v=a.front();
a.pop();
op=(LL)s.find(v+'0');
if(op==-1)
s+=(v+'0');
else {
string del=s.substr(op,s.size()-op);
s.erase(op,s.size()-op);
int len=del.size();
Fo(i,0,len-1) {
int x=del[i]-'0';
a.push(x);
}
a.push(v);
}
if(a.size()==0) {
printf("zcl");
return 0;
}
if(z.size()==0) {
printf("ajh");
return 0;
}
if(tim==1000) {
if(z.size()>a.size())
printf("zcl");
if(z.size()<a.size())
printf("ajh");
if(z.size()==a.size())
printf("no winner");
}
}
return 0;
}
K
注意!“唯一持有”!
读题啊!
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<sstream>
using namespace std;
typedef long long LL;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin)
#define INF 2147483647
#define eps 1e-7
#define L 1005
#define Fo(i,a,b) for(LL i=(a),_=(b); i<=_; i++)
#define Ro(i,b,a) for(LL i=(b),_=(a); i>=_; i--)
inline LL read() {
LL x=0,f=1;char c=getchar();
while(!isdigit(c)) {
if(c=='-')f=-f;c=getchar();}
while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48ll),c=getchar();
return x*f;
}
int n , m , k , v[200005] , minn=INF;
int main() {
// fin;
n=read(); m=read(); k=read();
if(m>=k) {
printf("Yes");
return 0;
}
Fo(i,1,n) {
v[i]=read();
minn=min(minn,v[i]);
}
if(m<minn) {
printf("No");
return 0;
}
Fo(i,1,n)
if(v[i]<v[i+1]&&v[i]<=m)
m+=v[i+1]-v[i];
if(m>=k)
printf("Yes");
else
printf("No");
return 0;
}
L
其实没必要这么麻烦 完全可以按照坐标去做
但是暴力还是可以出来的
坑点就是 答案不一定在-100到100之间
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<sstream>
using namespace std;
typedef long long LL;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin)
#define INF 2147483647
#define eps 1e-7
#define L 1005
#define Fo(i,a,b) for(LL i=(a),_=(b); i<=_; i++)
#define Ro(i,a,b) for(LL i=(b),_=(a); i>=_; i--)
inline LL read() {
LL x=0,f=1;char c=getchar();
while(!isdigit(c)) {
if(c=='-')f=-f;c=getchar();}
while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48ll),c=getchar();
return x*f;
}
struct Node {
int x , y;
bool operator != (Node a) {
return a.x!=x||a.y!=y;
}
};
Node n1 , n2 , n3;
int len1 , len2 , len3 , flag;
int len(Node a , Node b) {
return pow(abs(a.x-b.x),2)+pow(abs(a.y-b.y),2);
}
void sol() {
if(len1>len2&&len1>len3)
flag = 3;
if(len2>len1&&len2>len3)
flag = 2;
if(len3>len1&&len3>len2)
flag = 1;
}
int main() {
// fin;
n1.x=read(); n1.y=read();
n2.x=read(); n2.y=read();
n3.x=read(); n3.y=read();
len1=len(n1,n2); len2=len(n1,n3); len3=len(n2,n3);
sol();
if(flag==1) {
Fo(i,-200,200)
Fo(j,-200,200) {
Node x;
x.x=i; x.y=j;
if(len(x,n2)==len(x,n3)&&len(x,n2)==len2&&x!=n1) {
printf("%d %d",i,j);
return 0;
}
}
}
if(flag==2) {
Fo(i,-200,200)
Fo(j,-200,200) {
Node x;
x.x=i; x.y=j;
if(len(x,n1)==len(x,n3)&&len(x,n1)==len1&&x!=n2) {
printf("%d %d",i,j);
return 0;
}
}
}
if(flag==3) {
Fo(i,-200,200)
Fo(j,-200,200) {
Node x;
x.x=i; x.y=j;
if(len(x,n2)==len(x,n1)&&len(x,n2)==len3&&x!=n3) {
printf("%d %d",i,j);
return 0;
}
}
}
return 0;
}
M
一个细节:答案一定不大于26
比较容易看出来吧
就是如果s和c中都存在的话 这个字母就算一个
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<sstream>
using namespace std;
typedef long long LL;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin)
#define INF 2147483647
#define eps 1e-7
#define L 1005
#define Fo(i,a,b) for(LL i=(a),_=(b); i<=_; i++)
#define Ro(i,b,a) for(LL i=(b),_=(a); i>=_; i--)
inline LL read() {
LL x=0,f=1;char c=getchar();
while(!isdigit(c)) {
if(c=='-')f=-f;c=getchar();}
while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48ll),c=getchar();
return x*f;
}
int n , m , t[30] , ans , x[30];
string s , c;
int main() {
// fin;
n=read(); m=read();
cin>>s>>c;
Fo(i,0,n-1)
t[s[i]-'a'] = 1;
Fo(i,0,m-1)
x[c[i]-'a'] = 1;
for(int i=0; i<26; i++)
if(x[i]&&t[i])
ans++;
printf("%d",ans);
return 0;
}
后
题目比较不错 真 新生赛
细节也很好哈哈哈 虽然我有些题写的超级麻烦吧
就这样吧 还好补完了会的题
剩下的待补 溜了溜了