# Life of Decimals

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 values of pi after the decimal places.

This is a companion discussion topic for the original entry at https://toph.co/p/life-of-decimals
1 Like

What’s wrong here?
@touhidur @hjr265

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

int main() {
char str ={'1', '4', '1', '5', '9', '2', '6', '5', '3', '5', '9', '0'};
int a, i, b;
scanf("%d", &a);
for(i=0; i<a; i++)
{
scanf("%d", &b);
printf("%c\n", str[b-1]);
}
return 0;
}
``````

The first 15 digit of pi 14159265358979

1 Like

@mahfuzAhmed Read the problem again. Why 15 digits?

I didn’t say you need 15 digits. I gave those to check your digits in the `char str` array.

Thanks my bro. Solved it.

27 Test Cases !!!   I don’t think that number of test-cases does matter.

The c code given formats the number so it prints 0141592653590 instead of correct 0141592653589. Change it.

Can anyone tell me what is wrong?

I’m attaching the code here:

Code
``````def multi_input(num):
l = []
for i in range(num):
u = int(input())
l.append(u)

return l

pi2 = list(str(14159265358979))

a = int(input())
n = multi_input(a)

for i in n:
ii = i - 1
print(int(pi2[ii]))
``````

@abdullahibn200 You have to print one output at a time. For example, after getting first input print the result 1. Then take the second input and print the result 4. New solvers often get into this situation.

1 Like

Thanks a lot for helping, @imamanik05.

@abdullahibn200 You can also test your submission as samples by clicking Test before submitting.