Submission

Status:
PPxxPPP-xP

Score: 60

User: Buktep

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

Language: c

Time: 0.003 second

Submitted On: 2024-10-16 18:12:19

#include <stdio.h> // ~10 min

int f_digit(int m, int x)
{
    int arr[100000];
    int rev[100000];
    int c = 0;

    while (m > 0)
    {
        arr[c++] = m % 10;
        m /= 10;
    }
    if (x > c)
    {
        return (-1); //Not found.
    }
    int temp = c;

    for (int i = 0; i < temp; i++)
    {
        rev[i] = arr[c--];
    }
    return (rev[x]);
}

int main()
{
    int a, b, x, d;
    int m;
    // printf("A = ");
    scanf("%d", &a);
    // printf("B = ");
    scanf("%d", &b);
    // printf("x = ");
    scanf("%d", &x);
    m = a * b;

    d = f_digit(m, x);
    if (d > -1)
    {
        printf("%d", d);
    }
    else
    {
        printf('_');
    }
    return (0);
}