QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#593036 | #9255. Python Program | rgnerdplayer | AC ✓ | 39ms | 3832kb | C++20 | 1.6kb | 2024-09-27 11:13:23 | 2024-09-27 11:13:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
auto solve = [&]() {
auto get = [&](string s) {
s.pop_back();
s.pop_back();
s = s.substr(6);
string a, b, c;
int i = s.find(',');
a = s.substr(0, i);
s = s.substr(i + 1);
int j = s.find(',');
if (j != -1) {
b = s.substr(0, j);
c = s.substr(j + 1);
} else {
b = s;
c = "1";
}
// cerr << a << ' ' << b << ' ' << c << '\n';
return tuple(a, b, c);
};
string s;
cin >> s >> s >> s >> s >> s;
auto [a, b, c] = get(s);
cin >> s >> s >> s >> s;
auto [d, e, f] = get(s);
i64 ans = 0;
int xa = stoi(a), xb = stoi(b), xc = stoi(c);
for (int i = xa; xc > 0 ? i < xb : i > xb; i += xc) {
int xd = isalpha(d[0]) ? i : stoi(d);
int xe = isalpha(e[0]) ? i : stoi(e);
int xf = isalpha(f[0]) ? i : stoi(f);
if (xf > 0 && xd < xe) {
int cnt = (xe - xd - 1) / xf;
ans += 1LL * (cnt + 1) * (xd + xd + cnt * xf) / 2;
}
if (xf < 0 && xd > xe) {
int cnt = (xd - xe - 1) / -xf;
ans += 1LL * (cnt + 1) * (xd + xd + cnt * xf) / 2;
}
}
cout << ans << '\n';
};
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3800kb
input:
ans=0 for a in range(1,3): for b in range(5,1,-2): ans+=b print(ans)
output:
16
result:
ok single line: '16'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
ans=0 for q in range(100,50,-1): for i in range(q,77,20): ans+=i print(ans)
output:
2092
result:
ok single line: '2092'
Test #3:
score: 0
Accepted
time: 30ms
memory: 3824kb
input:
ans=0 for i in range(1,1000000): for j in range(i,1,-1): ans+=j print(ans)
output:
166666666665500001
result:
ok single line: '166666666665500001'
Test #4:
score: 0
Accepted
time: 9ms
memory: 3832kb
input:
ans=0 for i in range(31,321983,2): for j in range(313,382193): ans+=j print(ans)
output:
11756963404587200
result:
ok single line: '11756963404587200'
Test #5:
score: 0
Accepted
time: 39ms
memory: 3824kb
input:
ans=0 for i in range(1,1000000): for j in range(i,114514,-1): ans+=j print(ans)
output:
160610445975856765
result:
ok single line: '160610445975856765'
Extra Test:
score: 0
Extra Test Passed