QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#674433 | #9255. Python Program | woodie_0064# | WA | 4ms | 3616kb | C++20 | 1.7kb | 2024-10-25 15:44:17 | 2024-10-25 15:44:17 |
Judging History
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'