版本比较
贪心
正文
增加 1 行删除 1 行
239 行未改动全部展开240241242243244244245246247248175 行未改动全部展开239 行未改动全部展开 else { int p = n / __gcd(n,k); if (ans[p] == 0) { for (int j = 1;j <= n;j += p) { for (int l = 0;l < p - 2;l++) for (int l = 0;l < p - 2;l++) res += a[j + l] * a[j + l + 2]; res += a[j] * a[j + 1] + a[j + p - 1] * a[j + p - 2]; } ans[p] = res;175 行未改动全部展开