結果
| 問題 | No.1136 Four Points Tour |
| ユーザー |
iiljj
|
| 提出日時 | 2020-10-07 21:49:01 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,019 bytes |
| 記録 | |
| コンパイル時間 | 429 ms |
| コンパイル使用メモリ | 29,568 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 04:11:09 |
| 合計ジャッジ時間 | 1,637 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 WA * 1 |
コンパイルメッセージ
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:47:5: note: in expansion of macro 'wt_int'
47 | 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 += 3 * sign;
res %= MOD;
res *= 250000002;
res %= MOD;
tmp = 0;
wt_int(res, buf, tmp);
return 0;
}
iiljj