Digits Sequence (Easy Edition)(int->string)

 

Let's write all the positive integer numbers one after another from 11 without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...

Your task is to print the kk-th digit of this sequence.

Input

The first and only line contains integer kk (1≤k≤100001≤k≤10000) — the position to process (11-based index).

Output

Print the kk-th digit of the resulting infinite sequence.

Examples

input

7

output

7

input

21

output

5

 

1.to_string();

 

c++11标准增加了全局函数std::to_string:

string to_string (int val);

string to_string (long val);

string to_string (long long val);

string to_string (unsigned val);

string to_string (unsigned long val);

string to_string (unsigned long long val);

string to_string (float val);

string to_string (double val);

string to_string (long double val);

代码示例:(使用编译器vs2013)

#include<iostream>
#include <string>   //std::string,std::string
#include<stdlib.h>
using namespace std;
int main()
{
	int num;
	string  str;
	cin >> num;
	str = to_string(num);
	cout << str;
	system("pause");
	return 0;
}

那么对于本题而言,for循环遍历,把出现的每一个数字转化为sting类型,然后再加入到sting变量中,就OK了。

 

#include<algorithm>
#include<iostream>
#include<string.h>
#include<cstdio>
#include<string>
#include<stdlib.h>
#define  P pair<long long,long long>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);//加速输入输出流
    string num="";
    int numm;
    cin>>numm;
    for(int i=1;i<=numm;++i)
    {
        num+=to_string(i);
    }
    cout<<num[numm-1]<<endl;
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值