UVa 11028 Sum of Product:A0077732014-07-07 synapse7 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1969算了前几个发现是A007773还给出了个公式:当n>=7, a(n) = (n^3-16n+27)/6 (n是奇数); (n^3-16n+30)/6 (n是偶数).(这谁看的出来!)完整代码:
01./*0.012s*/02.03.#include<cstdio>04.const int a[] = {0, 1, 1, 1, 3, 8, 21, 43, 69, 102, 145, 197, 261, 336, 425, 527, 645, 778, 929, 1097, 1285};05.06.int main()07.{08.int n, cas = 0;09.while (scanf("%d", &n), n)10.printf("Case #%d: %d
", ++cas, a[n]);11.return 0;12.}