未完成。。。
想用穷举法做,但不知道怎么排除重复的情况,如3*1+1*3+0和1*3+3*1+0是一样的。。。
牛人请帮忙
#include <iostream>
#include <string>
using namespace std;
int darts[61];
int sum=0,everysum=1;
int dartscount(int current,int times,int start)
{
for (int i=start;i>0;i--)
{
if (darts[i]>0)
{
current=current-i;
if (current==0&×>0)
{
sum+=everysum*darts[i];
}
else if (current>0&×>1)
{
everysum*=darts[i];
sum=dartscount(current,times-1,i);
everysum/=darts[i];
}
current+=i;
}
}
return sum;
}
int main()
{
memset(darts,0,sizeof(darts));
darts[25]=1;darts[50]=1;
for (int i=1;i<=60;i++)
{
if (i<=20)
darts[i]++;
if (i%2==0&&i/2<=20)
darts[i]++;
if (i%3==0&&i/3<=20)
darts[i]++;
}
int n,num,k=1;
scanf("%d",&n);
while (n>0)
{
printf("Scenario #%d:\n",k++);
scanf("%d",&num);
sum=0;everysum=1;
printf("%d\n\n",dartscount(num,3,num));
n--;
}
}