0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AtCoder Beginner Contest 350 A問題

Posted at

AtCoder Beginner Contest 350 A問題
こちらの問題です。

問題

image.png

入出力例

image.png

解法

例外である316と0を除き、最後の3文字が349以下であるかどうか確認します。

#include <iostream>
#include <string>
using namespace std;

int main() {
    string input;
    cin >> input;
    int len = input.length();
    
    string lastThreeDigits = input.substr(len - 3);
    int number = stoi(lastThreeDigits);

    if ((number != 0 && number != 316) && (number <= 349)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?