CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:Katajisto
Submission time:2017-10-04 21:42:45 +0300
Language:C++
Status:READY
Result:37
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED25
#30
Test results
testverdicttimegroup
#1ACCEPTED0.06 s1details
#2ACCEPTED0.06 s2details
#30.06 s3details

Compiler report

input/code.cpp: In function 'char calculate(long long int)':
input/code.cpp:27:14: warning: unused variable 'tempnum' [-Wunused-variable]
    long long tempnum = num;
              ^
input/code.cpp:16:16: warning: unused variable 'nextsub' [-Wunused-variable]
  long long int nextsub = 0;
                ^
input/code.cpp:19:12: warning: variable 'nums' set but not used [-Wunused-but-set-variable]
  long long nums;
            ^

Code

#include <vector>
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <stdlib.h>
#include <random>
using namespace std;
long long int taken = 1;
int originalnum;
char calculate(long long int query)
{
	//b++;
	long long int i = 1;
	long long int num = query;
	long long int nextsub = 0;
	long long int sub = 1;
	long long int region = 1;
	long long nums;
	if (num <= 9)
	{
	}
	else
	{
		while (sub != 144000000000000000)
		{
			long long tempnum = num;
			sub = i * 9 * pow(10, i - 1);
			if (num - sub > 0)
			{
				num = num - sub;
				region++;
			}
			else
			{
				//cout << "nada" << endl;
			}
			//cout << "NUM: " << num << ", SUB: " << sub << endl;
			i++;
		}
	}
	//cout << "REGION: " << region << " NUMS: " << region * 9 * pow(10, region - 1) << endl;
	nums = region * 9 * pow(10, region - 1);
	long long calc = (num - 1) / region + pow(10, region - 1);
	//cout << "CALCULATION: " << calc << endl;
	string result = to_string(calc);
	long long pos = (num - 1) % region;
	//cout << "POS: "<< pos << endl;
	return result[pos];
}
int main()
{
	long int q;
	cin >> q;
	vector<long long int> queries = {};
	for(long int t = 1; t <= q; t++)
	{
		long long int query;
			cin >> query;
			queries.push_back(query);
	}
	for (long long int query : queries)
	{
		cout << calculate(query) << 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:

input
1000
672274832941907421
260504693279721732
646999966092970935
100853063389774434
...

correct output
7
2
2
0
9
...

user output
7
2
2
0
9
...
Truncated