Submission

Status:

PPPPPPPPP-

Subtask/Task Score:

90/100

Score: 90

User: theem1502

Problemset: เลขหลักของผลคูณ

Language: c

Time: 0.001 second

Submitted On: 2025-09-12 10:18:13

#include <stdio.h>
int main() {
    int digit;
    long long a, b;
    scanf("%lld %lld %d", &a, &b, &digit);
    long long prod = a * b;
    long long tempprod = prod;
    int digitcount = 0;
    if (tempprod == 0) {
        digitcount = 1;
    }
    
    while (tempprod > 0) {
        tempprod /=10;
        digitcount++;
    }
    if (digit == 0) {
        printf("%c", '_');
        return 0;
    }
    if (digit > digitcount) {
        printf("%c", '_');
        return 0;
    }
    int thenum = 1;
    for (int i = 0; i < digitcount - (digit-1); i++){
        thenum *= 10;
    }
    int digitwewant = prod % thenum;

    tempprod = digitwewant;
    digitcount = 0;
    while (tempprod > 0) {
        if (digitwewant != tempprod) {
            digitwewant/=10;
        }
        tempprod /=10;
        digitcount++;
    }
    printf("%d", digitwewant);
}