結果

問題 No.1136 Four Points Tour
ユーザー iiljjiiljj
提出日時 2020-10-07 21:49:01
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 2,019 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 28,884 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 10:01:39
合計ジャッジ時間 2,184 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 0 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 0 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 0 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 0 ms
4,380 KB
01_Sample03_evil.txt AC 1 ms
4,376 KB
04_Rnd_large_evil1.txt AC 1 ms
4,380 KB
04_Rnd_large_evil2.txt AC 1 ms
4,376 KB
04_Rnd_large_evil3.txt AC 1 ms
4,380 KB
04_Rnd_large_evil4.txt AC 0 ms
4,376 KB
04_Rnd_large_evil5.txt AC 1 ms
4,380 KB
04_Rnd_large_evil6.txt AC 0 ms
4,376 KB
04_Rnd_large_evil7.txt AC 0 ms
4,376 KB
04_Rnd_large_evil8.txt AC 1 ms
4,376 KB
04_Rnd_large_evil9.txt AC 1 ms
4,376 KB
04_Rnd_large_evil10.txt AC 0 ms
4,376 KB
05_Rnd_huge_evil1.txt AC 1 ms
4,380 KB
05_Rnd_huge_evil2.txt AC 1 ms
4,380 KB
05_Rnd_huge_evil3.txt AC 1 ms
4,376 KB
05_Rnd_huge_evil4.txt AC 1 ms
4,376 KB
05_Rnd_huge_evil5.txt AC 0 ms
4,376 KB
05_Rnd_huge_evil6.txt AC 0 ms
4,380 KB
05_Rnd_huge_evil7.txt AC 1 ms
4,376 KB
99_evil_01.txt WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘main’ 内:
main.c:8:15: 警告: 関数 ‘getc_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    8 |         tmp = getc_unlocked(stdin);                                                                                    \
      |               ^~~~~~~~~~~~~
main.c:26:5: 備考: in expansion of macro ‘rd_int’
   26 |     rd_int(n, tmp);
      |     ^~~~~~
main.c:20:19: 警告: 関数 ‘putc_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   20 |     while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);
      |                   ^~~~~~~~~~~~~
main.c:47:5: 備考: in expansion of macro ‘wt_int’
   47 |     wt_int(res, buf, tmp);
      |     ^~~~~~

ソースコード

diff #

#include <stdio.h>

#define MOD 1000000007U

// 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;                                                                                                     \
    }                                                                                                                  \
    if (!ptr) buf[ptr++] = 0;                                                                                          \
    while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);

int main() {
    unsigned long long n = 0, tmp;
    char buf[10];

    rd_int(n, tmp);

    // (3^n + 3*(-1)^n) / 4
    int sign = (n % 2) ? -1 : 1;
    tmp = 3;
    unsigned long long res = 1;
    while (n) {
        if (n & 1) {
            res *= tmp;
            res %= MOD;
        }
        n >>= 1;
        tmp *= tmp;
        tmp %= MOD;
    }
    res += 3 * sign;
    res %= MOD;
    res *= 250000002;
    res %= MOD;

    tmp = 0;
    wt_int(res, buf, tmp);

    return 0;
}
0