結果

問題 No.3043 yukicoderへようこそ!
ユーザー xuzijian629xuzijian629
提出日時 2019-04-01 22:36:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,515 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 201,588 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 01:45:58
合計ジャッジ時間 2,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

void solve1() {
    cout << "Hello World!" << endl;
}

void solve2(stringstream& ss) {
    random_device rnd;
    if (rnd() & 1) {
        int n;
        ss >> n;
        for (int i = 1; i <= n; i++) {
            if (i % 3 == 0 && i % 5 == 0) {
                cout << "FizzBuzz" << endl;
            } else if (i % 3 == 0) {
                cout << "Fizz" << endl;
            } else if (i % 5 == 0) {
                cout << "Buzz" << endl;
            } else {
                cout << i << endl;
            }
        }
    } else {
        int n;
        ss >> n;
        cout << n * (n + 1) / 2 << endl;
    }
}

void solve3(stringstream& ss) {
    int a, b;
    string s;
    ss >> a >> b >> s;
    cout << a + b << " " << s << endl;
}

void solve4(stringstream& ss) {
    int n;
    ss >> n;
    unsigned long long sum = 0;
    for (int i = 0; i < n; i++) {
        unsigned long long a;
        ss >> a;
        sum += a;
    }
    cout << sum << endl;
}

int main() {
    string input = "";
    stringstream ss;
    char c;
    int newlinecnt = 0, spacecnt = 0;
    while ((c = getchar()) != EOF) {
        input += c;
        if (c == '\n') newlinecnt++;
        if (c == ' ') spacecnt++;
        ss << c;
    }
    cerr << newlinecnt << endl;
    if (newlinecnt == 1 && input.size() > 10) {
        solve1();
    } else if (input.size() < 4) {
        solve2(ss);
    } else if (spacecnt == 1) {
        solve3(ss);
    } else {
        solve4(ss);
    }
}
0