QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#710166 | #9255. Python Program | wysun | AC ✓ | 42ms | 3604kb | C++14 | 1.6kb | 2024-11-04 18:56:00 | 2024-11-04 18:56:00 |
Judging History
answer
#include <iostream>
using namespace std;
typedef long long LL;
int main()
{
string s;
cin >> s;
cin >> s;
cin >> s;
cin >> s;
cin >> s;
string a, b, c, d, e, f;
int i;
s = s.substr(6);
s = s.substr(0, s.find(')'));
i = s.find(',');
a = s.substr(0, i);
s = s.substr(i + 1);
i = s.find(',');
if (i == -1)
{
b = s;
c = "1";
}
else
{
b = s.substr(0, i);
c = s.substr(i + 1);
}
cin >> s;
cin >> s;
cin >> s;
cin >> s;
s = s.substr(6);
s = s.substr(0, s.find(')'));
i = s.find(',');
d = s.substr(0, i);
s = s.substr(i + 1);
i = s.find(',');
if (i == -1)
{
e = s;
f = "1";
}
else
{
e = s.substr(0, i);
f = s.substr(i + 1);
}
cin >> s;
cin >> s;
LL ans = 0;
int va = stoi(a);
int vb = stoi(b);
int vc = stoi(c);
for (int i = va; (vc > 0 ? i < vb : i > vb); i += vc)
{
int vd = isalpha(d[0]) ? i : stoi(d);
int ve = isalpha(e[0]) ? i : stoi(e);
int vf = isalpha(f[0]) ? i : stoi(f);
if (vf > 0) {
if (vd < ve) {
LL k = (ve - vd - 1) / vf;
ans += 1LL * (vd + vd + k * vf) * (k + 1) / 2;
}
} else {
if (vd > ve) {
LL k = (vd - ve - 1) / -vf;
ans += 1LL * (vd + vd + k * vf) * (k + 1) / 2;
}
}
}
cout << ans << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
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: 3464kb
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: 33ms
memory: 3588kb
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: 3512kb
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: 42ms
memory: 3468kb
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