UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212011#3815. 种树Aaron1004ms1200kbC++111.1kb2024-10-13 10:08:042024-10-13 12:54:49

answer

#include<bits/stdc++.h>
//#include<windows.h>
using namespace std;
typedef long long ll;
typedef unsigned long long sll;
const int mod=1e9+7,INF=0x3f3f3f3f;
const long double pie=acos(-1);
#define dist(x1,y1,x2,y2) sqrt( ((x1)-(x2))*((x1)-(x2) + ((y1)-(y2))*((y1)-(y2) ) )
//#define KEY_DOWN(VK_NONAME)((GetAsyncKeyState(VK_NONAME)& 0x8000)? 1:0)
inline int AC()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    return x*f;
}
int vis[19][19],d[5][2]={{0,0},{0,1},{1,0},{0,-1},{-1,0}},n,m,fac[6]={1,1,2,6,24,120};
int dfs(int x,int y,int k){
	if(k==1)
		return 1;
	int sum=0;
	for(int i=0;i<5;i++)
		vis[x+d[i][0]][y+d[i][1]]++;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(!vis[i][j]){
				
				sum+=dfs(i,j,k-1);
				
			}
		}
	}
	for(int i=0;i<5;i++)
		vis[x+d[i][0]][y+d[i][1]]--;
	return sum;
}
signed main(){
	int k;
	cin>>n>>m>>k;
	int sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			sum+=dfs(i,j,k);
//			cout<<sum<<endl;
		}
	}
	cout<<sum/fac[k];
    return 0;
} 


详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1196kb

input:

2 2 1

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 10
Accepted
time: 0ms
memory: 1200kb

input:

2 3 2

output:

8

result:

ok 1 number(s): "8"

Test #3:

score: 10
Accepted
time: 0ms
memory: 1200kb

input:

4 4 2

output:

96

result:

ok 1 number(s): "96"

Test #4:

score: 10
Accepted
time: 2ms
memory: 1200kb

input:

4 4 5

output:

304

result:

ok 1 number(s): "304"

Test #5:

score: 10
Accepted
time: 1ms
memory: 1196kb

input:

3 4 3

output:

84

result:

ok 1 number(s): "84"

Test #6:

score: 10
Accepted
time: 0ms
memory: 1196kb

input:

3 5 2

output:

83

result:

ok 1 number(s): "83"

Test #7:

score: 10
Accepted
time: 0ms
memory: 1196kb

input:

3 5 3

output:

215

result:

ok 1 number(s): "215"

Test #8:

score: 10
Accepted
time: 0ms
memory: 1200kb

input:

3 5 4

output:

276

result:

ok 1 number(s): "276"

Test #9:

score: 10
Accepted
time: 1ms
memory: 1196kb

input:

3 5 5

output:

174

result:

ok 1 number(s): "174"

Test #10:

score: 10
Accepted
time: 0ms
memory: 1200kb

input:

4 3 5

output:

18

result:

ok 1 number(s): "18"

Extra Test:

score: 0
Extra Test Passed