首页 > 其他 > 详细

CB--19

时间:2020-09-29 23:14:12      阅读:36      评论:0      收藏:0      [点我收藏+]

01

02

技术分享图片
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

struct lqb {
    
};

int main()
{
    int year = 2019;
    stack<int> ans;
    while(year) {
        if(year / 26 > 0)
            ans.push(year % 26);
        else
            break;
        year /= 26;
    }
    cout<<(char)(year + 64);
    while(!ans.empty()) {
        cout<<(char)(ans.top() + 64);
        ans.pop();
    }
    return 0;
}
View Code

03

技术分享图片
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

struct lqb {
    
};

int main()
{
    int f1 = 1,f2 = 1, f3 = 1,f4 = 0,i = 3;
    while(i++) {
        f4 = (f1 + f2 + f3) % 10000;
        if( i == 20190324) {
            cout<<f4;
            break;
        }
        f1 = f2;
        f2 = f3;
        f3 = f4;
    }
    return 0;
}
View Code

04

 

05

技术分享图片
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
//#include <map>
#include <set>

using namespace std;

#define L 30
#define W 50

char map[L][W];
int dir[4][2] = {{1,0},{0,-1},{0,1},{-1,0}};     // D  L  R  U
char ch[4] = {D,L,R,U};
int vis[L][W] = {0};

struct Point {
    int x;
    int y;
    string road;
    Point(int a,int b):x(a),y(b) {    }
}; 

void BFS() {
    queue<Point> q;
    Point p(0,0);
    p.road = "";
    q.push(p);
    vis[0][0] = 1;
    while(!q.empty()) { // 空 = true 
        Point t = q.front();
        q.pop();
        if(t.x == L - 1 && t.y == W - 1) {
            cout<<t.road<<endl;
            break;
        }
        for(int i = 0;i < 4;i++) {
            int dx = t.x + dir[i][0];
            int dy = t.y + dir[i][1];
            if(dx >= 0 && dx < L && dy >= 0 && dy < W) {
                if(map[dx][dy] == 0 && !vis[dx][dy]) {
                    Point tt(dx,dy);
                    tt.road = t.road + ch[i];
                    q.push(tt);
                    vis[dx][dy] = 1;
                }
            }
        } 
    }    
}

int main()
{
    for(int i = 0;i < L;i++) {
        for(int j = 0;j < W;j++)
            scanf("%c",&map[i][j]);
        getchar();    
    }
    cout<<endl<<endl;
    BFS();
    return 0;
}
View Code

06

07

08

09

10

 

CB--19

原文:https://www.cnblogs.com/2015-16/p/13737192.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!