

Ví dụ về cách giải nén số 20352035 như sau: có 22 số 00, có 33 số 55, vậy khi giải nén số 20352035 ta được số 0055500555.
Cho một số tự nhiên NN có số lượng chữ số là chẵn. Giải nén số NN được số SS. Hãy tìm chữ số thứ KK của số SS tính từ trái sang phải.
Input
Output
Example
Test 1
Input2035 4Output5Note
scratch.
Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
`#`Ý tường bài toán
Số N là các cặp số chẵn được chia thành các cặp số liên tiếp:
`(a_1, b_1) , (a_2, b_2), ... , (a_n, b_n)`
Ghép các đoạn lại theo thứ tự ⇒ `S`
Duyệt số `S` tự trái sang phải ⇒ `K`
(Ràng buộc `N` $\le$ `1818` chữ số)
_____________________________________________________________________________________________
Test 1:
Input
2035 4
Output
5
Tách thành từng cặp chữ số:
`20` và `35`
`20 → 0 2 lần → 00`
`35 → 5 3 lần → 555`
`S = 00555, vì k = 4 ⇒ s = 5`
_____________________________________________________________________________________________
`@` Code C++
#pragma GCC optimize("O2")
#pragma GCC target("avx,avx2,fma")
//----------HamDeck----------
//----------Huuuu------
#include <bits/stdc++.h>
using namespace std;
//-----------Define---------------
#define __File(name) \
if (fopen(name ".inp", "r")) \
freopen(name ".inp", "r", stdin), freopen(name ".out", "w", stdout)
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define el cout << '\n'
#define ll long long
#define db double
#define ull unsigned long long
#define st string
#define big __int128
#define gcd(a, b) abs(__gcd(a, b))
#define lcm(a, b) abs((a) * (b) / gcd(a, b))
#define fix(a, b) fixed << setprecision(a) << (b)
#define all(x) (x).begin(), (x).end()
#define all1(x) (x) + (1), (x) + (n) + (1)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rep1(i, a, b) for (int i = a; i <= b; i++)
#define out(x) \
{ \
for (int i = 1; i <= (n); ++i) \
cout << x[i] << ' '; \
el; \
}
#define pb push_back
#define pob pop_back()
#define fi first
#define se second
//----------Constant-------------
int main()
{
// freopen("phucdepzai02.inp", "r", stdin);
// freopen("phucdepzai02.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
string n;
cin >> n;
ll k;
cin >> k;
int dem = n.size();
for (int i = 0; i < dem; i += 2)
{
int cap = n[i] - '0';
char chuso = n[i + 1];
if (k > cap)
{
k -= cap;
}
else
{
cout << chuso;
el;
return 0;
}
}
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin