QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#791192#9255. Python ProgramzhishengRE 0ms3816kbC++204.9kb2024-11-28 17:23:492024-11-28 17:23:50

Judging History

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

  • [2024-11-28 17:23:50]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3816kb
  • [2024-11-28 17:23:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
int a,b,c,d,e,f;
int sum(int a1,int n,int d) {
    int an = a1 + (n-1)*d;
   return (a1 + an)*n/2;
}
signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    auto solve = [&]() {
        vector <string> s(10);
        for(int i=1;i<=5;i++) {
            getline(cin,s[i]);
            // cout << a[i] << "\n";
        }
        int ans = 0;

        c = 1,f = 1;
        string x = "";x += s[2][5];
        string tmp = "";
        int cnt = 0,p1,p2;
           for(int i=0;i<s[2].size();i++) {
                if(s[2][i] == '(') p1 = i;
                if(s[2][i] == ')') p2 = i;
           }
        int f1=0,f2=0,f3 = 0;
        int fla = 0;
        for(int i=p1;i<=p2;i++) {
            if(s[2][i] == '-') {
                fla = 1;
                i++;
            }
            if(s[2][i]>='0' && s[2][i]<='9' ) {
                tmp += s[2][i];
            }
            else {
                if(tmp.size() > 0) {
                    cnt ++ ;

                    if(cnt == 1) {
                        a = stoi(tmp);
                        if(fla) {
                            a = -a;
                        }
                    }
                    else if(cnt == 2) {
                        b = stoi(tmp);
                        if(fla) {
                            b = -b;
                        }

                    }
                    else if(cnt ==3 ) {
                        c= stoi(tmp);
                        if(fla) {
                            c = -c;
                        }
                    }

                }
                tmp = "";
                f = 0;
            }
        }
        tmp = "";
        cnt = 0;
        for(int i=0;i<s[3].size();i++) {
            if(s[3][i] == '(') p1 = i;
            if(s[3][i] == ')') p2 = i;
        }
        for(int i=p1;i<=p2;i++) {
            if(s[3][i] == '-') {
                fla = 1;
                i++;
            }
            if(s[3][i]>='0' && s[3][i]<='9' ) {
                tmp += s[3][i];
            }
            else if(s[3][i] >='a' && s[3][i]<='z') {
                tmp += s[3][i];
            }
            else {
                if(tmp.size() > 0) {
                    cnt ++ ;
                    if(cnt == 1) {
                        if(tmp == x) {
                            f1 = 1;
                        }
                        else d = stoi(tmp);
                        if(fla) {
                            d = -d;
                        }
                    }
                    else if(cnt == 2) {
                        if(tmp == x) {
                            f2 = 1;
                        }
                        else e = stoi(tmp);
                        if(fla) {
                            e = -e;
                        }
                    }
                    else if(cnt ==3 ) {
                        if(tmp == x) {
                            f3 = 1;
                        }
                        else f = stoi(tmp);
                        if(fla) {

                            f = -f;
                        }
                    }

                }
                tmp = "";
                fla = 0;
            }
        }
        // cout << a << " " << b << ' ' << c << " " << d << " " <<e << " " << f << "\n";
        if(a < b) {
            for(int i=a;i<b;i+=c) {
                int st = d;int ed = e;int len = f;
                if(f1 == 1) st = i;
                if(f2 == 1) ed = i;
                if(f3 == 1) len = i;
                if(len > 0) {
                    if(st >= ed) {
                        continue;
                    }
                    int ct = (ed - st + len-1)/len;
                    ans += sum(st,ct,len);
                }
                if(len < 0) {
                    if(st<=ed) continue;;
                    int ct = (-ed+ st + abs(len)-1)/abs(len);
                    ans += sum(st,ct,len);
                }
            }
            cout << ans << "\n";
        }
        else {
            for(int i=a;i>b;i+=c) {
                int st = d;int ed = e;int len = f;
                if(f1 == 1) st = i;
                if(f2 == 1) ed = i;
                if(f3 == 1) len = i;
                if(len > 0) {
                    if(st >= ed) {
                        continue;
                    }
                    int ct = (ed - st + len-1)/len;
                    ans += sum(st,ct,len);
                }
                if(len < 0) {
                    if(st<=ed) continue;;
                    int ct = (-ed+ st + abs(len)-1)/abs(len);
                    ans += sum(st,ct,len);
                }
            }
            cout << ans << "\n";
        }




    };
    int t = 1;
    // cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

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
Runtime Error

input:

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

output:


result: