Submission #65891658


Source Code Expand

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N, K;
    if (scanf("%d %d", &N, &K) != 2) return 1;

    long long *A = malloc(sizeof(long long) * N);
    if (!A) return 1;
    for(int i = 0; i < N; i++){
        scanf("%lld", &A[i]);
    }

    // 10^K をループで安全に計算
    unsigned long long limit = 1;
    for(int i = 0; i < K; i++){
        limit *= 10ULL;
    }

    // now は表示中の値
    unsigned long long now = 1;

    for(int i = 0; i < N; i++){
        __int128 prod = (__int128)now * (__int128)A[i];
        if (prod >= (__int128)limit) {
            now = 1;
        } else {
            now = (unsigned long long)prod;
        }
    }

    printf("%llu\n", now);
    free(A);
    return 0;
}

Submission Info

Submission Time
Task B - Product Calculator
User oinucha
Language C (gcc 12.2.0)
Score 200
Code Size 777 Byte
Status AC
Exec Time 1 ms
Memory 1760 KiB

Compile Error

Main.c: In function ‘main’:
Main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%lld", &A[i]);
      |         ^~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 32
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 0 ms 1624 KiB
example_01.txt AC 0 ms 1580 KiB
hand_00.txt AC 0 ms 1736 KiB
hand_01.txt AC 0 ms 1616 KiB
hand_02.txt AC 0 ms 1632 KiB
hand_03.txt AC 1 ms 1744 KiB
hand_04.txt AC 0 ms 1656 KiB
random_00.txt AC 0 ms 1748 KiB
random_01.txt AC 0 ms 1732 KiB
random_02.txt AC 0 ms 1728 KiB
random_03.txt AC 0 ms 1752 KiB
random_04.txt AC 0 ms 1724 KiB
random_05.txt AC 0 ms 1728 KiB
random_06.txt AC 0 ms 1656 KiB
random_07.txt AC 0 ms 1628 KiB
random_08.txt AC 0 ms 1600 KiB
random_09.txt AC 0 ms 1724 KiB
random_10.txt AC 0 ms 1624 KiB
random_11.txt AC 0 ms 1636 KiB
random_12.txt AC 0 ms 1636 KiB
random_13.txt AC 0 ms 1600 KiB
random_14.txt AC 0 ms 1652 KiB
random_15.txt AC 0 ms 1636 KiB
random_16.txt AC 0 ms 1584 KiB
random_17.txt AC 0 ms 1588 KiB
random_18.txt AC 0 ms 1644 KiB
random_19.txt AC 0 ms 1576 KiB
random_20.txt AC 0 ms 1656 KiB
random_21.txt AC 0 ms 1620 KiB
random_22.txt AC 0 ms 1632 KiB
random_23.txt AC 0 ms 1652 KiB
random_24.txt AC 0 ms 1760 KiB