QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#690757#9255. Python ProgramfosovAC ✓41ms3812kbC++141.2kb2024-10-31 02:10:362024-10-31 02:10:37

Judging History

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

  • [2024-10-31 02:10:37]
  • 评测
  • 测评结果:AC
  • 用时:41ms
  • 内存:3812kb
  • [2024-10-31 02:10:36]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define MOD ((int) (1e9) + 7)
#define pii pair<int, int>

#define N 200010
#define inf 0x7fffffff

string si, sa, sb, sc;
void read() {
    string buf, cu = ""; sc = "1";
    cin >> buf >> si;
    cin >> buf >> buf;
    buf = buf.substr(6, buf.size() - 6 - 2) + ",";

    string* cont[3] = { &sa, &sb, &sc };
    for (int i = 0, j = 0; i < buf.size(); ++ i) {
        if (buf[i] == ',') *cont[j ++] = cu, cu = "";
        else cu += buf[i];
    }
}

ll i, ia, ib, ic;
ll j, ja, jb, jc;

int main() {
#ifdef TEST
    freopen("zz.in", "r+", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> si;
    read();
    ia = stoi(sa), ib = stoi(sb), ic = stoi(sc);
    read();
    
    
    ll res = 0;
    for (i = ia; i * ic < ib * ic; i += ic) {
        ja = isalpha(sa[0]) ? i : stoi(sa);
        jb = isalpha(sb[0]) ? i : stoi(sb);
        jc = isalpha(sc[0]) ? i : stoi(sc);
        if (ja * jc >= jb * jc) continue;
        jb += jc < 0 ? 1 : -1;
        res += (ja + ja + (jb - ja) / jc * jc) * ((jb - ja) / jc + 1) / 2;
    }
    cout << res << '\n';

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 32ms
memory: 3812kb

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: 6ms
memory: 3656kb

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: 41ms
memory: 3600kb

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