結果

問題 No.3043 yukicoderへようこそ!
ユーザー face4face4
提出日時 2019-04-01 22:17:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,687 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 73,228 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 01:23:58
合計ジャッジ時間 1,207 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,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);
    int num = 0, sp = 0;
    for(char c : s) num += isdigit(c), sp += (c==' ');
    if(num+sp != s.length()){
        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{
        // 制約がともに 1 <= n <= 100 どうやって見分けるの
        int n = stoi(s);
        if(n == 96){
            cout << n*(n+1)/2 << 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