# DatatÃ¤hti 2018 alku

 Start: 2017-10-02 00:00:00 End: 2017-10-16 00:00:00

CSES - DatatÃ¤hti 2018 alku - Results
History
2017-10-15 23:42:080
2017-10-15 23:20:56
2017-10-15 23:19:47
2017-10-15 23:13:010
2017-10-15 23:11:300
2017-10-15 23:08:400
2017-10-15 23:07:450
2017-10-15 22:29:000
2017-10-15 22:16:380
 Task: Kyselyt Sender: koneistitLiikaa Submission time: 2017-10-15 23:42:08 Language: C++ Status: READY Score: 0

## Test results

 test verdict time (s) group #1 WRONG ANSWER 0.06 / 1.00 1 details #2 WRONG ANSWER 0.06 / 1.00 2 details #3 WRONG ANSWER 0.05 / 1.00 3 details

## Code

```#include <iostream>
#include <string>
using namespace std;

typedef long long ll;

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

int f_ugly(ll n) {
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;
}
if (n < 10) {
return n;
}

int c = 0;									// n of digits sorta
for (int i{0}; i<MAGICAL_CONSTANT; i++) {
if (s[i] < n) {
c++;
}
}
ll f = s[c-1];								// count of numDIGITSbers smaller than
//	int d = to_string(n).length();				// n of digits
ll r = p(10,c);

//	cout << c << endl;
//	cout << r << endl;
ll temp = n-f;					// much doff
//	cout << temp << endl;
ll m = temp%(c+1);				// digits already built
r += temp/(c+1);				// number we are building
//	cout << r << endl;
if (m == 0) {
r -= 1;
}
//	cout << c << " " << m << endl;
//		cout << r << endl;
ll sauli = p(10,c-m);
//		cout << sauli << endl;
r /= sauli;

//		cout << r << endl;
r %= 10;

return r;

//	cout << f << endl;
//	cout << m << endl;							// digit of tha number
//	cout << m << endl;
//	cout << n << " " << c;
}

int main() {

//	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;
//	cout << f_ugly(n);

for (int i=0; i<100; i++) {
cout << f_ugly(i);
}
return 0;
}
```

## Test details

### Test 1

Group: 1

input
```1000 582 214 723 273 480 280 237 204 134 210 565 640 784 508 846 532 465 952 205 ...```
view   save

correct output
```0 1 7 7 6 1 5 4 7 6 2 2 2 2 8 2 1 3 1 8 ...```
view   save

user output
`012345678901112131415161718191...`
view   save

### Test 2

Group: 2

input
```1000 615664 916441 627600 279508 126605 944125 25887 440405 352957 206746 951305 821686 716797 333476 430123 167570 619834 411383 459670 ...```
view   save

correct output
```1 2 3 2 2 8 7 9 8 3 7 1 9 8 4 3 1 9 9 6 ...```
view   save

user output
`012345678901112131415161718191...`
view   save

### Test 3

Group: 3

```1000 672274832941907421 260504693279721732 646999966092970935 100853063389774434 469646937576313460 292789544562527987 202678876957048242 921044261294332160 293497307441838185 889420403130803486 887773296767104352 272588988734184089 900854413164191389 306838570888252671 321818592757748092 632312861733842235 590425060048634753 921705179835679834 711775852688052272 ...```
```7 2 2 0 9 7 7 2 0 4 0 3 0 5 9 9 3 1 2 7 ...```
`012345678901112131415161718191...`