很簡單,要不然壓縮程式碼,要不然體換 scanf 和 printf
第一種測試
AC (1ms, 76KB) |
main(){long long b;for(;~scanf("%lld",&b)&&b;)printf("%lld\n",b*(b+1)*(2*b+1)/6);}
第二種測試
AC (1ms, 40KB)
用 getchar_unlocked putchar_unlocked 替換 scanf 和 printf
inline long long read() {
long long n = 0, c = getchar_unlocked();
while (c < '0' || c > '9') c = getchar_unlocked();
while (c >= '0' && c <= '9') n = n * 10 + (c - '0'), c = getchar_unlocked();
return n;
}
inline void write(long long x) {
if (x > 9) write(x / 10);
putchar_unlocked(x % 10 + '0');
}
main() {
long long b;
while ((b = read()) && b) {
write(b * (b + 1) * (2 * b + 1) / 6);
putchar_unlocked('\n');
}
}