合工大OJ-1267 Function

由于代码没能足够优化,运行超时,很遗憾不能AC。

Description


有一个函数f(a,b,c),其定义如下:




Input


多组测试数据,

每组占一行,包括三个整数,a,b,c。


Output


对于每组数据输出f(a,b,c) mod 10000007的值,每组输出占一行。


Sample Input


2 2 2
1 1 1
-1 2 3
55 2 3
55 2 -3

Sample Output


134792
85195
2
1
2


#include <cmath>

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int num[100][100][100];
int f(int a,int b,int c) {
if(a<10||b<10||c<10) {
if(a>0&&b>0&&c>0&&a<100&&b<100&&c<100)
num[a][b][c]=2;
return 2;

if(a>60||b>60||c>60) {
if(a>0&&b>0&&c>0&&a<100&&b<100&&c<100)
num[a][b][c]=1;
return 1;
}
if(num[a][b][c]!=0){
return num[a][b][c];
}
if(num[a+1][b+2][c+3]!=0&&num[a-3][b-2][c-1]!=0){
num[a][b][c]=num[a+1][b+2][c+3]+num[a-3][b-2][c-1];
}
return f(a+1,b+2,c+3)+f(a-3,b-2,c-1);

}
int main() {
int a=0,b=0,c=0,m=0,n=0;
while(~scanf("%d %d %d",&a,&b,&c)) {
memset(num,0,sizeof(num));
cout<<f(a+10,b+10,c+10)%10000007<<endl;
}
return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值