社区讨论
超时超时全部超时
P1464[PacNW 1999] Function参与者 9已保存回复 12
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 12 条
- 当前快照
- 1 份
- 快照标识符
- @mi7w1omu
- 此快照首次捕获于
- 2025/11/21 04:33 4 个月前
- 此快照最后确认于
- 2025/11/21 06:31 4 个月前
全部超时
求助!
C
#include<iostream>
#include<iomanip>
#include<math.h>
#include<ctime>
#include <string>
using namespace std;
struct temp
{
int tempa, tempb, tempc;
int ans;
};
int fun(int a, int b, int c)
{
if (a <= 0 || b <= 0 || c <= 0)
{
return 1;
}
else if (a > 20 || b > 20 || c > 20)
{
return fun(20, 20, 20);
}
else if (a < b&&b < c)
{
return (fun(a, b, c - 1) + fun(a, b - 1, c - 1) - fun(a, b - 1, c));
}
else
{
return (fun(a - 1, b, c) + fun(a - 1, b - 1, c) + fun(a - 1, b, c - 1) - fun(a - 1, b - 1, c - 1));
}
}
int main()
{
int tempa=0, tempb=0, tempc=0;
temp *aim = new temp[10000000];
cin >> tempa >> tempb >> tempc;
int i = 0;
if (tempa != -1 && tempb != -1 && tempc != -1)
{
aim[0].tempa = tempa;
aim[0].tempb = tempb;
aim[0].tempc = tempc;
while (aim[i].tempa != -1 && aim[i].tempb != -1 && aim[i].tempc != -1)
{
aim[i].ans = fun(aim[i].tempa, aim[i].tempb, aim[i].tempc);
i++;
cin >> aim[i].tempa >> aim[i].tempb >> aim[i].tempc;
if (i > 10)cout << "no";
}
}
//cout << i << endl;
for (int j = 0; j < i ; j++)
{
cout << "w(" << aim[j].tempa << "," << aim[j].tempb << "," << aim[j].tempc << ")=" << aim[j].ans<<endl;
}
return 0;
}
回复
共 12 条回复,欢迎继续交流。
正在加载回复...