QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#809200 | #9255. Python Program | Hiraethsoul# | AC ✓ | 6ms | 3784kb | C++23 | 5.7kb | 2024-12-11 13:12:56 | 2024-12-11 13:12:56 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
signed main()
{
std::ios::sync_with_stdio(0);
std::cin.tie(0);
std::string a, b, c, d, e;
getline(std::cin, a);
getline(std::cin, b);
getline(std::cin, c);
getline(std::cin, d);
getline(std::cin, e);
int cnt = 0;
while (a[cnt] == ' ')
{
++cnt;
}
a = a.substr(cnt);
cnt = 0;
while (b[cnt] == ' ')
{
++cnt;
}
b = b.substr(cnt);
cnt = 0;
while (c[cnt] == ' ')
{
++cnt;
}
c = c.substr(cnt);
cnt = 0;
while (d[cnt] == ' ')
{
++cnt;
}
d = d.substr(cnt);
cnt = 0;
while (e[cnt] == ' ')
{
++cnt;
}
e = e.substr(cnt);
int A, B, C, D, E, F;
int pos = 15;
int now = 0;
while (isdigit(b[pos]))
{
now = now * 10 + b[pos] - '0';
++pos;
}
A = now;
now = 0;
++pos;
while (isdigit(b[pos]))
{
now = now * 10 + b[pos] - '0';
++pos;
}
B = now;
now = 0;
++pos;
if (b[pos] == '-')
{
++pos;
while (isdigit(b[pos]))
{
now = now * 10 + b[pos] - '0';
++pos;
}
C = -now;
}
else if (isdigit(b[pos]))
{
while (isdigit(b[pos]))
{
now = now * 10 + b[pos] - '0';
++pos;
}
C = now;
}
else
{
C = 1;
}
pos = 15;
now = 0;
while (isdigit(c[pos]))
{
now = now * 10 + c[pos] - '0';
++pos;
}
D = now;
if (pos == 15)
{
D = 1e18;
++pos;
}
now = 0;
++pos;
int cur = pos;
while (isdigit(c[pos]))
{
now = now * 10 + c[pos] - '0';
++pos;
}
E = now;
if (pos == cur)
{
E = 1e18;
++pos;
}
now = 0;
++pos;
if (c[pos] == '-')
{
++pos;
while (isdigit(c[pos]))
{
now = now * 10 + c[pos] - '0';
++pos;
}
F = -now;
}
else if (isdigit(c[pos]))
{
while (isdigit(c[pos]))
{
now = now * 10 + c[pos] - '0';
++pos;
}
F = now;
} //????????????
else if (islower(c[pos]))
{
F = 1e18;
}
else
{
F = 1;
}
if (C < 0)
{
A -= C;
B -= C;
std::swap(A, B);
C = -C;
}
if (D > 2e9 and E > 2e9) // DE
{
std::cout << 0 << '\n';
return 0;
}
if (D > 2e9 and F > 2e9)
{
int ans = 0;
for (int i = A; i < B; i += C)
{
int inf = (E - 1) / i;
if (i < E)
{
ans += (1 + inf) * inf / 2 * i;
}
}
std::cout << ans << '\n';
return 0;
}
if (F > 2e9 and E > 2e9)
{
int ans = 0;
for (int i = A; i < B; i += C)
{
if (D < i)
{
ans += D;
}
}
std::cout << ans << '\n';
return 0;
}
if (F > 2e9)
{
int ans = 0;
for (int i = A; i < B; i += C)
{
int inf = std::max((E - D - 1) / i, 0ll);
if (D < E)
{
ans += (D + D + (inf)*i) * (inf + 1) / 2;
}
}
std::cout << ans << '\n';
return 0;
}
else
{
if (D > 2e9)
{
int ans = 0;
for (int i = A; i < B; i += C)
{
if (F > 0)
{
int inf = std::max((E - i - 1) / F, 0ll);
if (i < E)
{
ans += (i + i + inf * F) * (inf + 1) / 2;
}
}
else
{
int inf = (E - i + 1) / F;
if (i > E)
{
ans += (i + i + inf * F) * (inf + 1) / 2;
}
}
// i->E 每次+F
}
std::cout << ans << '\n';
return 0;
}
else if (E > 2e9)
{
int ans = 0;
for (int i = A; i < B; i += C)
{
if (F > 0)
{
int inf = std::max((i - D - 1) / F, 0ll);
if (D < i)
{
ans += (D + D + inf * F) * (inf + 1) / 2;
}
}
else
{
int inf = (i + 1 - D) / F;
if (D > i)
{
ans += (D + D + inf * F) * (inf + 1) / 2;
}
}
// D->i 每次+F
}
std::cout << ans << '\n';
return 0;
}
else
{
if (F < 0)
{
D -= F;
E -= F;
std::swap(D, E);
F = -F;
}
int ans = 0;
for (int i = A; i < B; i += C)
{
int inf = std::max((E - D - 1) / F, 0ll);
if (D < E)
{
ans += (D + D + inf * F) * (inf + 1) / 2;
}
// D->i 每次+F
}
std::cout << ans << '\n';
return 0;
}
}
// 一定是正数
// 第三位是步长
// 可能有好几个1e18
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
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: 3784kb
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: 6ms
memory: 3652kb
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: 1ms
memory: 3544kb
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: 6ms
memory: 3744kb
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