QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#626966 | #9255. Python Program | sunyuheng365# | AC ✓ | 55ms | 3856kb | C++14 | 2.4kb | 2024-10-10 14:15:30 | 2024-10-10 14:15:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n'
#define int long long
string s[11];
int change(string str)
{
int flg = 1, val = 0;
for (auto ch : str)
{
if (ch == '-')
flg = -flg;
else if (ch >= '0' && ch <= '9')
val = val * 10 + ch - '0';
}
return val * flg;
}
void solve()
{
for (int i = 0; i < 11; i++)
cin >> s[i];
string Iname = s[2];
vector<string> cut4;
s[4].pop_back(), s[4].pop_back(), s[4] += ',';
string cur;
for (int i = 6; i < s[4].size(); i++)
{
if (s[4][i] == ',')
{
cut4.push_back(cur);
cur.clear();
}
else
cur += s[4][i];
}
if (cut4.size() == 2)
cut4.push_back("1");
int a = change(cut4[0]), b = change(cut4[1]), c = change(cut4[2]);
vector<string> cut8;
s[8].pop_back(), s[8].pop_back(), s[8] += ',';
for (int i = 6; i < s[8].size(); i++)
{
if (s[8][i] == ',')
{
cut8.push_back(cur);
cur.clear();
}
else
cur += s[8][i];
}
if (cut8.size() == 2)
cut8.push_back("1");
bool Id = (cut8[0] == Iname), Ie = (cut8[1] == Iname), If = (cut8[2] == Iname);
int d, e, f;
if (!Id)
d = change(cut8[0]);
if (!Ie)
e = change(cut8[1]);
if (!If)
f = change(cut8[2]);
auto work = [&](int l, int r, int d) -> ll
{
int bot = 0, top = 1e6, ans = -1;
while (bot <= top)
{
int mid = ((bot + top) >> 1);
int val = l + mid * d;
if ((d > 0 ? val < r : val > r))
ans = mid, bot = mid + 1;
else
top = mid - 1;
}
if (ans == -1)
return 0;
return (ans + 1) * l + (1 + ans) * ans / 2 * d;
};
ll ans = 0;
for (int i = a; (c > 0 ? i < b : i > b); i += c)
{
int startj = (Id ? i : d);
int endj = (Ie ? i : e);
int step = (If ? i : f);
ans += work(startj, endj, step);
}
std::cout << ans << endl;
}
signed main()
{
#ifndef sunyuheng365
ios::sync_with_stdio(false);
#endif
int tc = 1;
// cin >> tc;
while (tc--)
solve();
#ifdef sunyuheng365
system("pause");
#endif
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 3588kb
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: 55ms
memory: 3844kb
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: 4ms
memory: 3648kb
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: 52ms
memory: 3856kb
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