結果
| 問題 |
No.1343 Dividing Digit
|
| コンテスト | |
| ユーザー |
iiljj
|
| 提出日時 | 2021-01-16 13:40:43 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,590 bytes |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 32,384 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 14:07:55 |
| 合計ジャッジ時間 | 953 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
コンパイルメッセージ
main.c: In function 'main':
main.c:42:9: warning: implicit declaration of function 'putc_unlocked' [-Wimplicit-function-declaration]
42 | putc_unlocked('0', stdout);
| ^~~~~~~~~~~~~
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
// clang-format off
#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} //
// clang-format on
#define wt_int(var, buf, ptr) \
while (var) { \
buf[ptr++] = var % 10; \
var /= 10; \
} \
while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);
int a[100000];
int main() {
// void *mmap(void * addr , size_t length , int prot , int flags , int fd , off_t offset );
char *rp = (char *)mmap(0l, 1l << 28, 1, 2, 0, 0ll);
RD(n) RD(k);
int sum = 0;
int *ap = a;
for (int i = 0; i < n; ++i) {
RD(t);
*ap++ = t;
sum += t;
}
unsigned int ans = 0;
long base = 1;
while (ap-- > a) {
ans += (base * *ap) % sum;
if (ans > sum) ans -= sum;
base *= k;
base %= sum;
}
if (ans == 0) {
putc_unlocked('0', stdout);
exit(0);
}
int ptr = 0;
char buf[10];
wt_int(ans, buf, ptr);
exit(0);
return 0;
}
iiljj