結果

問題 No.8022 縛りFizzBuzz (Easy)
ユーザー rsk0315
提出日時 2020-02-24 21:07:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 54,912 KB
最終ジャッジ日時 2025-01-09 02:06:15
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <string>

#define length(x) ((#x ## s).length())

using namespace std::literals;

int const one = length(x);
int const three = length(xxx);
int const five = length(xxxxx);

int main() {
  int n;
  scanf("%d", &n);

  for (int i = one; i <= n; ++i) {
    if ((i % three < one) && (i % five < one)) {
      puts("FizzBuzz");
    } else if (i % three < one) {
      puts("Fizz");
    } else if (i % five < one) {
      puts("Buzz");
    } else {
      printf("%d\n", i);
    }
  }
}
0