結果

問題 No.593 4進FizzBuzz
ユーザー nyboyunyboyu
提出日時 2018-01-22 20:43:33
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 28,268 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 22:15:56
合計ジャッジ時間 2,448 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 0 ms
4,380 KB
testcase_06 AC 0 ms
4,380 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 0 ms
4,380 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 0 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 16 ms
4,376 KB
testcase_17 AC 16 ms
4,380 KB
testcase_18 AC 16 ms
4,376 KB
testcase_19 AC 17 ms
4,376 KB
testcase_20 AC 16 ms
4,384 KB
testcase_21 AC 16 ms
4,380 KB
testcase_22 AC 17 ms
4,376 KB
testcase_23 AC 16 ms
4,376 KB
testcase_24 AC 16 ms
4,380 KB
testcase_25 AC 16 ms
4,376 KB
testcase_26 AC 16 ms
4,376 KB
testcase_27 AC 18 ms
4,380 KB
testcase_28 AC 16 ms
4,380 KB
testcase_29 AC 17 ms
4,376 KB
testcase_30 AC 16 ms
4,376 KB
testcase_31 AC 16 ms
4,380 KB
testcase_32 AC 16 ms
4,380 KB
testcase_33 AC 17 ms
4,380 KB
testcase_34 AC 16 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
int main(void){
    char *str;
    str=(char *)malloc(2000001ULL);
    scanf("%s",str);
    //n=10
    // 10=>  1(mod 3)
    //A0B=> AB=>A+B(mod 3)
    // 10=>  0(mod 5)
    //A0B=>  B(mod 5)

    //n= 4
    // 10=>  1(mod 3)
    //A0B=> AB=>A+B(mod 3)
    // 10=> -1(mod 5)
    //A0B=>-A0
    //       +B=>A+B(mod 5)
    int m3=0,m5=0,t;
    for(int i=0;str[i]!='\0';i++){
        t=str[i]-'0';
        m3=(t+m3)%3;//4=> 1(mod 3)
        m5=(t-m5)%5;//4=>-1(mod 5)
    }
    if(m3==0&&m5==0){
        printf("FizzBuzz\n");
    } else if(m3==0){
        printf("Fizz\n");
    } else if(m5==0){
        printf("Buzz\n");
    } else {
        printf("%s\n",str);
    }
    free(str);
    return 0;
}
0