結果

問題 No.3022 縛りFizzBuzz (Easy)
ユーザー imulanimulan
提出日時 2017-03-31 23:09:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 73,944 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 11:23:06
合計ジャッジ時間 1,766 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define pb push_back

void ans(int n)
{
    vector<string> ans;
    while(n)
    {
        if(!(n%('p'-'a'))) ans.pb("FizzBuzz");
        else if(!(n%('d'-'a'))) ans.pb("Fizz");
        else if(!(n%('f'-'a'))) ans.pb("Buzz");
        else ans.pb(to_string(n));
        n--;
    }

    reverse(all(ans));
    for(int i='a'-'a'; i<ans.size(); ++i) cout << ans[i] << endl;
}

int main()
{
    int n;
    cin >>n;
    ans(n);
}
0