CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:koneistitLiikaa
Submission time:2017-10-15 22:16:38 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.06 s1details
#20.07 s2details
#30.06 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:41:5: warning: unused variable 'm' [-Wunused-variable]
  ll m = (n-f)%(c+1);
     ^

Code

#include <iostream>
using namespace std;

typedef long long ll;

ll p(int n, int x) {
	return x == 0 ? 1 : n*p(n, x-1);
}

int main() {
	int const MAGICAL_CONSTANT = 17;
	ll t[MAGICAL_CONSTANT];
	ll s[MAGICAL_CONSTANT];
	ll a = 0;
	for (int i{0}; i<MAGICAL_CONSTANT; i++) {
		t[i] = p(10, i) * 9 * (i+1);
		a += t[i];
		s[i] = a;
	}

//	for (int i{0}; i<MAGICAL_CONSTANT; i++) {
//		cout << t[i] << endl;
//	}
//	for (int i{0}; i<MAGICAL_CONSTANT; i++) {
//		cout << s[i] << endl;
//	}

	ll n;
	cin >> n;

	int c = 0;
	for (int i{0}; i<MAGICAL_CONSTANT; i++) {
		if (s[i] < n) {
			c++;
		}
	}
	ll f = s[c-1];
//	cout << f << endl;
	ll r = p(10,c) + (n-f)/(c+1);
	ll m = (n-f)%(c+1);
	cout << ((r % p(10,c)) / p(10,(4-c)%4)) << endl;
//	cout << r << endl;
//	cout << m << endl;
//	cout << n << " " << c;
	return 0;
}

Test details

Test 1

Group: 1

Verdict:

input
1000
582
214
723
273
...

correct output
0
1
7
7
6
...

user output
0

Test 2

Group: 2

Verdict:

input
1000
615664
916441
627600
279508
...

correct output
1
2
3
2
2
...

user output
0

Test 3

Group: 3

Verdict:

input
1000
672274832941907421
260504693279721732
646999966092970935
100853063389774434
...

correct output
7
2
2
0
9
...

user output
0