However, Sakura is a very naughty girl, so she just randomly uses the tool for
For each test case, there is only one line, with three integers
It is guaranteed that
2 3 3 1 4 4 2
Case #1: 4 Case #2: 8HintThe precise answer in the first test case is about 3.56790123.
题目大意
给定一个
解题思路
就是对于每一个格子,求其
然而对于每一个格子来说,求
左部分:
右部分:
上部分:
下部分:
再减去重复的部分:
左上:
右上:
左下:
左下:
所以我们得到总的没有被涂色的面积为
代码
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <map>
using namespace std;
typedef long long LL;
const int MAXN = 1e6+5;
const double PI = acos(-1);
const double eps = 1e-8;
const LL MOD = 1e9+7;
int main(){
//freopen("C:/Users/yaonie/Desktop/in.txt", "r", stdin);
//freopen("C:/Users/yaonie/Desktop/out.txt", "w", stdout);
int T; scanf("%d",&T);
for(int cas=1; cas<=T; cas++){
LL n, m, k; scanf("%lld%lld%lld",&n,&m,&k);
double ans = 0;
LL t = n*n*m*m;
for(LL i=1; i<=n; i++){
for(LL j=1; j<=m; j++){
LL tmp = (j-1)*(j-1)*n*n-(i-1)*(i-1)*(j-1)*(j-1);
tmp += ((m-j)*(m-j)*n*n-(i-1)*(i-1)*(m-j)*(m-j));
tmp += ((i-1)*(i-1)*m*m-(n-i)*(n-i)*(j-1)*(j-1));
tmp += ((n-i)*(n-i)*m*m-(n-i)*(n-i)*(m-j)*(m-j));
double sum = 1;
double a = 1.0*tmp/t;
LL b = k;
while(b){
if(b&1) sum=sum*a;
b>>=1;
a=a*a;
}
ans += 1-sum;
}
}
printf("Case #%d: %.0f\n",cas, ans);
}
return 0;
}