結果
問題 |
No.593 4進FizzBuzz
|
ユーザー |
![]() |
提出日時 | 2018-09-04 17:42:58 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 933 bytes |
コンパイル時間 | 1,319 ms |
コンパイル使用メモリ | 159,076 KB |
実行使用メモリ | 5,356 KB |
最終ジャッジ日時 | 2024-10-14 17:32:05 |
合計ジャッジ時間 | 4,453 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define ll long long int #define rep(i,n) for( int i = 0; i < n; i++ ) #define rrep(i,n) for( int i = n; i >= 0; i-- ) #define REP(i,s,t) for( int i = s; i <= t; i++ ) #define RREP(i,s,t) for( int i = s; i >= t; i-- ) #define dump(x) cerr << #x << " = " << (x) << endl; #define INF 2000000000 #define mod 1000000007 #define INF2 1000000000000000000 int main(void) { cin.tie(0); ios::sync_with_stdio(false); string S; cin >> S; int digitsum = 0; int remainder = 0; rep(i, S.length()) { digitsum += S[i] - '0'; remainder += (S[i] - '0') * ((((int)S.length() - i) % 2 == 1) * 3 + 1); } int flag = 1; if (digitsum % 3 == 0) flag *= 3; if (remainder % 5 == 0) flag *= 5; if (flag == 3) { cout << "Fizz" << endl; } else if (flag == 5) { cout << "Buzz" << endl; } else if (flag == 15) { cout << "FizzBuzz" << endl; } else cout << S << endl; return 0; }