Code Submission Evaluation System Login

Datatähti 2018 alku

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

Tasks | Messages | Scoreboard | Statistics


CSES - Datatähti 2018 alku - Results
History
2017-10-09 19:56:39100
2017-10-03 14:13:530
2017-10-03 14:02:040
2017-10-03 13:43:430
2017-10-03 13:42:310
2017-10-03 13:33:090
2017-10-03 13:09:390
2017-10-03 11:04:090
2017-10-03 11:03:020
2017-10-03 11:00:240
2017-10-03 10:58:260
2017-10-03 10:56:130
2017-10-03 09:28:460
2017-10-03 09:28:440
2017-10-03 09:25:200
2017-10-03 09:25:190
2017-10-03 09:23:130
Task:Kyselyt
Sender:Shrike
Submission time:2017-10-09 19:56:39
Language:C++
Status:READY
Score:100

Feedback

groupverdictscore
#1ACCEPTED12
#2ACCEPTED25
#3ACCEPTED63

Test results

testverdicttime (s)group
#1ACCEPTED0.05 / 1.001details
#2ACCEPTED0.05 / 1.002details
#3ACCEPTED0.04 / 1.003details

Compiler report

input/code.cpp:30:5: warning: integer constant is so large that it is unsigned [enabled by default]
     10000000000000000000
     ^
input/code.cpp:31:1: warning: narrowing conversion of '10000000000000000000I128' from '__int128' to 'const ll {aka const long long int}' inside { } [-Wnarrowing]
 };
 ^
input/code.cpp: In function 'll dig(ll)':
input/code.cpp:39:5: warning: unused variable 'tens' [-Wunused-variable]
  ll tens;
     ^

Code

#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cstdlib>

using namespace std;
typedef long long ll;

const ll pow_10[20] = {
    1,
    10,
    100,
    1000,
    10000,
    100000,
    1000000,
    10000000,
    100000000,
    1000000000,
    10000000000,
    100000000000,
    1000000000000,
    10000000000000,
    100000000000000,
    1000000000000000,
    10000000000000000,
    100000000000000000,
    1000000000000000000,
    10000000000000000000
};

ll
dig(ll i)
{
	ll     digits = 1U;
	ll     value  = 1U;
	ll     limit  = 9U;
	ll tens;
	if (!i--)
		return 0;
	while (i/limit >= digits) {
		const ll old_limit = limit;

		i -= digits * limit;

		digits++;
		value *= 10U;
		limit *= 10U;

		/* If limit overflows, we are in the correct, final region. */
		if (limit <= old_limit)
			break;
	}

	value += i / digits;
	value /= pow_10[(digits - 1) - (i % digits)];


	return value % 10U;
}

int
main(int argc, char **argv)
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int q;
	cin >> q;
	ll qs[q];
	for (int i = 0; i < q; i++)
		cin >> qs[i];
	for (int i = 0; i < q; i++)
		cout << dig(qs[i]) << "\n";
	return 0;
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

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
0
1
7
7
6
1
5
4
7
6
2
2
2
2
8
2
1
3
1
8
...
view   save

Test 2

Group: 2

Verdict: ACCEPTED

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
1
2
3
2
2
8
7
9
8
3
7
1
9
8
4
3
1
9
9
6
...
view   save

Test 3

Group: 3

Verdict: ACCEPTED

input
1000
672274832941907421
260504693279721732
646999966092970935
100853063389774434
469646937576313460
292789544562527987
202678876957048242
921044261294332160
293497307441838185
889420403130803486
887773296767104352
272588988734184089
900854413164191389
306838570888252671
321818592757748092
632312861733842235
590425060048634753
921705179835679834
711775852688052272
...
view   save

correct output
7
2
2
0
9
7
7
2
0
4
0
3
0
5
9
9
3
1
2
7
...
view   save

user output
7
2
2
0
9
7
7
2
0
4
0
3
0
5
9
9
3
1
2
7
...
view   save