竞选全谷最正确的代码(

· · 休闲·娱乐

竞选失败……

题目编号:P1021

啊,怎么在讨论区发个表都能被删啊,不管了,转移到文章吧。

(以上为转移到文章时新增的内容)

其实就是打表。

#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
const int s[20][20][20]=
{
{
{1},
{1,2},
{1,2,3},
{1,2,3,4},
{1,2,3,4,5},
{1,2,3,4,5,6},
{1,2,3,4,5,6,7},
{1,2,3,4,5,6,7,8},
{1,2,3,4,5,6,7,8,9},
{1,2,3,4,5,6,7,8,9,10},
{1,2,3,4,5,6,7,8,9,10,11},
{1,2,3,4,5,6,7,8,9,10,11,12},
{1,2,3,4,5,6,7,8,9,10,11,12,13},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14}
},
{
{1},
{1,2},
{1,3,4},
{1,3,5,6},
{1,3,5,7,8},
{1,2,5,8,9,10},
{1,2,5,8,11,12,13},
{1,2,5,8,11,14,15,16},
{1,3,4,9,11,16,17,19,20},
{1,2,3,7,11,15,19,21,22,24},
{1,2,3,7,11,15,19,23,25,26,28},
{1,3,4,9,11,16,21,23,28,29,31,32},
{1,3,4,9,11,16,20,25,27,32,33,35,36}
},
{
{1},
{1,3},
{1,4,5},
{1,4,7,8},
{1,4,6,14,15},
{1,3,7,9,19,24},
{1,4,5,15,18,27,34},
{1,3,6,10,24,26,39,41},
{1,3,8,9,14,32,36,51,53},
{1,2,6,8,19,28,40,43,91,103},
{1,2,3,8,11,26,38,56,69,85,89},
{1,3,8,13,15,16,49,53,84,88,108,114}
},
{
{1},
{1,3},
{1,5,8},
{1,3,11,18},
{1,3,11,15,32},
{1,4,9,16,38,49},
{1,4,9,24,35,49,51},
{1,3,8,19,33,39,92,102},
{1,4,10,11,28,33,78,118,143},
{1,4,9,24,26,42,104,115,174,185},
{1,4,9,20,34,52,62,137,149,229,242}
},
{
{1},
{1,4},
{1,6,7},
{1,4,12,21},
{1,4,9,31,51},
{1,4,13,24,56,61},
{1,4,13,24,30,87,106},
{1,6,8,33,48,77,183,236},
{1,4,13,18,51,92,163,208,223},
{1,6,8,21,60,93,104,154,378,414}
},
{
{1},
{1,4},
{1,7,12},
{1,4,19,33},
{1,7,12,43,52},
{1,7,11,48,83,115},
{1,4,18,31,104,145,170},
{1,5,18,29,97,170,219,308},
{1,6,10,32,77,114,284,447,471}
},
{
{1},
{1,5},
{1,8,13},
{1,5,24,37},
{1,8,11,64,102},
{1,7,12,64,113,193},
{1,7,18,62,104,244,259},
{1,4,17,31,117,209,513,550}
},
{
{1},
{1,5},
{1,9,14},
{1,6,25,65},
{1,9,15,78,115},
{1,9,14,65,170,297},
{1,6,28,47,127,412,602}
},
{
{1},
{1,6},
{1,9,20},
{1,5,34,60},
{1,9,23,108,181},
{1,6,31,48,256,373}
},
{
{1},
{1,6},
{1,10,26},
{1,6,41,67},
{1,8,27,119,194}
},
{
{1},
{1,7},
{1,9,30},
{1,7,48,85}
},
{
{1},
{1,7},
{1,11,37}
},
{
{1},
{1,8}
},
{
{1}
}
},
t[20][20]=
{
{1,2,3,4,5,6,7,8,9,10,11,12,13,14},
{2,4,8,12,16,20,26,32,40,46,54,64,72},
{3,7,15,24,36,52,70,93,121,154,186,225},
{4,10,26,44,70,108,162,228,310,422,550},
{5,14,35,71,126,211,336,524,726,1016},
{6,18,52,114,216,388,638,1007,1545},
{7,23,69,165,345,664,1137,1911},
{8,28,89,234,512,1045,2001},
{9,34,112,326,797,1617},
{10,40,146,427,1055},
{11,47,172,547},
{12,54,212},
{13,62},
{14}
};
int n,k,i;
main()
{
    scanf("%d%d",&n,&k);
    for(i=1;i<=k;i++)
    printf("%d ",s[n-1][k-1][i-1]);
    printf("\nMAX=%d",t[n-1][k-1]);
}

以上表全部来源于论文,供参考。