CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:Katajisto
Submission time:2017-10-04 11:54:49 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp:1:1: error: 'include' does not name a type
 include "stdafx.h"
 ^
In file included from /usr/include/c++/4.8/bits/move.h:57:0,
                 from /usr/include/c++/4.8/bits/stl_pair.h:59,
                 from /usr/include/c++/4.8/bits/stl_algobase.h:64,
                 from /usr/include/c++/4.8/vector:60,
                 from input/code.cpp:2:
/usr/include/c++/4.8/type_traits:285:31: error: 'std::size_t' has not been declared
   template<typename _Tp, std::size_t _Size>
                               ^
/usr/include/c++/4.8/type_traits:419:34: error: 'nullptr_t' is not a member of 'std'
     struct __is_nullptr_t_helper<std::nullptr_t>
                                  ^
/usr/include/c++/4.8/type_traits:419:34: error: 'nullptr_t' is not a member of 'std'
/usr/include/c++/4.8/type_traits:419:48: error: template argument 1 is invalid
     struct __is_nullptr_t_helper<std::nullptr_t>
                                                ^
/usr/include/c++/4.8/type_traits:123

Code

include "stdafx.h"
#include <vector>
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <stdlib.h>
#include <random>
using namespace std;
unsigned long long int taken = 1;
int originalnum;

int main()
{
	int wait;
	int q;
	cin >> q;
	vector<unsigned long long int> queries = {};
	for (unsigned long long int t = 1; t <= q; t++)
	{
		unsigned long long int tempq;
		cin >> tempq;
		queries.push_back(tempq);
	}
	for(unsigned long long int query : queries)
	{
		unsigned long long int i = 1;
		unsigned long long int num = query;
		unsigned long long int nextsub = 0;
		unsigned long long int sub = 1;
		unsigned long long int region = 1;
		unsigned long long nums;
		if (num <= 9)
		{

		}
		else
		{
			while (num > nextsub)
			{
				unsigned long long tempnum = num;
				sub = i * 9 * pow(10, i - 1);
				nextsub = i * 9 * pow(10, i);
				if (num - sub > 0)
				{
					num = num - sub;
					region++;
				}
				else
				{
					//cout << "nada" << endl;
				}
				//cout << "NUM: " << num << ", SUB: " << sub << endl;
				i++;
			}
		}
		//cout << "REGION: " << region << " NUMS: " << region * 9 * pow(10, region - 1) << endl;
		nums = region * 9 * pow(10, region - 1);
		unsigned long long calc = (num - 1) / region + pow(10, region - 1);
		//cout << "CALCULATION: " << calc << endl;
		string result = to_string(calc);
		unsigned long long pos = (num - 1) % region;
		//cout << "POS: "<< pos << endl;
		cout << result[pos] << endl;

	}
	
}