結果

問題 No.3043 yukicoderへようこそ!
ユーザー face4face4
提出日時 2019-04-01 22:01:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,476 bytes
コンパイル時間 776 ms
コンパイル使用メモリ 73,720 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 07:52:40
合計ジャッジ時間 1,040 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
using namespace std;
typedef long long ll;

int main(){
    string s;
    getline(cin, s);
    bool judge = true;
    int sp = 0;
    for(char c : s) judge &= isdigit(c), sp += (c==' ');
    if(!judge){
        cout << "Hello World!" << endl;
        return 0;
    }
    if(sp == 1){
        int t = 0;
        for(;;t++)  if(s[t] == ' ') break;
        int a = stoi(s.substr(0, t)), b = stoi(s.substr(t+1));
        string k;
        getline(cin, k);
        cout << a+b << " " << k << endl;
        return 0;
    }
    string k = "";
    if(getline(cin, k)){
        sp = 0;
        for(int i = 0; i < k.length(); i++) if(k[i] == ' ') sp++;
        if(sp == 0){
            int n = stoi(s);
            ll ans = stoll(k);
            for(int i = 1; i < n; i++)  cin >> s, ans += stoll(s);
            cout << ans << endl;
        }else{
            ll ans = 0;
            int l = 0, r = 0;
            while(r < k.length()){
                while(r < k.length() && k[r] != ' ')  r++;
                ans += stoll(k.substr(l, r-l));
                l = r+1; r++;
            }
            cout << ans << endl;
        }
    }else{
        for(int i = 1; i <= stoi(s); i++){
            string ret = "";
            if(i%3 == 0)    ret += "Fizz";
            if(i%5 == 0)    ret += "Buzz";
            if(ret == "")   ret = to_string(i);
            cout << ret << endl;
        }
    }
    return 0;
}
0