codeforces round937 div4

A. Stair, Peak, or Neither?

问题:

思路:枚举所有合法情况

代码:

#include <iostream>
 
using namespace std; 
 
void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b && b < c) cout << "STAIR" << endl;
    else if(a < b && b > c) cout << "PEAK" << endl;
    else cout << "NONE" << endl;
}
 
int main() {
    int t;
    cin >> t;
    while(t -- ) {
        solve();
    }
    return 0;
}

B upscaling

题目:

思路:两个for循环,按照奇数遍历次数和偶数遍历次数分别填充方块

代码:

#include <iostream>
 
using namespace std;
 
const int N = 22;
 
char g[2 * N][2 * N];
 
void get(int a, int b, char c) {
    g[(a - 1) * 2 + 1][(b - 1) * 2 + 1] = c;
    g[(a - 1) * 2 + 1][(b - 1) * 2 + 2] = c;
    g[(a - 1) * 2 + 2][(b - 1) * 2 + 1] = c;
    g[(a - 1) * 2 + 2][(b - 1) * 2 + 2] = c;
}
 
void solve() {
    int n;
    cin >> n;
 
    int w = 1;
 
    for(int i = 1; i <= n; i ++ ) {
        if(i % 2) {
            for(int j = 1; j <= n; j ++ ) {
                char c;
                if(w ++ % 2) c = '#';
                else c = '.';
                get(i, j, c);
            }
        } else {
                for(int j = n; j; j -- ) {
                    char c;
                    if(w ++ % 2) c = '#';
                    else c = '.';
                    get(i, j, c);
                }
            }
    }
 
    for(int i = 1; i <= 2 * n; i ++ ) {
        for(int j = 1; j <= 2 * n; j ++ ) {
            cout << g[i][j];
        }
        cout << endl;
    }
}
 
int main() {
    int t;
    cin >> t;
 
    while(t -- ) {
        solve();
    }
    return 0;
}

C time conversion

问题:

思路:模拟

代码:

#include <iost
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值