結果
問題 | No.1136 Four Points Tour |
ユーザー |
![]() |
提出日時 | 2020-10-07 21:55:21 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 2,126 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 29,824 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 04:15:03 |
合計ジャッジ時間 | 1,293 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 |
コンパイルメッセージ
main.c: In function 'main': main.c:8:15: warning: implicit declaration of function 'getc_unlocked' [-Wimplicit-function-declaration] 8 | tmp = getc_unlocked(stdin); \ | ^~~~~~~~~~~~~ main.c:26:5: note: in expansion of macro 'rd_int' 26 | rd_int(n, tmp); | ^~~~~~ main.c:20:19: warning: implicit declaration of function 'putc_unlocked' [-Wimplicit-function-declaration] 20 | while (ptr--) putc_unlocked(buf[ptr] + '0', stdout); | ^~~~~~~~~~~~~ main.c:50:5: note: in expansion of macro 'wt_int' 50 | wt_int(res, buf, tmp); | ^~~~~~
ソースコード
#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 += (MOD + 3 * sign) % MOD; // printf("[%lld]\n", res); if (res < 0) res += MOD; // printf("[%lld]\n", res); res %= MOD; res *= 250000002; res %= MOD; tmp = 0; wt_int(res, buf, tmp); return 0; }