QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#550009#9255. Python Programucup-team3695#AC ✓0ms3600kbC++201.4kb2024-09-07 08:49:562024-09-07 08:49:57

Judging History

你现在查看的是测评时间为 2024-09-07 08:49:57 的历史记录

  • [2024-09-07 08:53:29]
  • 管理员手动重测本题所有提交记录
  • 测评结果:AC
  • 用时:4ms
  • 内存:3604kb
  • [2024-09-07 08:49:57]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3600kb
  • [2024-09-07 08:49:56]
  • 提交

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'