Problem Statement
The number pi to the 100100-th decimal place is
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
You are given an integer N between 11 and 100100, inclusive.
Print the value of pi to the N-th decimal place.
More precisely, truncate the value of pi to N decimal places and print the result without removing the trailing 0
s.
Constraints
- 1≤N≤100
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Print the value of pi to the N-th decimal place in a single line.
Sample Input
2
Sample Output
3.14
题目大意:给定一个精确到小数点后100位的pi值和一个整数N,按要求输入整数N并精确地输出小数点后第N位的pi值。
思路:将以上pi值当作字符串来解。
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int main() {
string pi = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679";
int i = 0;
int n = 0;
cin >> n;
for (i = 0; i <= n + 1; i++) {
cout << pi[i];
}
return 0;
}