QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#617248#9255. Python Programwzxtsl#AC ✓4ms3848kbC++234.0kb2024-10-06 14:37:032024-10-06 14:37:07

Judging History

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

  • [2024-10-06 14:37:07]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3848kb
  • [2024-10-06 14:37:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define For(i,aa,a) for(int i=aa;i<=a;i++)
#define fast ios::sync_with_stdio(false),cout.tie(0),cout.tie(0)
int n,m;
int ans;
const int N=2e6+7;
const int mod=998244353;
string s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11;
void solve(){
    cin>>s1>>s2>>s3>>s4>>s5>>s6>>s7>>s8>>s9>>s10>>s11;

    int a,b,c,d,e,f;
    a=b=c=d=e=f=0;
    int flag=0;
    int fu=0;
    int cnt=0;
    string ss="";
    int num1=0x3f3f3f3f;
    int num2=0x3f3f3f3f;
    int num3=0x3f3f3f3f;
    int i,j;
    for(int i=s5.size()-1;i>=0;i--){
        if('('==s5[i]||','==s5[i]||s5[i]==')'){
            flag++;
            cnt=0;
        }
        if(flag==1){
            if((s5[i]-'0'<0||s5[i]-'9'>0)&&(s5[i]!='-')) continue;
            if(cnt==0) num3=0;
            if(s5[i]!='-') num3+=(s5[i]-'0')*pow(10,cnt),cnt++;
            else if(s5[i]=='-') num3=num3*(-1);
        }else if(flag==2){
            if((s5[i]-'0'<0||s5[i]-'9'>0)&&(s5[i]!='-')) continue;
            if(cnt==0) num2=0;
            if(s5[i]!='-') num2+=(s5[i]-'0')*pow(10,cnt),cnt++;
            else num2=num2*(-1);
        }else if(flag==3){
            if((s5[i]-'0'<0||s5[i]-'9'>0)&&(s5[i]!='-')) continue;
            if(cnt==0) num1=0;
            if(s5[i]!='-') num1+=(s5[i]-'0')*pow(10,cnt),cnt++;
            else num1=num1*(-1);
        }
    }
    //cout<<num1<<"!"<<num2<<"!"<<num3<<endl;
    if(flag==3){
        a=num2,b=num3;c=1;
    }else{
        a=num1,b=num2,c=num3;
        if(num3==0) c=1;
    }
    //cout<<a<<"!"<<b<<"!"<<c<<endl;
    num1=0x3f3f3f3f;
    num2=0x3f3f3f3f;
    num3=0x3f3f3f3f;
    flag=0,cnt=0;
    for(int i=s9.size()-1;i>=0;i--){
        if('('==s9[i]||','==s9[i]||s9[i]==')'){
            flag++;
            cnt=0;
        }
        if(flag==1){
            if((s9[i]-'0'<0||s9[i]-'9'>0)&&(s9[i]!='-')) continue;
            if(cnt==0) num3=0;
            if(s9[i]!='-') num3+=(s9[i]-'0')*pow(10,cnt),cnt++;
            else if(s9[i]=='-') num3=num3*(-1);
        }else if(flag==2){
            if((s9[i]-'0'<0||s9[i]-'9'>0)&&(s9[i]!='-')) continue;
            if(cnt==0) num2=0;
            if(s9[i]!='-') num2+=(s9[i]-'0')*pow(10,cnt),cnt++;
            else num2=num2*(-1);
        }else if(flag==3){
            if((s9[i]-'0'<0||s9[i]-'9'>0)&&(s9[i]!='-')) continue;
            if(cnt==0) num1=0;
            if(s9[i]!='-') num1+=(s9[i]-'0')*pow(10,cnt),cnt++;
            else num1=num1*(-1);
        }
    }
    if(flag==3){
        f=1;
        d=num2,e=num3;
    }else{
        d=num1,e=num2,f=num3;
        if(num3==0) f=1;
    }
    int ans=0;
    //cout<<a<<"!"<<b<<"!"<<c<<"!"<<d<<"!"<<e<<"!"<<f<<endl;
    if(c>0){
        int d1=d,e1=e,f1=f;
        for(i=a;i<b;i+=c){
            if(d==0x3f3f3f3f){
                d1=i;
            }
            if(e==0x3f3f3f3f){
                e1=i;
            }
            if(f==0x3f3f3f3f){
                f1=i;
            }
            if(1.0*(e1-d1)/f1<=0) continue;
            else{
                int cnt=((e1-d1)/f1);
                if(d1+cnt*f1==e1) cnt--;
                ans+=(d1+d1+cnt*f1)*(cnt+1)/2;
            }
        }
        cout<<ans<<endl;
    }else{
        //cout<<a<<"!"<<b<<"!"<<c<<"!"<<d<<"!"<<e<<"!"<<f<<endl;
        int d1=d,e1=e,f1=f;
        for(i=a;i>b;i+=c){
            if(d==0x3f3f3f3f){
                d1=i;
            }
            if(e==0x3f3f3f3f){
                e1=i;
            }
            if(f==0x3f3f3f3f){
                f1=i;
            }
            //cout<<d1<<"!"<<e1<<"!"<<f1<<endl;
            if(1.0*(e1-d1)/f1<=0) continue;
            else{
                //ans+=(d1+d1+((e1-d1)/f1)*f1)*((e1-d1)/f1)/2;
                int cnt=((e1-d1)/f1);
                if(d1+cnt*f1==e1) cnt--;
                ans+=(d1+d1+cnt*f1)*(cnt+1)/2;
                //cout<<cnt<<"!!"<<ans<<endl;
            }
        }
        cout<<ans<<endl;
    }
}
signed main(){
    int t=1;
    //cin>>t;
    while(t--){

        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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: 0ms
memory: 3728kb

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: 3ms
memory: 3780kb

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