1题面
1题解
没啥好说的直接求,注意坑点是房子涨价滞后于蒜头君攒钱,感觉这是常识性问题。
1代码
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define mem(a,s) memset(a,s,sizeof(a))
typedef long long LL;
double sum = 0, s=200,N, K;
int main(){
// freopen("in.txt","r",stdin);
cin >> N >> K;
int ans=0;
K /= (double)100;
K += 1;
while(++ans<=20){
sum+=N;
if(sum>s)
break;
s *= K;
}
if(ans>20)
cout << "Impossible\n";
else
cout << ans << endl;
return 0;
}
2题面
样例输入
4
0 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
样例输出
1
Sponsor
2题解
直接求出旋转规律:每顺时针旋转90度,i->j,j->n+1-i,由此可以得出,旋转180,270度的公式
2代码
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define mem(a,s) memset(a,s,sizeof(a))
typedef long long LL;
const int N=21;
const int M=21;
int a[N][N];
int b[M][M];
int n;
int main(){
// freopen("in.txt","r",stdin);
cin>>n;
rep(i,1,n)
rep(j,1,n)
cin>>a[i][j];
rep(i,1,n)
rep(j,1,n)
cin>>b[i][j];
int ans = 0;
rep(k,0,3){
rep(i,1,n){
rep(j,1,n){
int ii, jj;
if (k == 0)
ii = i, jj = j;
if(k==1)
ii = j, jj = n + 1 - i;
if(k==2)
ii=n+1-i,jj=n+1-j;
if(k==3)
ii = n + 1 - j, jj = i;
if(a[i][j]!=b[ii][jj]){
ans = k + 1;
break;
}
}
if(ans>k)
break;
}
if(ans==k)
break;
}
cout << (ans < 4 ? ans : -1);
return 0;
}
3题面
3思路
直接转码即可。
3代码
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define mem(a,s) memset(a,s,sizeof(a))
typedef long long LL;
int main(){
// freopen("in.txt","r",stdin);
char c;
while((c=getchar())!=EOF){
if(c<'A'||c>'Z')
cout << c;
else
cout << (char((c - 'A' +21) % 26 + 'A'));
}
return 0;
}
4题面
Examples
Input
7
2 2 2 1 1 2 2
Output
4
Input
6
1 2 1 2 1 2
Output
2
Input
9
2 2 1 1 1 2 2 2 2
Output
6
4题解
正解只能是1…1,2…2或2…2,1…1,则可以直接模拟,求解相邻的两端1和2的长度,取最小值更新最大答案。
4代码
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define mem(a,s) memset(a,s,sizeof(a))
typedef long long LL;
const int N = 1e5 + 10;
int a[2];
int l[2];
int n;
int main(){
// freopen("in.txt","r",stdin);
cin.sync_with_stdio();
cin>>n;
int sum = 0;
rep(i, 1, n){
cin >> a[i%2];
if(i==1||a[i%2]==a[(i+1)%2])
l[a[i%2]-1]++;
else{
sum = max(sum, min(l[0], l[1]));
l[a[i%2]-1] = 1;
}
}
sum = max(sum, min(l[0], l[1]));
cout << sum*2;
return 0;
}