2 条题解

  • 1
    @ 2025-1-16 9:58:22
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int n;
    	double pi = 0.0;
    	cin >> n;
    	for (int i = 1; i <= n; i++){
    		if (i % 2 != 0)
    			pi = pi + 4.0 * 1 / (2 * i - 1);
    		else
    			pi = pi - 4.0 * 1 / (2 * i - 1);
    	} 
    	cout << fixed << setprecision(6) << pi;
    	return 0;
    }
    

    信息

    ID
    41
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    (无)
    递交数
    239
    已通过
    81
    上传者