結果
| 問題 | No.593 4進FizzBuzz | 
| コンテスト | |
| ユーザー |  ats5515 | 
| 提出日時 | 2017-11-10 22:31:07 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 19 ms / 2,000 ms | 
| コード長 | 800 bytes | 
| コンパイル時間 | 837 ms | 
| コンパイル使用メモリ | 84,012 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-24 12:37:40 | 
| 合計ジャッジ時間 | 2,627 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 31 | 
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string N;
	cin >> N;
	reverse(N.begin(), N.end());
	int a3 = 1;
	int a5 = 1;
	int x3 = 0;
	int x5 = 0;
	for (int i = 0; i < N.size(); i++) {
		x3 = (x3 + a3*((int)(N[i] - '0'))) % 3;
		x5 = (x5 + a5*((int)(N[i] - '0'))) % 5;
		a3 = (a3 * 4) % 3;
		a5 = (a5 * 4) % 5;
	}
	if (x3 == 0 && x5 == 0) {
		cout << "FizzBuzz" << endl;
	}
	else if (x3 == 0) {
		cout << "Fizz" << endl;
	}
	else if (x5 == 0) {
		cout << "Buzz" << endl;
	}
	else {
		reverse(N.begin(), N.end());
		cout << N << endl;
	}
	
}
            
            
            
        