結果

問題 No.593 4進FizzBuzz
ユーザー SSRS
提出日時 2020-11-12 15:29:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 919 ms
コンパイル使用メモリ 64,896 KB
実行使用メモリ 7,312 KB
最終ジャッジ日時 2024-07-22 19:12:03
合計ジャッジ時間 5,117 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
int main(){
	string N;
	cin >> N;
	int M = N.size();
	int a = 0, b = 0;
	for (int i = 0; i < M; i++){
		a += N[i] - '0';
		if (i % 2 == 0){
			b += N[i] - '0';
		} else {
			b -= N[i] - '0';
		}
	}
	if (a % 3 == 0 && b % 5 == 0){
		cout << "FizzBuzz" << endl;
	} else if (a % 3 == 0){
		cout << "Fizz" << endl;
	} else if (b % 5 == 0){
		cout << "Buzz" << endl;
	} else {
		cout << N << endl;
	}
}
0