QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#552817#9255. Python Programucup-team2000#AC ✓4ms3948kbC++201020b2024-09-08 02:45:522024-09-08 02:45:52

Judging History

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

  • [2024-09-08 02:45:52]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3948kb
  • [2024-09-08 02:45:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
	cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);

	int x;
	scanf("ans=%d\n", &x);
	char out_var;
	int a,b;
	scanf("for %c in range(%d, %d ", &out_var, &a,&b);
	int c;
	if (!scanf(" , %d ", &c)) c=1;
	scanf(" ): ");
	string d(50, 0),e(50, 0);
	char doesnt_matter;
	scanf(" for %c in range(%[^,], %[^,)] ", &doesnt_matter,d.data(),e.data());
	string f(50, 0);
	if (!scanf(" , %[^)]", f.data())) f="1";

	int di = d[0]==out_var ? INT_MIN : stoi(d);
	int ei = e[0]==out_var ? INT_MIN : stoi(e);
	int fi = f[0]==out_var ? INT_MIN : stoi(f);

	ll out=0;
	for (ll i=a; (c>0 && i<b) || (c<0 && i>b); i+=c) {
		int ff = fi==INT_MIN ? i : fi;
		int diff = (ei==INT_MIN ? i : ei)-(di==INT_MIN ? i : di);
		if (signbit(diff) != signbit(ff)) continue;
		int d2 = abs(diff);
		if (d2==0) continue;
		ll y = (d2-1)/abs(ff);
		out+=(y+1) * (2ll*(di==INT_MIN ? i : di) + 1ll*ff*y)/2;
	}

	cout<<out<<"\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 4ms
memory: 3704kb

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

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

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