結果

問題 No.1343 Dividing Digit
ユーザー iiljjiiljj
提出日時 2021-01-16 13:28:56
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,562 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 31,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 15:27:27
合計ジャッジ時間 1,736 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:42:9: warning: implicit declaration of function 'putc_unlocked' [-Wimplicit-function-declaration]
   42 |         putc_unlocked('0', stdout);
      |         ^~~~~~~~~~~~~

ソースコード

diff #

#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;
    }
    int ans = 0;
    int base = 1;
    while (ap-- > a) {
        ans += base * *ap % 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;
}
0