結果

問題 No.3101 砂嵐
ユーザー iiljjiiljj
提出日時 2023-03-31 22:17:05
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 5,996 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 29,924 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 08:21:23
合計ジャッジ時間 1,864 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
testcase_34 AC 1 ms
4,348 KB
testcase_35 AC 1 ms
4,348 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 AC 1 ms
4,348 KB
testcase_38 AC 1 ms
4,348 KB
testcase_39 AC 1 ms
4,348 KB
testcase_40 AC 1 ms
4,348 KB
testcase_41 AC 1 ms
4,348 KB
testcase_42 AC 1 ms
4,348 KB
testcase_43 AC 1 ms
4,348 KB
testcase_44 AC 1 ms
4,348 KB
testcase_45 AC 1 ms
4,348 KB
testcase_46 AC 1 ms
4,348 KB
testcase_47 AC 1 ms
4,348 KB
testcase_48 AC 1 ms
4,348 KB
testcase_49 AC 1 ms
4,348 KB
testcase_50 AC 1 ms
4,348 KB
testcase_51 AC 1 ms
4,348 KB
testcase_52 AC 1 ms
4,348 KB
testcase_53 AC 1 ms
4,348 KB
testcase_54 AC 1 ms
4,348 KB
testcase_55 AC 1 ms
4,348 KB
testcase_56 AC 1 ms
4,348 KB
testcase_57 AC 1 ms
4,348 KB
testcase_58 AC 1 ms
4,348 KB
testcase_59 AC 1 ms
4,348 KB
testcase_60 AC 1 ms
4,348 KB
testcase_61 AC 1 ms
4,348 KB
testcase_62 AC 1 ms
4,348 KB
testcase_63 AC 1 ms
4,348 KB
testcase_64 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:9:15: warning: implicit declaration of function 'getc_unlocked' [-Wimplicit-function-declaration]
    9 |         tmp = getc_unlocked(stdin);                                                                                    \
      |               ^~~~~~~~~~~~~
main.c:71:5: note: in expansion of macro 'rd_int'
   71 |     rd_int(n, k);
      |     ^~~~~~
main.c:74:9: warning: implicit declaration of function 'putc_unlocked' [-Wimplicit-function-declaration]
   74 |         putc_unlocked('0', stdout);
      |         ^~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

// 以下,正の整数向け
// verified with: yukicoder No.1128 Wedding Ceremony

// int tmp, var = 0; を先に宣言する
#define rd_int(var, tmp)                                                                                               \
    for (;;) {                                                                                                         \
        tmp = getc_unlocked(stdin);                                                                                    \
        if (tmp < '0' || tmp > '9') break;                                                                             \
        var = var * 10 + tmp - '0';                                                                                    \
    }

// char buf[9]; int ptr = 0; を先に宣言する
#define wt_int(var, buf, ptr)                                                                                          \
    while (var) {                                                                                                      \
        buf[ptr++] = var % 10;                                                                                         \
        var /= 10;                                                                                                     \
    }                                                                                                                  \
    while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);

// 以下,負の数もOKなバージョン
// verified with: yukicoder No.1132 凸凹

// int tmp, var = 0, sign = 0; を先に宣言する
#define rd_int_s(var, tmp, sign)                                                                                       \
    for (;;) {                                                                                                         \
        tmp = getchar_unlocked();                                                                                      \
        if (tmp == '-') {                                                                                              \
            sign = 1;                                                                                                  \
            break;                                                                                                     \
        } else if ('0' <= tmp && tmp <= '9') {                                                                         \
            var = tmp - '0';                                                                                           \
            break;                                                                                                     \
        }                                                                                                              \
    }                                                                                                                  \
    for (;;) {                                                                                                         \
        tmp = getc_unlocked(stdin);                                                                                    \
        if (tmp < '0' || tmp > '9') break;                                                                             \
        var = var * 10 + tmp - '0';                                                                                    \
    }                                                                                                                  \
    if (sign) var = -var;

// char buf[9]; int ptr = 0, sign = 0; を先に宣言する
#define wt_int_s(var, buf, ptr, sign)                                                                                  \
    if (var < 0) {                                                                                                     \
        sign = 1;                                                                                                      \
        var = -var;                                                                                                    \
    }                                                                                                                  \
    while (var) {                                                                                                      \
        buf[ptr++] = var % 10;                                                                                         \
        var /= 10;                                                                                                     \
    }                                                                                                                  \
    if (!ptr) buf[ptr++] = 0;                                                                                          \
    if (sign) putc_unlocked('-', stdout);                                                                              \
    while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);

#define rd_int_s_(var, tmp, sign)                                                                                      \
    var = sign = 0;                                                                                                    \
    rd_int_s(var, tmp, sign);

#define wt_int_s_(var, buf, ptr, sign)                                                                                 \
    ptr = sign = 0;                                                                                                    \
    wt_int_s(var, buf, ptr, sign);

int main() {
    long long n = 0;
    int k, ptr = 0;
    char buf[20];

    rd_int(n, k);

    if (n < 10) {
        putc_unlocked('0', stdout);
        return 0;
    }

    int ans = 0;
    while (n >= 10) {
        long long prod = 1;
        while (n > 0 && prod > 0) {
            prod *= (n % 10);
            n /= 10;
        }
        ans++;
        n = prod;
    }
    wt_int(ans, buf, ptr);
    return 0;
}
0