QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#550723#9255. Python Programucup-team4770#AC ✓3ms3696kbC++141.7kb2024-09-07 14:03:362024-09-07 14:03:36

Judging History

你现在查看的是最新测评结果

  • [2024-09-07 14:03:36]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3696kb
  • [2024-09-07 14:03:36]
  • 提交

answer

#include <bits/stdc++.h>
#define PR(x) printf(x ? "YES\n" : "NO\n")
#define pr(x) printf(x ? "Yes\n" : "No\n")
#define mk make_pair
#define pb emplace_back
#define fi first
#define se second
#define pii pair<int, int>
#define fore(i, u, v) for (int i = h[u], v = e[i].v; i; v = e[i = e[i].nxt].v)
#define all(x) x.begin(), x.end()
#define int long long

using namespace std;

string s;

bool is(char x) { return isdigit(x) || x == '-'; }
int trans() {
	int r = 0, fl = 1;
	for (char c : s) 
		if (is(c)) {
			if (c == '-') fl *= -1;
			else r = r * 10 + c - '0';
		}
		else break;
	return fl * r;
}

void po() { s.erase(s.begin()); }

signed main() {
	
	getline(cin, s);
	int ans = 0;
	getline(cin, s);
	char i = s[4];
	while (!is(s[0])) po();
	int a = trans();
	while (is(s[0])) po();
	while (!is(s[0])) po();
	int b = trans();
	while (is(s[0])) po();
	while (!s.empty() && !is(s[0])) po();
	int c = s.empty() ? 1 : trans();
	
	getline(cin, s);
	while (s[0] != '(') po(); po();
	bool f1 = 0, f2 = 0, f3 = 0;
	int d, e, f;
	if (s[0] == i) f1 = 1; else d = trans();
	while (is(s[0])) po();
	while (!is(s[0])) po();
	if (s[0] == i) f2 = 1; else e = trans();
	while (is(s[0])) po();
	if (s[0] != ',') f = 1;
	else if (s[1] != i) po(), f = trans();
	else f3 = 1;

	getline(cin, s);
	getline(cin, s);

	int D = d, E = e, F = f;

	for (int i = a; c > 0 ? i < b : i > b; i += c) {
		d = f1 ? i : D;
		e = f2 ? i - 1 : E;
		f = f3 ? i : F;
		
		int fl = 1;

		if (f < 0) d = -d, e = -e, f = -f, fl = -1;
		if (d >= e) continue;
		
		int ed = (e - d - 1) / f;
		ans += fl * (2 * d + ed * f) * (ed + 1) / 2;
	}

	cout << ans;

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3696kb

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: 3648kb

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: 3ms
memory: 3656kb

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: 3640kb

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: 3ms
memory: 3636kb

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