CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:Katajisto
Submission time:2017-10-06 20:29:36 +0300
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED25
#3ACCEPTED63
Test results
testverdicttimegroup
#1ACCEPTED0.05 s1details
#2ACCEPTED0.06 s2details
#3ACCEPTED0.05 s3details

Code

#include <stdint.h>
#include <iostream>
#include <vector>
using namespace std;
const uint64_t kerto[20] = { UINT64_C(1), UINT64_C(10), UINT64_C(100), UINT64_C(1000), UINT64_C(10000), UINT64_C(100000), UINT64_C(1000000), UINT64_C(10000000), UINT64_C(100000000), UINT64_C(1000000000), UINT64_C(10000000000), UINT64_C(100000000000), UINT64_C(1000000000000),UINT64_C(10000000000000), UINT64_C(100000000000000), UINT64_C(1000000000000000), UINT64_C(10000000000000000), UINT64_C(100000000000000000), UINT64_C(1000000000000000000), UINT64_C(10000000000000000000) };
int calc(uint64_t i)
{
	uint64_t     nums = 1U;
	uint64_t     arvo = 1U;
	uint64_t     limit = 9U;
	i--;
	while (i / limit >= nums) {
		const uint64_t vlimit = limit;
		i -= nums * limit;
		nums++;
		arvo *= 10U;
		limit *= 10U;
		if (limit <= vlimit)
			break;
	}
	arvo += i / nums;
	arvo /= kerto[(nums - 1) - (i % nums)];
	return arvo % 10U;
}
int main()
{
	vector<long long> queryvector = {};
	long long int query;
	cin >> query;
	for (long int i = 0; i < query; i++)
	{
		long long int q;
		cin >> q;
		queryvector.push_back(q);
	}
	for (long long kysely : queryvector)
	{
		cout << calc(kysely) << endl;
	}
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
1000
582
214
723
273
...

correct output
0
1
7
7
6
...

user output
0
1
7
7
6
...
Truncated

Test 2

Group: 2

Verdict: ACCEPTED

input
1000
615664
916441
627600
279508
...

correct output
1
2
3
2
2
...

user output
1
2
3
2
2
...
Truncated

Test 3

Group: 3

Verdict: ACCEPTED

input
1000
672274832941907421
260504693279721732
646999966092970935
100853063389774434
...

correct output
7
2
2
0
9
...

user output
7
2
2
0
9
...
Truncated