QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#698551 | #9255. Python Program | SDNUyuqi# | AC ✓ | 4ms | 3636kb | C++23 | 3.1kb | 2024-11-01 20:25:01 | 2024-11-01 20:25:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
const int N=100;
string s[N];
int main()
{
for(int i=1;i<=5;i++)
{
getline(cin,s[i]);
}
//2
int l,r;
l=s[2].find('f');
l=s[2].find(' ',l);
r=s[2].find(' ',l+1);
string A=s[2].substr(l+1,r-l-1);
l=s[3].find('f');
l=s[3].find(' ',l);
r=s[3].find(' ',l+1);
string B=s[3].substr(l+1,r-l-1);
l=s[2].find('(');
r=s[2].find(')');
string a,b,c;
ll aa,bb,cc;
l=s[2].find('(');
r=s[2].find(',',l+1);
a=s[2].substr(l+1,r-l-1);
l=r;
r=s[2].find(',',l+1);
if(r==string::npos)
{
r=s[2].find(')',l+1);
b=s[2].substr(l+1,r-l-1);
c="1";
}
else
{
b=s[2].substr(l+1,r-l-1);
l=r;
r=s[2].find(')',l+1);
c=s[2].substr(l+1,r-l-1);
}
string d,e,f;
l=s[3].find('(');
r=s[3].find(',',l+1);
d=s[3].substr(l+1,r-l-1);
l=r;
r=s[3].find(',',l+1);
if(r==string::npos)
{
r=s[3].find(')',l+1);
e=s[3].substr(l+1,r-l-1);
f="1";
}
else
{
e=s[3].substr(l+1,r-l-1);
l=r;
r=s[3].find(')',l+1);
f=s[3].substr(l+1,r-l-1);
}
ll dd,ee,ff;
if(a==A)
{
aa=1e18;
}
else
{
aa=stoi(a);
}
if(b==A)
{
bb=1e18;
}
else
{
bb=stoi(b);
}
if(c==A)
{
cc=1e18;
}
else
{
cc=stoi(c);
}
if(d==A)
{
dd=1e18;
}
else
{
dd=stoi(d);
}
if(e==A)
{
ee=1e18;
}
else
{
ee=stoi(e);
}
if(f==A)
{
ff=1e18;
}
else
{
ff=stoi(f);
}
ll an=0;
if(cc>0)
{
for(int i=aa,x,y,z;i<bb;i+=cc)
{
if(dd==1e18)
{
x=i;
}
else
{
x=dd;
}
if(ee==1e18)
{
y=i;
}
else
{
y=ee;
}
if(ff==1e18)
{
z=i;
}
else z=ff;
if(z>0&&x>=y)
{
continue;
}
if(z<0&&x<=y)
{
continue;
}
ll su=(abs(y-x)-1)/abs(z);
ll be=x,en=x+su*z;
an+=(be+en)*(su+1)/2;
}
}
else
{
for(int i=aa,x,y,z;i>bb;i+=cc)
{
if(dd==1e18)
{
x=i;
}
else
{
x=dd;
}
if(ee==1e18)
{
y=i;
}
else{
y=ee;
}
if(ff==1e18)
{
z=i;
}
else z=ff;
if(z>0&&x>=y)
{
continue;
}
if(z<0&&x<=y)
{
continue;
}
ll su=(abs(y-x)-1)/abs(z);
ll be=x,en=x+su*z;
an+=(be+en)*(su+1)/2;
}
}
cout<<an<<endl;
//system("pause");
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
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: 3572kb
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: 3588kb
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: 3604kb
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: 3520kb
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