結果

問題 No.637 X: Yet Another FizzBuzz Problem
ユーザー hiyori
提出日時 2019-02-10 09:49:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 544 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 63,616 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 18:36:12
合計ジャッジ時間 1,553 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
void run();

int main()
{
    run();
    EXIT_SUCCESS;
}

void run()
{
    int fizzbuzz=8, fizz_or_buzz=4, sum=0, cnt=0,N;
    for(int i=0; i<5; i++){
        std::cin>>N;
        if(N%3==0 && N%5==0){
            sum += fizzbuzz;
        }
        else if(N%3==0 || N%5==0){
            sum += fizz_or_buzz;
        }
        else {
            while(N>0){
                N/=10;
                cnt++;
            }
            sum+=cnt;
            cnt=0;
        }
    }
    std::cout<<sum<<std::endl;
}
0