QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#550593#9255. Python Programucup-team4801#AC ✓3ms1632kbC++171.9kb2024-09-07 13:32:582024-09-07 13:32:58

Judging History

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

  • [2024-09-07 13:32:58]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:1632kb
  • [2024-09-07 13:32:58]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<string>
#include<cctype>

#define fi first
#define se second
#define mkp std::make_pair
using ll=long long;
using llu=unsigned long long;
using std::max;
using std::min;
template<class T> void cmax(T&a,T b){a=max(a,b);}
template<class T> void cmin(T&a,T b){a=min(a,b);}
template<class T> T sqr(T a){return a*a;}

namespace xm{
    char sz[1145];
    void getbracket(){
        char ch;
        do{
            scanf(" %c",&ch);
        }while(ch!='(');
    }void _(){
        const int wtf=-1e9;
        getbracket();
        int a,b,c,d,e,f;
        {
            scanf("%[^)]",sz);
            int p[3]={};
            for(int i=0;sz[i];++i) if(sz[i]==',') p[++*p]=i;
            sscanf(sz,"%d",&a);
            sscanf(sz+p[1]+1,"%d",&b);
            if(*p==2) sscanf(sz+p[2]+1,"%d",&c);
            else c=1;
        }
        getbracket();
        {
            scanf("%[^)]",sz);
            int p[3]={};
            for(int i=0;sz[i];++i) if(sz[i]==',') p[++*p]=i;
            if(isalpha(sz[0])) d=wtf;
            else sscanf(sz,"%d",&d);
            if(isalpha(sz[p[1]+1])) e=wtf;
            sscanf(sz+p[1]+1,"%d",&e);
            if(*p==2){
                if(isalpha(sz[p[2]+1])) f=wtf;
                else sscanf(sz+p[2]+1,"%d",&f);
            }else f=1;
        }

        //printf("%d %d %d %d %d %d\n",a,b,c,d,e,f);

        ll ans=0;
        for(int i=a;c>0?i<b:i>b;i+=c){
            int td=d==wtf?i:d;
            int te=e==wtf?i:e;
            int tf=f==wtf?i:f;
            ll cnt;
            if(tf>0){
                if(te<=td) continue;
                cnt=(te-td-1)/tf;
            }else{
                if(te>=td) continue;
                cnt=(td-te-1)/(-tf);
            }
            ans+=(td*2ll+cnt*tf)*(cnt+1)/2;
        }
        printf("%lld\n",ans);
    }
}

int main(){
    xm::_();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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

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

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