QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#660569#9255. Python Program_CHO#WA 0ms3536kbC++202.2kb2024-10-20 12:07:392024-10-20 12:07:39

Judging History

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

  • [2024-10-20 12:07:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3536kb
  • [2024-10-20 12:07:39]
  • 提交

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,++p;
    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 > s){
            --t;
            i64 n = (t-s) / step + 1;
            ans += n * s + n*(n-1) / 2 * step;
        }
        if(step < 0 && t < s){
            ++t;
            i64 n = (s-t) / (-step) + 1;
            ans += n * s + n*(n-1)/2 * step;
        }
        // for(int j=s;(step>0&&j<=t)||(step<0&&j>=t);j+=step) ans+=j;
   }
    cout << ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

ans=0
for q in range(100,50,-1):
    for i in range(q,77,20):
        ans+=i
print(ans)

output:

199

result:

wrong answer 1st lines differ - expected: '2092', found: '199'