結果

問題 No.1343 Dividing Digit
ユーザー iiljjiiljj
提出日時 2021-01-16 13:39:18
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,575 bytes
コンパイル時間 1,529 ms
コンパイル使用メモリ 31,616 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 15:38:30
合計ジャッジ時間 1,261 ms
ジャッジサーバーID
(参考情報)
judge1 / 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 AC 4 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 4 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
    }
    unsigned int ans = 0;
    long 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