当前位置:   article > 正文

蓝桥杯2022 第一次官方模拟赛 1-9 个人代码

蓝桥杯2022 第一次官方模拟赛 1-9 个人代码

参加过一次正赛,这是第一次参加所谓的模拟赛,免费的参加着玩玩。
难度比正赛简单很多很多。
做了1-4,5-9。代码如下。
第五题是最基础的二维前缀和题,这比赛写两三个小时写到最后头晕,就没写,交卷了。
其它的没对过答案,但我感觉是没有问题的。

2

138

m = [31,28,31,30,31,30,31,31,30,31,30,31]

a = 6
ans = 0
for i in range(12):
    for j in range(1,m[i]+1):
        if j == 1 or j == 11 or j == 21 or j == 31 or a%7 == 0 or a%7==6:
            ans += 1
        a+=1
print(ans)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

3

91381

#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
    double s = 0;
    int n=1;
    while(s<12){
        s += (1.0/n);
        n++;
    }
    cout<<n;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

4

276

s = '''PHQGHUMEAYLNLFDXFIRCVSCXGGBWKFNQDUXWFNFOZVSRTKJPREPGGXRPNRVY
STMWCYSYYCQPEVIKEFFMZNIMKKASVWSRENZKYCXFXTLSGYPSFADPOOEFXZBC
OEJUVPVABOYGPOEYLFPBNPLJVRVIPYAMYEHWQNQRQPMXUJJLOOVAOWUXWHMS
NCBXCOKSFZKVATXDKNLYJYHFIXJSWNKKUFNUXXZRZBMNMGQOOKETLYHNKOAU
GZQRCDDIUTEIOJWAYYZPVSCMPSAJLFVGUBFAAOVLZYLNTRKDCPWSRTESJWHD
IZCOBZCNFWLQIJTVDWVXHRCBLDVGYLWGBUSBMBORXTLHCSMPXOHGMGNKEUFD
XOTOGBGXPEYANFETCUKEPZSHKLJUGGGEKJDQZJENPEVQGXIEPJSRDZJAZUJL
LCHHBFQMKIMWZOBIWYBXDUUNFSKSRSRTEKMQDCYZJEEUHMSRQCOZIJIPFION
EEDDPSZRNAVY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AMHURKTRFFACLVGRZKKLDACLLTEO
JOMONXRQYJZGINRNNZWACXXAEDRWUDXZRFUSEWJTBOXVYNFHKSTCENAUMNDD
XFDMVZCAUTDCCKXAAYDZSXTTOBBGQNGVVPJGOJOGLMKXGBFCPYPCKQCHBDDZ
WRXBZMQRLXVOBTWHXGINFGFRCCLMZNMJUGWWBSQFCIHUBSJOLLMSQSGHMCPH
ELSOTFLBGSFNPCUZSRUPCHYNVZHCPQUGRIWNIQXDFJPWPXFBLKPNPEELFJMT
'''
a = s.split()
cnt = 0
for i in range(1,len(a)-1):
    for j in range(1,len(a[i])-1):
        if a[i][j] < a[i-1][j] and a[i][j] < a[i+1][j] and a[i][j] < a[i][j-1] and a[i][j] < a[i][j+1]:
            cnt+=1
print(cnt)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

5

6

#include <bits/stdc++.h>

using namespace std;

int a,b;

int main(){

    cin>>a>>b;

    cout<<a-b-1;

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

7

#include <bits/stdc++.h>

using namespace std;

string s;

int main(){

    cin>>s;

    for(int i=0;i<s.length();i++){

        if(s[i]=='a' || s[i]=='e' ||s[i]=='i' ||s[i]=='o' ||s[i]=='u'){

            s[i]+='A'-'a';

        }

    }

    cout<<s;

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

8

#include <bits/stdc++.h>
using namespace std;
int n;

int s[100];
int pretime,prea,preb;


int main(){
    cin>>n;
    char c = getchar();
    long long ans=0;
    for(int i=0;i<n;i++){
        int k=0;
        char c;
        while((c = getchar()) != '\n'){
            if(c==' ' || c==':')s[k]=-1;
            else s[k] =  int(c - '0');
            k++;
            
        }

        int a = s[9];
        for(int j=10;s[j]!=-1;j++){
            a = a*10 + s[j];
        }
        int b = s[k-1],d=1;
        for(int j=k-2;s[j]!=-1;j--){
            b += s[j]*pow(10,d);
            d++;
        }
        
        int time = (s[0]*10+s[1])*60*60 + (s[3]*10+s[4])*60 + (s[6]*10+s[7]);

        if(i!=0){
            ans+=(time-pretime)*prea*preb;
        }
        pretime = time;
        prea = a;
        preb = b;
    }
    cout<<ans;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43

9

#include <bits/stdc++.h>
using namespace std;
int n,m;

char g[100][100];
int di[][2] = {{1,1},{1,-1},{-1,1},{-1,-1}};

int k[][2] = {{1,-1},{1,1},{-1,-1},{-1,1}};



int search(int a,int b){
    char c = g[a][b];
    int cnt = 0 ;
    for(int d=0;d<4;d++){
        int x = a+(di[d][0]), y = b+(di[d][1]);
        while(x>=0 && x<n && y>=0 && y<m){
            if(g[x][b]==c && g[a][y]==c){
                int ok = 1,p=a,q=y;
                while(p!=x){
                    p+=k[d][0],q+=k[d][1];
                    if(g[p][q]!=c)ok=0;
                }
                if(ok==1)cnt++;
                x += (di[d][0]), y += (di[d][1]);
            }else break;
        }
    }

    return cnt;
}


int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            cin>>g[i][j];
        }
    long long ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            ans += search(i,j);
            //cout<<search(i,j)<<' ';
        }
        //cout<<endl;
    }

    cout<<ans;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/73620
推荐阅读
相关标签
  

闽ICP备14008679号