結果

問題 No.637 X: Yet Another FizzBuzz Problem
ユーザー commy
提出日時 2018-02-26 19:26:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 598 bytes
コンパイル時間 545 ms
コンパイル使用メモリ 68,944 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 18:59:05
合計ジャッジ時間 1,543 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(s) cerr << __LINE__ << "\t:" << #s << " = " << (s) << endl
    
using namespace std;

int digits(int n) {
    int ans = 0;
    do {
	ans++;
	n /= 10;
    } while(n > 0);
    return ans;
}

int main () {
    int a[5] = {};
    REP (i, 0, 5) cin >> a[i];
    int ans = 0;
    REP (i, 0, 5) {
	if (a[i] % 5 == 0) ans += 4;
	if (a[i] % 3 == 0) ans += 4;
	if ((a[i] % 3) && (a[i] % 5)) ans += digits(a[i]);
	//dump(ans);
	
    }
    cout << ans << endl;
    return 0; 
}
0