0
点赞
收藏
分享

微信扫一扫

Problem - 1177B - Codeforces(模拟)

软件共享软件 2022-01-24 阅读 66
算法

Problem - 1177B - Codeforces

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define syncfalse ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll pre[20];
ll a[20];
int main(){
    syncfalse
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #endif
    a[1]=9;
    for (ll i = 2; i <= 13; ++i){
        a[i]=a[i-1]*10;
    }
    for (ll i = 1; i <= 13; ++i){
        pre[i]=pre[i-1]+a[i]*i;
    }
    ll k;
    cin>>k;
    ll len = lower_bound(pre+1, pre+14, k)-pre-1;
    k-=pre[len];
    ll wei = k/(len+1)-1;
    ll yu = k%(len+1);
    ll now = pow(10, len);
    now+=wei;
    if (yu!=0){
        now++;
        string s = to_string(now);
        cout << s[yu-1];
    }else{
        string s = to_string(now);
        cout << s[s.size()-1];
    }

    return 0;
}
举报

相关推荐

0 条评论