T1
非常签到的一题。只要你敢交就能 A。
T2
一道简单的快写,模板。
//优化过的版本,不用写这么长
#include<iostream>
#include<cstdio>
using namespace std;
#define pc putchar_unlocked
static const char dig2[201]={
"00010203040506070809"
"10111213141516171819"
"20212223242526272829"
"30313233343536373839"
"40414243444546474849"
"50515253545556575859"
"60616263646566676869"
"70717273747576777879"
"80818283848586878889"
"90919293949596979899"
};
inline void print(int x){
if(x==0){
pc('0');
return;
}
char buf[12];
int p=0;
while(x>=100){
int r=x%100;
x/=100;
buf[p++]=dig2[r*2+1];
buf[p++]=dig2[r*2];
}
if(x>=10){
pc(dig2[x*2]);
pc(dig2[x*2+1]);
}
else
pc(x+'0');
while(p--)
pc(buf[p]);
}
int main(){
int n,m;
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin>>n>>m;
for(int i=n;i<m+n;i++){
print(i);
pc('\n');
}
return 0;
}T3
01背包问题,但是原题是P1048,题解即可。
#include <iostream>
#include <stdio.h>
using namespace std;
int w[105],val[105];
int dp[105][1005];
int main()
{
int t,m,res=-1;
scanf("%d%d",&t,&m);
for(int i=1;i<=m;i++)
{
scanf("%d%d",&w[i],&val[i]);
}
for(int i=1;i<=m;i++)
for(int j=t;j>=0;j--)
{
if(j>=w[i])
{
dp[i][j]=max(dp[i-1][j-w[i]]+val[i],dp[i-1][j]);
}
else
{
dp[i][j]=dp[i-1][j];
}
}
printf("%d",dp[m][t]);
return 0;
}
T4
有点难度。名称暗示了不能用普通快速幂,因此我们采用光速幂,也就是分段打表,适用于模数与底数确定的情况,由于本题空间限制较大,因此可以全打。
时间限制后来缩小了是为了卡掉 IO 优化的快速幂做法。
#include<iostream>
#include<cstdio>
using namespace std;
#define pc putchar_unlocked
static const char dig2[201]={
"00010203040506070809"
"10111213141516171819"
"20212223242526272829"
"30313233343536373839"
"40414243444546474849"
"50515253545556575859"
"60616263646566676869"
"70717273747576777879"
"80818283848586878889"
"90919293949596979899"
};
inline void print(int x){
if(x==0){
pc('0');
return;
}
char buf[12];
int p=0;
while(x>=100){
int r=x%100;
x/=100;
buf[p++]=dig2[r*2+1];
buf[p++]=dig2[r*2];
}
if(x>=10){
pc(dig2[x*2]);
pc(dig2[x*2+1]);
}
else
pc(x+'0');
while(p--)
pc(buf[p]);
}
int main(){
long long ans[1000000]{1};
int a,b,t;
ios::sync_with_stdio(0);
cin.tie(0);
cin>>t>>a;
for(int i=1;i<1000001;i++){
ans[i]=(ans[i-1])*a%(int(1e9+7));
}
for(int i=0;i<t;i++){
cin>>b;
print(ans[b]);
pc('\n');
}
return 0;
}T5
首先暴力是过不了后几个点的,由于异或的良好性质,所以可以找一下规律。
| 次数 | 对错 |
|---|---|
| 1 | 1100 |
| 2 | 1111 |
| 3 | 0011 |
| 4 | 1100 |
| 5 | 1111 |
发现了吗?3 次一循环。
#include<bitset>
#include<string>
#include<iostream>
using namespace std;
int main(){
string a,b;
cin>>a>>b;
bitset<10900> x(a);
bitset<10900> y(b);
bitset<10900> ans;
ans=x^y;
int t;
cin>>t;
if(t%3==0){
for(int i=0;i<a.size();i++)
cout<<ans[i];
}
else if(t%3==1)
for(int i=0;i<a.size();i++)
cout<<x[i];
else
for(int i=0;i<a.size();i++)
cout<<y[i];
return 0;
}赛后总结:
全程无大锅,赛程中 E 题题面有小的修缮。
全程仅 @LS185 一人参赛,获得幸运奖。
AK 奖:无人获得。
首杀奖:@LS185 获得 A、C 题首杀。
感谢所有抽空参加这场比赛的选手!
广告:作者即将组建的解密赛预计将在今年举行!请密切关注此文章以了解最新动态。
UPD:解密赛已完成 2 题!点此查看