【T1T2】签到题集合

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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值