void solve() {
// Code
int n;
cin >> n;
double S = n*n*(1.0-PI/4);
int k;
cin >> k;
printf("%.6f\n", S*(2.0-pow(0.5, k-1)));
}
void solve() {
// Code
int n;
cin >> n;
double S = n*n*(1.0-PI/4);
int k;
cin >> k;
printf("%.6f\n", S*(2.0-pow(0.5, k-1)));
}
用这个 M_PI
//#include
//#include
//#include
//using namespace std;
int main()
{
int n;
cin >> n;
int i;
for(i = 0; i < n; i++){
double len;
int cnt;
cin >> len >> cnt;
int j;
double area = 0;
for(j = 0; j < cnt; j++){
area = len * len - M_PI * (len/2) * (len/2) + area;
len = sqrt(len * len / 2);
}
cout << “case #” << i << “:” << endl;
cout << fixed << setprecision(6) << area << endl;
}
return 0;
}
使用
acos(-1.0)