QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#550551#9255. Python Programucup-team4801#WA 3ms1704kbC++171.9kb2024-09-07 13:24:252024-09-07 13:24:25

Judging History

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

  • [2024-09-07 13:24:25]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:1704kb
  • [2024-09-07 13:24:25]
  • 提交

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 c=1;
        }

        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;
}

详细

Test #1:

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

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

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

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: -100
Wrong Answer
time: 1ms
memory: 1588kb

input:

ans=0
for i in range(31,321983,2):
    for j in range(313,382193):
        ans+=j
print(ans)

output:

587788233552352

result:

wrong answer 1st lines differ - expected: '11756963404587200', found: '587788233552352'