QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#765218 | #9255. Python Program | 1903331632 | AC ✓ | 40ms | 3856kb | C++23 | 2.3kb | 2024-11-20 13:10:37 | 2024-11-20 13:10:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(s) s.begin(), s.end()
#define int long long
#define endl '\n'
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int q;
vector<int> is_p;
bool is[N];
void solve()
{
string s;
cin >> s >> s >> s >> s >> s;
string t1, t2, t3;
int it1 = s.find("(");
int it2 = s.find(",");
int it3 = s.rfind(",");
t1 = s.substr(it1 + 1, it2 - it1 - 1);
if (it2 != it3)
{
t2 = s.substr(it2 + 1, it3 - it2 - 1);
t3 = s.substr(it3 + 1, s.find(")") - it3 - 1);
}
else
{
t2 = s.substr(it2 + 1, s.find(")") - it2 - 1);
t3 = "1";
}
cin >> s;
cin >> s;
string b = s;
cin >> s;
cin >> s;
string q1, q2, q3;
it1 = s.find("(");
it2 = s.find(",");
it3 = s.rfind(",");
q1 = s.substr(it1 + 1, it2 - it1 - 1);
if (it2 != it3)
{
q2 = s.substr(it2 + 1, it3 - it2 - 1);
q3 = s.substr(it3 + 1, s.find(")") - it3 - 1);
}
else
{
q2 = s.substr(it2 + 1, s.find(")") - it2 - 1);
q3 = "1";
}
// cout << t1 << ' ' << t2 << ' ' << t3 << endl;
// cout << b << endl;
// cout << q1 << ' ' << q2 << ' ' << q3 << endl;
cin >> s;
char o = s[5];
cin >> s;
int x1 = stoll(t1), x2 = stoll(t2), x3 = stoll(t3);
int res = 0;
for (int i = x1; ((x3 > 0) ? (i < x2) : (i > x2)); i += x3)
{
int y1 = (isalpha(q1[0]) ? (i) : (stoll(q1)));
int y2 = (isalpha(q2[0]) ? (i) : (stoll(q2)));
int y3 = (isalpha(q3[0]) ? (i) : (stoll(q3)));
if (y3 > 0)
{
if (y1 < y2)
{
int k = (y2 - y1 - 1) / y3;
res += ((y1 + k * y3) + y1) * (k + 1) / 2;
// cout << y1 << ' ' << y2 << ' ' << y3 << ' ' << k << endl;
}
}
else
{
if (y1 > y2)
{
int k = (y1 - y2 - 1) / -y3;
res += (y1 + k * y3 + y1) * (k + 1) / 2;
}
}
}
cout << res << endl;
}
signed main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
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: 3840kb
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: 32ms
memory: 3816kb
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: 3856kb
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: 40ms
memory: 3844kb
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