CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:Katajisto
Submission time:2017-10-06 20:15:33 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp:1:20: fatal error: stdafx.h: No such file or directory
 #include "stdafx.h"
                    ^
compilation terminated.

Code

#include "stdafx.h"
#include <stdint.h>
#include <iostream>
#include <vector>
using namespace std;
int calc(uint64_t i)
{
	uint64_t     digits = 1U;
	uint64_t     value = 1U;
	uint64_t     limit = 9U;
	unsigned int tens;
	i--;
	while (i / limit >= digits) {
		const uint64_t old_limit = limit;
		i -= digits * limit;
		digits++;
		value *= 10U;
		limit *= 10U;
		if (limit <= old_limit)
			break;
	}
	value += i / digits;
	value /= pow(10,(digits - 1) - (i % digits));
	return value % 10U;
}
int main()
{
	vector<long long> queryvector = {};
	long long int query;
	cin >> query;
	for (long int i = 0; i < query; i++)
	{
		long long int q;
		cin >> q;
		queryvector.push_back(q);
	}
	for (long long kysely : queryvector)
	{
		cout << calc(kysely) << endl;
	}
	main();
}