QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#550009 | #9255. Python Program | ucup-team3695# | AC ✓ | 0ms | 3600kb | C++20 | 1.4kb | 2024-09-07 08:49:56 | 2024-09-07 08:49:57 |
Judging History
answer
#include <algorithm>
#include <iostream>
#include <limits>
#include <string>
long long g(long long d, long long e, long long f)
{
if (f < 0)
{
return -g(-d, -e, -f);
}
long long k = (std::max(0ll, e - d) + f - 1) / f;
return d * k + f * k * (k - 1) / 2;
}
int main()
{
std::string I;
long long a, b, c, d, e, f;
std::string ln;
std::getline(std::cin, ln);
std::getline(std::cin, ln);
size_t x1 = 15, y1 = ln.find(',') + 1, z1 = ln.find(',', y1) + 1;
I = ln.substr(4, 1);
std::string A = ln.substr(x1, y1 - 1 - x1);
std::string B = ln.substr(y1, z1 - 1 - y1);
std::string C = z1 == std::string::npos + 1 ? "1" : ln.substr(z1, ln.size() - 2 - z1);
std::getline(std::cin, ln);
size_t x2 = 19, y2 = ln.find(',') + 1, z2 = ln.find(',', y2) + 1;
std::string D = ln.substr(x2, y2 - 1 - x2);
std::string E = ln.substr(y2, z2 - 1 - y2);
std::string F = z2 == std::string::npos + 1 ? "1" : ln.substr(z2, ln.size() - 2 - z2);
a = std::stoll(A);
b = std::stoll(B);
c = std::stoll(C);
long long i = std::numeric_limits<long long>::max();
d = D == I ? i : std::stoll(D);
e = E == I ? i : std::stoll(E);
f = F == I ? i : std::stoll(F);
long long ans = 0;
for (long long ii = a; c > 0 ? ii < b : ii > b; ii += c)
{
ans += g(d == i ? ii : d, e == i ? ii : e, f == i ? ii : f);
}
std::cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3600kb
input:
ans=0 for a in range(1,3): for b in range(5,1,-2): ans+=b print(ans)
output:
16
result:
wrong answer 1st lines differ - expected: '6', found: '16'