2019第十届蓝桥杯c/c++,b组

感觉、、我比去年还菜

/*2019-3-28成绩出来了、省二,

和去年一样,去年是差点省一,今年差点省三。。。

数的分解10分,迷宫15分,这样丢了25分

完全二叉树的权值20分的题,当成满二叉树做的,按丢5分算(其实觉的丢的分不止这些)

这样丢了30分。。。妈耶,我想一巴掌呼死自己

等会、、等差数列还有20分呢、、、、mdlx

ps 学校的机房还是不能用longlong,又浪费好长时间调bug,醉了

*/

没啥想法的第一题,瞪眼瞪出的490

手算的第二题BYQ

拆2019的,我好像少读了个条件、、(还是说那个特殊数的和来着,忘了、、)

迷宫的手动模拟了下dfs,mdzz,眼都花了,最后写了个dfs

等差数列智障写了个最小的差分、、应该求gcd+特判gcd==0的

完全二叉树不是,满二叉树、、gg

倒数第二题,sort直接写的,据说,不对,要考虑括号、、、(我寻思着题目里也没说啊)

最后一题太麻烦,直接输出随机数了

 

凉了、、、这么一算我,分都没了、、

C

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int maxn = 1e5+7,mod = 1e9+7;
int dp[20190324+10] = {0,1,1,1};
int main(){
    for(int i=4;i<=20190324;i++)
        dp[i] = (dp[i-1]+dp[i-2]+dp[i-3])%10000;
    printf("%d\n",dp[20190324]);
    return 0;
}
// 4659

 

D

wsl,少看了个条件,不能有 2 或 4

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int maxn = 1e5+7,mod = 1e9+7;
bool jude(int x){
    while(x){
        if(x%10 == 2 || x%10 == 4)
            return true;
        x /= 10;
    }
    return false;
}
int main(){
    ll ans = 0;
    for(int i=1;i<=2019;i++){
        if(jude(i))continue;
        for(int j=i+1;j<=2019 && 2019-(i+j)>j;j++){
            if(jude(j) || jude(2019-(i+j)))continue;
            ans++;
        }
    }
    printf("%lld\n",ans);
    return 0;
}
// 40785

 

迷宫,bfs+dfs

当时写错了qwq

咱这个代码可以看下是怎么走哒,笑

 

 

 

 

*1 1 1 1  1 11  1  1 1 11  1 11 1  1****1   1 1 1
*   1   1     1 1 1  1    1       1**11* 11 1  1 1
*1111 11 1  1   1     11 1  1 111***11 ******1
*1******* 1 1 1   11 1    1 1  ***1 1 1 1 11* 1 11
***11111***** 1 1    1  1 1   1*1     1 11  ***
11  1   11 1*1    1 1 11   11 1**11 1 1 1 1111*111
   11 11 1 1*1  1  1  1 1      1*  1 1  111****
1 1     1 1** 1  11 1 1 1 11111 *11    1   *111 1
  111     1*1 1    11   1      1***1 1  11 ***1  1
11   11 1  **111  1   1  1 1 1 1 1*1 1 1   11*1
   1    1  1*    1 1  1 1 1 111 1 * 1 1 1 1  **1 1
111  1  1 1 *1  1    1     1 1 1 1*1  1  1   1*1
      1     * 1 1 11  1111 1   11 ****1 1 1 1** 11
1 1 1 1  111*   1    11    1 11  1111*11 1   *1
1 1 1 1 1   *11 1 1 1  1 1    1 1*****111 111*1  1
1       1 11*  1    1 11  1 11 1 *1 111    *** 1
1 1 1  1    *  1 1  1    1   1   * 1   1111*1 1  1
  1 1  1 1 1*11 1  1 1 1   11 1 1*11 111****11 1 1
11  1 1    1*   11      1 1  1 1 *** 1 **111    1
    1   11  * 11 1 11 1      1  1 1**1 *1    111 1
1 1  1 1   1*1    *** 111 11  1 11 1*11*1 1 1    1
  1 1    1  **11 1*1*1    1   1   1 *1** 1   1 1 1
1 1    1   11* 1***1*   1 1 1  1 1 1*1*11111 1  1
     1  1 1  ****11 *1 1  1 1  1    *1**********1
11 1      1  111 111**1  1    111 1 *1 11 111 1*
     11 1   1   1   1*******1*** 111*1      11 *11
1 1 1   1 1   1   1   11111***1*1 1**1 1      1*
1     1 1  1 1  1 1 11       1 *1 1*1   1 111 1*
  1111    1    1       11 111  ***** 1        1*11
1      11  111 1 111 1   1   11 111 1 1 11 1111***

