[COCI2014-2015#7] JANJE:
题目大意:
题目有点长,链接。
思路:
简单组合题,初赛内容。
代码:
inline ll Read()
{
ll x = 0, f = 1;
char c = getchar();
while (c != '-' && (c < '0' || c > '9')) c = getchar();
if (c == '-') f = -f, c = getchar();
while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
return x * f;
}
int n, m;
ll c, x, y;
ll Ans[10] = {0, 1572864-6, 96, 24-6, 24576-6, 12, 6, 96, 1073741826ll-6};
int main()
{
n = Read(), m = Read();
if (m == 1) {puts("0"); return 0;}
x = m * (m - 1) * (m - 2) / 6;
x *= Ans[n];
switch (n)
{
case 1: y = 2; break;
case 3: y = 2; break;
case 4: y = 2; break;
case 8: y = 2; break;
default: y = 0;
}
y *= m * (m - 1) / 2;
printf ("%lld
", x + y);
return 0;
}