QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#765200 | #9255. Python Program | yudiao_vicky | WA | 3ms | 3812kb | C++11 | 2.4kb | 2024-11-20 13:04:11 | 2024-11-20 13:04:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int a[N];
int f[(1 << 20) + 1];
int mask = 1 << 18;
vector<int> x, y;
void solve()
{
string a;
cin >> a;
cin >> a;
cin >> a;
cin >> a;
cin >> a;
int p = 0;
int f=1;
for (int i = 6; i < a.size(); i++)
{
if (a[i] >= '0' && a[i] <= '9')
{
p = p * 10 + a[i]-'0';
}
else if(a[i]=='-'){
f=-1;
}
else if(a[i] == ',' || a[i] == ')')
{
x.push_back(p*f);
f=1;
p = 0;
}
}
cin >> a;
cin >> a;
cin >> a;
cin >> a;
f=1;
int ff = 0;
for (int i = 6; i < a.size(); i++)
{
if (a[i] >= '0' && a[i] <= '9')
{
p = p * 10 + a[i]-'0';
ff=0;
}
else if(a[i]=='-'){
f=-1;
ff=0;
}
else if ((a[i] == ',' || a[i] == ')') && !ff)
{
y.push_back(p*f);
p = 0;
}
else if((a[i]>='a' && a[i]<='z') || (a[i]>='A' && a[i]<='Z'))
{
y.push_back(-1e9);
ff=1;
}
}
int res = 0;
if(x.size()!=3) x.push_back(1);
if(y.size()!=3) y.push_back(1);
// for(int i=0; i<x.size(); i++){
// cout << x[i]<<" "<<y[i]<<endl;
// }
if(x[2]>0){
int d=y[0],e=y[1],f=y[2];
for(int i=x[0];i<x[1];i+=x[2]){
if(y[0]==-1e9) d = i;
if(y[1]==-1e9) e = i;
if(y[2]==-1e9) f = i;
if(f>0 && e<=d) continue;
int t = (e-d)/f;
if(t*f+d == y[1]) t--;
res+=(d+t*f+d)*(t+1)/2;
}
}
else {
int d=y[0],e=y[1],f=y[2];
for(int i=x[0];i>x[1];i+=x[2]){
if(y[0]==-1e9) d = i;
if(y[1]==-1e9) e = i;
if(y[2]==-1e9) f = i;
if(f>0 && e<=d) continue;
// cout << d << " " << e << " " << f << endl;
int t = (e-d)/f;
if(t*f+d == y[1]) t--;
// cout << (d+t*f+d)*(t+1)/2 << endl;
res+=(d+t*f+d)*(t+1)/2;
}
}
cout <<res <<endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
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: 3556kb
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: 3ms
memory: 3812kb
input:
ans=0 for i in range(1,1000000): for j in range(i,1,-1): ans+=j print(ans)
output:
1182719329
result:
wrong answer 1st lines differ - expected: '166666666665500001', found: '1182719329'