QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#619497 | #9255. Python Program | wuzihan# | AC ✓ | 11ms | 3764kb | C++20 | 3.5kb | 2024-10-07 14:26:50 | 2024-10-07 14:26:50 |
Judging History
answer
#include <bits/stdc++.h>
#define N 1005
#define int long long
// #define x first
// #define y second
// #define endl '\n'
#pragma GCC optimize(2)
using namespace std;
int s,s1,s2,len,ans,num[N];
string st,str[2][N];
signed main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
cin>>st;
cin>>st>>str[0][0]>>st>>st;
len=st.size();
for(int i=0;i<len;i++)
{
if(st[i]=='('||st[i]==',')
{
int j=i+1;
s1++;
while(st[j]!=','&&st[j]!=')') str[0][s1]+=st[j],j++;
i=j-1;
}
}
cin>>st>>str[1][0]>>st>>st;
len=st.size();
for(int i=0;i<len;i++)
{
if(st[i]=='('||st[i]==',')
{
int j=i+1;
s2++;
while(st[j]!=','&&st[j]!=')') str[1][s2]+=st[j],j++;
i=j-1;
}
}
for(int i=1;i<=s1;i++)
{
int len1=str[0][i].size();
for(int j=0;j<len1;j++)
if(str[0][i][j]!='-') num[i]=num[i]*10+str[0][i][j]-'0';
else s=1;
}
if(s1<3) num[3]=1;
// cout<<num[1]<<" "<<num[2]<<" "<<num[3]<<endl;
// cout<<str[1][3]<<endl;
if(!s)
for(int i=num[1];i<num[2];i+=num[3])
{
int l=0,r=0,p=0;
s=0;
if(str[1][1]==str[0][0]) l=i;
else
{
int len1=str[1][1].size();
for(int j=0;j<len1;j++) l=l*10+str[1][1][j]-'0';
}
if(str[1][2]==str[0][0]) r=i;
else
{
int len1=str[1][2].size();
for(int j=0;j<len1;j++) r=r*10+str[1][2][j]-'0';
}
if(s2<3) p=1;
else
if(str[1][3]==str[0][0]) p=i;
else
{
int len1=str[1][3].size();
for(int j=0;j<len1;j++)
if(str[1][3][j]!='-') p=p*10+str[1][3][j]-'0';
else s=1;
}
// cout<<l<<" "<<r<<" "<<p<<endl;
if(!s)
if(l<r)
{
r=(r-l-1)/p*p+l;
ans+=(l+r)*((r-l)/p+1)/2;
}
if(s)
if(l>r)
{
swap(l,r);
l=r-(r-l-1)/p*p;
// cout<<l<<" "<<r<<" "<<p<<endl;
ans+=(l+r)*((r-l)/p+1)/2;
}
}
else
for(int i=num[1];i>num[2];i-=num[3])
{
int l=0,r=0,p=0;
s=0;
if(str[1][1]==str[0][0]) l=i;
else
{
int len1=str[1][1].size();
for(int j=0;j<len1;j++) l=l*10+str[1][1][j]-'0';
}
if(str[1][2]==str[0][0]) r=i;
else
{
int len1=str[1][2].size();
for(int j=0;j<len1;j++) r=r*10+str[1][2][j]-'0';
}
if(s2<3) p=1;
else
if(str[1][3]==str[0][0]) p=i;
else
{
int len1=str[1][3].size();
for(int j=0;j<len1;j++)
if(str[1][3][j]!='-') p=p*10+str[1][3][j]-'0';
else s=1;
}
if(!s)
if(l<r)
{
r=(r-l-1)/p*p+l;
ans+=(l+r)*((r-l)/p+1)/2;
}
if(s)
if(l>r)
{
swap(l,r);
l=r-(r-l-1)/p*p;
ans+=(l+r)*((r-l)/p+1)/2;
}
}
cin>>st>>st;
cout<<ans;
return 0;
}
/*
ans=0
for a in range(1,3):
for b in range(5,1,-2):
ans+=b
print(ans)
ans=0
for q in range(50,100):
for i in range(q,77,20):
ans+=i
print(ans)
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
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: 3708kb
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: 9ms
memory: 3636kb
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: 3696kb
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: 11ms
memory: 3764kb
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