Submission

Status:

PP--PPPP-P

Subtask/Task Score:

70/100

Score: 70

User: SnowAveNode

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

Language: cpp

Time: 0.003 second

Submitted On: 2025-09-19 17:42:41

#include<bits/stdc++.h>
using namespace std;

static string to_string_i128(__int128 x){
    if (x == 0) return "0";
    bool neg = x < 0; if(neg) x = -x;
    string s;
    while (x){ s.push_back(char('0' + int(x % 10))); x /= 10; }
    if (neg) s.push_back('-');
    reverse(s.begin(), s.end());
    return s;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    long long a, b, x; 
    cin >> a >> b >> x;

    __int128 prod = (__int128)a * (__int128)b;
    string s = to_string_i128(prod);
    if (x>=1 && x <= (long long)s.size()) cout << s[x-1] << endl;
    else cout << endl;
}