DDDDRRURRRRRRDRRRRDDDLDDRDDDDDDDDDDDDRDDRRRURRUURRDDDDRDRRRRRRDRRURRDDDRRRRUURUUUUUUULULLUUUURRRRUUL
LLUUUULLUUULUURRURRURURRRDDRRRRRDDRRDDLLLDDRRDDRDDLDDDLLDDLLLDLDDDLDDRRRRRRRRRDDDDDDRR
186

Process returned 0 (0x0)   execution time : 1.883 s
Press any key to continue.
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
typedef unsigned long long ll;
const int maxn = 1e5+7,mod = 1e9+7;
char s[100][100],ans[1000],t[5] = "DLRU",out[1000];
int cnt = 1e9;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,-1,1,0};
bool vis[100][100];
int mmp[100][100],flag;
void Setout(int x,int y){
    COORD coord;
    coord.X = x; //第3行
    coord.Y = y; //第3列
    //获取控制台缓冲区句柄
    HANDLE ConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
    //设置光标位置
    SetConsoleCursorPosition(ConsoleHandle, coord);
}
void dfs(int x,int y,int deep){
    if(flag)return;
    if(x == 30 && y == 50){
        if(cnt>deep){
            cnt = deep;
            for(int i=0;i<cnt;i++)out[i] = ans[i];
            Setout(0,31);
            printf("%d\n",cnt);
        }
        flag = 1;
        return;
    }
    for(int i=0;i<4;i++){
        int tx = x+dx[i],ty = y+dy[i];
        if(tx>0&&ty>0&&tx<=30&&ty<=50&& s[tx][ty]=='0' && !vis[tx][ty] && mmp[tx][ty]>mmp[x][y]){
            ans[deep] = t[i];
            vis[tx][ty] = 1;
            Setout(ty-1,tx-1);
            printf("*");
            dfs(tx,ty,deep+1);
            if(flag)return;
            vis[tx][ty] = 0;
            Setout(ty-1,tx-1);
            printf(" ");
        }
    }
}
struct node{int x,y,id;};
void bfs(){
    queue<node> Q;
    mmp[1][1] = 0;
    Q.push(node{1,1,0});
    while(!Q.empty()){
        node top = Q.front();
        Q.pop();
        for(int i=0;i<4;i++){
            node t = {top.x+dx[i],top.y+dy[i],top.id+1};
            if(t.x>0&&t.y>0&&t.x<=30&&t.y<=50 && s[t.x][t.y] == '0' && mmp[t.x][t.y]>t.id){
                mmp[t.x][t.y] = t.id;
                Q.push(t);
            }
        }
    }
}
int main(){
    memset(mmp,0x3f,sizeof mmp);
    for(int i=1;i<=30;i++)
        scanf("%s",s[i]+1);
    bfs();
    system("cls");
    for(int i=1;i<=30;i++){
        for(int j=1;j<=50;j++)//printf("%c",s[i][j]=='0'?mmp[i][j]%2+'0':'#');
            printf("%c",s[i][j]=='0'?' ':'1');
        puts("");
    }
    //printf("%d\n",mmp[30][50]);
    vis[1][1] = 1;
    Setout(0,0);printf("*");
    dfs(1,1,0);
    Setout(0,31);
    for(int i=0;i<cnt;i++)printf("%c",out[i]);
    printf("\n%d\n",cnt);
    return 0;
}
/*
01010101001011001001010110010110100100001000101010
00001000100000101010010000100000001001100110100101
01111011010010001000001101001011100011000000010000
01000000001010100011010000101000001010101011001011
00011111000000101000010010100010100000101100000000
11001000110101000010101100011010011010101011110111
00011011010101001001001010000001000101001110000000
10100000101000100110101010111110011000010000111010
00111000001010100001100010000001000101001100001001
11000110100001110010001001010101010101010001101000
00010000100100000101001010101110100010101010000101
11100100101001001000010000010101010100100100010100
00000010000000101011001111010001100000101010100011
10101010011100001000011000010110011110110100001000
10101010100001101010100101000010100000111011101001
10000000101100010000101100101101001011100000000100
10101001000000010100100001000100000100011110101001
00101001010101101001010100011010101101110000110101
11001010000100001100000010100101000001000111000010
00001000110000110101101000000100101001001000011101
10100101000101000000001110110010110101101010100001
00101000010000110101010000100010001001000100010101
10100001000110010001000010101001010101011111010010
00000100101000000110010100101001000001000000000010
11010000001001110111001001000011101001011011101000
00000110100010001000100000001000011101000000110011
10101000101000100010001111100010101001010000001000
10000010100101001010110000000100101010001011101000
00111100001000010000000110111000000001000000001011
10000001100111010111010001000110111010101101111000
*/

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值