QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#674433#9255. Python Programwoodie_0064#WA 4ms3616kbC++201.7kb2024-10-25 15:44:172024-10-25 15:44:17

Judging History

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

  • [2024-10-25 15:44:17]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3616kb
  • [2024-10-25 15:44:17]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;
string s;

void work(){
	ll a,b,c,d,e,f;
	string s;getline(cin,s);
	getline(cin,s);
	bool f1 = false,f2 = false,f3 = false;
	
	auto trans = [&] () {
		auto p = s.find('(');
		p += 1;
		int rem = s.size() - p;
		s = s.substr(p,rem - 2);
	};
	
	auto toInt = [&] (string s,ll &x,bool &flag) {
		if(s.size() == 0) x = 1;
		else if(islower(s[0])) flag = true;
		else {
			x = 0;
			int now = 1;
			for(int i = 0;i < s.size();i++) {
				if(s[i] == '-') now = -1;
				else x = x * 10 + s[i] - '0';
			}
			x *= now;
		}
	};
	
	auto calc = [&] (ll &x,ll &y,ll &z,string s) {
		auto p = s.find(',');
		x = y = z = 0;
		toInt(s.substr(0,p),x,f1);
		s = s.substr(p + 1,s.size() - (p + 1));
		p = s.find(',');
		toInt(s.substr(0,p),y,f2);
		if(p == s.npos) {
			z = 1;
		}else {
			s = s.substr(p + 1,s.size() - (p + 1));
			toInt(s,z,f3);
		}
	};
	trans();
	calc(a,b,c,s);
	getline(cin,s);
	trans();
	calc(d,e,f,s);
	ll ans = 0;
	for(;;a += c) {
		if(c > 0 && a >= b) break;
		if(c < 0 && a <= b) break;
		if(f1) d = a;
		if(f2) e = a;
		if(f3) f = a;
		ll sz = (abs(e - d) + abs(f) - 1) / abs(f);
		if(f > 0 && d >= e) sz = 0;
		if(f < 0 && d <= e) sz = 0;
//		cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << ' ' << sz << ' ';
		ans += sz * ((d + d + f * (sz - 1)) / 2);
//		cout << ans << '\n';
	}
	cout << ans << '\n';
	getline(cin,s);
	getline(cin,s);	
}
	

int main(){
//	freopen("test.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
//	cin >> T;
//	while(T--){
		work();
//	}	
	return 0;
}

详细

Test #1:

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

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

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: -100
Wrong Answer
time: 4ms
memory: 3600kb

input:

ans=0
for i in range(1,1000000):
    for j in range(i,1,-1):
        ans+=j
print(ans)

output:

166666541665750001

result:

wrong answer 1st lines differ - expected: '166666666665500001', found: '166666541665750001'