CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:chobbit
Submission time:2017-10-09 14:15:17 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.06 s1details
#20.06 s2details
#30.21 s3details

Code

#include <iostream>
#include <math.h>

int c(std::string x) {
	std::string::size_type sz;
	int a = (int)pow(10.0, (double)x.length() - 1.0);
	int b = std::stoi(x,&sz);
	if (b < 10) return b;
	if (b == a) { return 1; }
	if (b == (a + 1)) { return 0; }
	return b - (b/a);
}

int main() {
	int s;
	std::string out = "";
	std::string y;
	
	std::cin >> s;
	
	for (int i = 0; i < s; ++i) {
		std::cin >> y;
		int n = c(y);
		out.append(std::to_string(n));
		out.append("\n");
	}
	
	std::cout << out;
}

Test details

Test 1

Group: 1

Verdict:

input
1000
582
214
723
273
...

correct output
0
1
7
7
6
...

user output
577
212
716
271
476
...
Truncated

Test 2

Group: 2

Verdict:

input
1000
615664
916441
627600
279508
...

correct output
1
2
3
2
2
...

user output
615658
916432
627594
279506
126604
...
Truncated

Test 3

Group: 3

Verdict:

input
1000
672274832941907421
260504693279721732
646999966092970935
100853063389774434
...

correct output
7
2
2
0
9
...

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi