2
4 2
5 10
输出
64
2496
**题意:**求在一个半径r的圆内整点上放置n个人,使得两两距离和最大。
题解:
0.Codeforces 460E (Round #262) 原题你最大
1.Dp, f[i,j,k]表示选i个点,横坐标总和为j,纵坐标总和为k时各点间距离平方和最大值
请允许我激情乱搞一会
代码:
#include
#include
using namespace std;
int n, r;
int ans[9][31] = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 4, 16, 36, 64, 100, 144, 196, 256, 324, 400, 484, 576, 676, 784, 900, 1024, 1156, 1296, 1444, 1600, 1764, 1936, 2116, 2304, 2500, 2704, 2916, 3136, 3364, 3600},
{0, 8, 32, 76, 130, 224, 312, 416, 554, 722, 896, 1064, 1248, 1512, 1746, 2016, 2264, 2600, 2888, 3218, 3584, 3912, 4344, 4712, 5138, 5612, 6062, 6536, 6984, 7520, 8084},
{0, 16, 64, 144, 256, 400, 576, 784, 1024, 1296, 1600, 1936, 2304, 2704, 3136, 3600, 4096, 4624, 5184, 5776, 6400, 7056, 7744, 8464, 9216, 10000, 10816, 11664, 12544, 13456, 14400},
{0, 24, 96, 218, 384, 624, 880, 1188, 1572, 2014, 2496, 2984, 3520, 4224, 4870, 5616, 6336, 7224, 8056, 9008, 9984, 10942, 12080, 13144, 14326, 15624, 16896, 18184, 19488, 20968, 22480},
{0, 36, 144, 324, 576, 900, 1296, 1764, 2304, 2916, 3600, 4356, 5184, 6084, 7056, 8100, 9216, 10404, 11664, 12996, 14400, 15876, 17424, 19044, 20736, 22500, 24336, 26244, 28224, 30276, 32400},
{0, 48, 192, 432, 768, 1224, 1740, 2356, 3102, 3954, 4896, 5872, 6960, 8280, 9564, 11016, 12456, 14160, 15816, 17666, 19584, 21500, 23688, 25808, 28122, 30624, 33120, 35664, 38266, 41200, 44076},
{0, 64, 256, 576, 1024, 1600, 2304, 3136, 4096, 5184, 6400, 7744, 9216, 10816, 12544, 14400, 16384, 18496, 20736, 23104, 25600, 28224, 30976, 33856, 36864, 40000, 43264, 46656, 50176, 53824, 57600}
};
int main() {
int T;
scanf("%d", &T);
while(T--) {
scanf("%d%d", &n, &r);
printf("%d\n", ans[n][r]);
}
}
起初队友写出的时候我看了一下,之后我吐了…