結果

問題 No.593 4進FizzBuzz
ユーザー newlife171128
提出日時 2017-12-24 10:21:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,011 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 66,508 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2024-12-17 18:25:36
合計ジャッジ時間 3,600 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>

using namespace std;

int ans =0;

int answ[3];
int get(string s){
	ans =0;
	for(int i=s.length()-1;i>=0;i--){

		if(i==0){
			answ[0] = (answ[0]+(s[i]-'0'))%3;
		}else {
			answ[0] = (answ[0]+(s[i]-'0'))*4%3;
		}
		if(i==0){
			answ[1] = (answ[1]+(s[i]-'0'))%5;
		}else {
			answ[1] = (answ[1]+(s[i]-'0'))*4%5;
		}
		if(i==0){
			answ[2] = (answ[2]+(s[i]-'0'))%15;
		}else {
			answ[2] = (answ[2]+(s[i]-'0'))*4%15;
		}

	}
	return ans;
}

int main() {

	string s ;
	cin>>s;

/*	int digit[s.length()];
	for(int i=0;i<s.length();i++){
		digit[i] = s[i]-'0';

	}*/

/*	for(int i=s.length()-1;i>=0;i--){

		if(i==0){
			ans = (ans+(s[i]-'0'));
		}else {
			ans = (ans+(s[i]-'0'))*4;
		}

	}*/

/*	cout<<ans;*/

	get(s);
	if(answ[2] ==0){
		cout<<"FizzBuzz"<<endl;
	}else if (answ[0] ==0) {
		cout<<"Fizz"<<endl;
	}else if (answ[1]==0) {
		cout<<"Buzz"<<endl;
	}else {
		cout<<s<<endl;
	}
return 0;
}
0