Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Life of Decimals

By TarifEzaz · Limits 1s, 512 MB

Given any circle, if you divide the circumference of that circle with its diameter, you would always find the same constant value of pi. This constant is so famous that we even have a day dedicated, just to this constant! So in this problem, we would like to tease you with the fascinating properties of pi. Let’s see if you can code and give us the first few digits of pi after the decimal places.

To help you with the job, we are providing you a C code that would print up to the first 12 digits of pi after the decimal places. But hey, you should not trust everything that you see on the internet.

#include <stdio.h>
#include <math.h>

int main() {
	double val = 2 * acos(0.0);
	printf("%.12lf\n",val);
	return 0; 
}

Input

The first line contains an integer T (1 ≤ T ≤ 100), the number of testcases. Each of the following T lines will have a single integer N (1 ≤ N ≤ 12), the position of the decimal digit you need to print.

Output

For each testcase, print a number on a line by itself, the digit of pi in a given position.

Sample

InputOutput
3	
1
2
3
1
4
1


Discussion
Statistics

95% Solution Ratio

protapEarliest, Mar '17

AnikcsejnuFastest, 0.0s

SIR.24Lightest, 0 B

FahimSifnatulShortest, 65B

Submit

Login to submit