2
0

More than 3 years have passed since last update.

JOI2019/2020 一次予選第三回 A問題,B問題の解き方

Posted at

JOI2019/2020の一次予選第三回、お疲れさまでした.
コンテスト中ではB問題のみ解けました.
解説が出ているから公開していいはず。
使用言語 : C++,Python3

A問題

qiita_joia.png

解法

X < L
の時、Lを出力.

L <= X <= R
の時、Xを出力.

R < X
の時、Rを出力.

コード

A.cpp
#include <iostream>

using namespace std;

int main(){
    int X;
    int L;
    int R;
    cin >> X >> L >> R;
    if(X < L){
        cout << L << endl;
    }
    else if(L <= X and X <= R){
        cout << X << endl;
    }
    else if(R < X){
        cout << R << endl;
    }
}

以上.

B問題

qiita_joi.png

解法

Python3のreplace関数を使って"joi" という文字列を"JOI"に置き換える.

コード

B.py
N, S = int(input())
print(S.replace('joi', 'JOI'))

以上.

感想

C問題もだけど、コンテスト中にA問題を解けなかったのが悔しいです...。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0