QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#660528#9255. Python Program_CHO#WA 3ms3820kbC++202.1kb2024-10-20 11:53:412024-10-20 11:53:44

Judging History

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

  • [2024-10-20 11:53:44]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3820kb
  • [2024-10-20 11:53:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

i64 a,b,c=1;
i64 d,e,f=1;
bool flag_d,flag_e,flag_f;

string outer,inner;


void read_out(){
    string str; getline(cin,str);
    stringstream stin(str);

    string outer;
    stin >> outer >> outer;

    int p = 0;
    while(!isdigit(str[p])) ++p;
    while(isdigit(str[p])) a = a*10 + str[p++] -'0';
    while(!isdigit(str[p])) p++;
    while(isdigit(str[p])) b = b*10 + str[p++] -'0';
    if(str[p]==')') return ;

    while(!isdigit(str[p]) && str[p] != '-') p++;
    int sgn = 1;if(str[p]=='-') sgn = -1;
    while(isdigit(str[p])) c = c*10 + str[p++]-'0';
    c *= sgn;
}
void read_in(){
    string str; getline(cin,str);
    int p = 0;
    while(str[p]!='(') ++p;
    ++ p;

    string tmp; while(str[p]!=',') tmp+=str[p++];
    if(tmp[0]=='-' || isdigit(tmp[0])){
        stringstream tmpin(tmp);
        tmpin >> d;
    }else{
        flag_d = true;
    }
    ++p;

    tmp.clear(); while(str[p]!=',' && str[p]!=')') tmp+=str[p++];
    if(tmp[0]=='-' || isdigit(tmp[0])){
        stringstream tmpin(tmp);
        tmpin >> e;
    }else{
        flag_e = true;
    }
    
    if(str[p]==')') return ;
    ++p;
    
    tmp.clear(); while(str[p]!=')') tmp+=str[p++];
    if(tmp[0]=='-' || isdigit(tmp[0])){
        stringstream tmpin(tmp);
        tmpin >> f;
    }else{
        flag_f = true;
    }
}
void read_opt(){
    
}
main(){
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    string str; getline(cin,str);
    read_out();
    read_in();
    read_opt();

    i64 ans = 0;
    for(i64 i = a;(c>0&&i<b)||(c<0&&i>b); i += c){
        i64 s = flag_d?i:d;
        i64 t = flag_e?i:e;
        i64 step = flag_f?i:f;
        // printf("%d -> %d %d %d\n",i,s,t,step);
        if(step > 0) t--;
        else if(step < 0) t++;

        // for(int j=s;(step>0&&j<=t)||(step<0&&j>=t);j+=step) ans+=j;
        if(step > 0 && t<s ) continue;
        if(step < 0 && t>s ) continue;
        i64 n = (t - s) / step + 1;
        ans += n * s + n*(n-1)/2 * step;
   }
    cout << ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3468kb

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

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

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

input:

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

output:

1959542591101000

result:

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