結果

問題 No.593 4進FizzBuzz
ユーザー reitetsuohreitetsuoh
提出日時 2017-12-26 15:47:47
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 569 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 57,300 KB
実行使用メモリ 9,012 KB
最終ジャッジ日時 2024-12-18 00:21:57
合計ジャッジ時間 3,881 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	string N;
	cin>>N;
	int i;
	int len=N.length()-1;
	LL M=0;
	LL m=1;
	for (i=len;i>=0;i--){
		int n=N[i]-'0';
		if (n>0){
			M+=n*m;
			M=M%3;
		}
		m*=4;
	}
	LL m3=M%3;
	M=0;
	m=1;
	for (i=len;i>=0;i--){
		int n=N[i]-'0';
		if (n>0){
			M+=n*m;
			M=M%5;
		}
		m*=4;
	}
	LL m5=M%5;
	if (m3==0 && m5==0){
		cout<<"FizzBuzz"<<endl;
	}else if (m3==0){
		cout<<"Fizz"<<endl;
	}else if (m5==0){
		cout<<"Buzz"<<endl;
	}else{
		cout<<N<<endl;
	}
	return 0;
}
0