poj 1959 Darts

dp解法暫時實現不了,暴搜實現。列出每次操作可以獲得的分數。

#include<iostream>
#include<string.h>
#include<math.h>
#include<fstream>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<vector> 
#define MAXSIZE 100
using namespace std;
int rec[63] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
            2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,
            3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,
            25,50};

int main()
{
    //freopen("data_1959.txt","r",stdin);
    int t = 0;
    scanf("%d", &t);
    int ans = 0;
    int casenum = 0;
    while(t--)
    {
        casenum++;
        int a = 0;
        ans = 0;
        scanf("%d", &a);
        for (int i = 0; i < 63; i++)
        {
            for (int j = i; j < 63; j++)
            {
                for (int k = j; k < 63; k++)
                {
                    //if ((rec[i] + rec[j] + rec[k] == a) && i!=j && i!=k && j!=k)
                    if (rec[i] + rec[j] + rec[k] == a)
                    {
                        ans++;
                    }
                }
            }
        }
        printf("Scenario #%d:\n%d\n", casenum, ans);
        printf("\n");
    }

    return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章