救救我,最后一点TLE了!

P2415 集合求和

我的代码: ```cpp #include <bits/stdc++.h> using namespace std; long long n; long long cnt; long long s[30005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); while (cin >> n) { s[++cnt] = n; } long long ans = 0; for (int i = 1; i <= cnt; i++) { ans += s[i]; } ans *= (1 << cnt - 1); cout << ans << endl; return 0; } ```
by coool @ 2023-08-25 11:19:31


|