QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#801344#9255. Python Programkjhhjki#WA 0ms3740kbC++201.9kb2024-12-06 21:32:382024-12-06 21:32:40

Judging History

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

  • [2024-12-06 21:32:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3740kb
  • [2024-12-06 21:32:38]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using f64 = long double;

template<typename T, typename U>
void chkmax(T &a, U b) { if(a < b) a = b; }
template<typename T, typename U>
void chkmin(T &a, U b) { if(a > b) a = b; }

constexpr int P = 998244353;

void init() { }

void solve()
{
    std::string s;
    std::getline(std::cin, s);
    int *a[2], *b[2], *c[2];
    int cur;
    auto get = [&](char *s, int **x) {
        if (std::isalpha(s[0])) {
            *x = &cur;
        } else {
            *x = new int(std::stoi(s));
        }
    };
    for (int i = 0; i < 2; ++i) {
        std::getline(std::cin, s);
        char ta[10], tb[10], tc[10]{};
        sscanf(s.c_str(), "%*[\tf]or %*c in range(%[^,],%[^,)],%[^)]):", ta, tb, tc);
        if (!tc[0]) {
            tc[0] = '1';
        }
        get(ta, &a[i]); get(tb, &b[i]); get(tc, &c[i]);
    }
    i64 ans = 0;
    for (cur = *a[0]; *c[0] > 0? cur < *b[0]: cur > *b[0]; cur += *c[0]) {
        int d = a[1][0], e = b[1][0], f = c[1][0];
        if (f < 0) {
            i64 n = (d - e - 1) / -f + 1, lst = d + n * f - f;
            if (e >= d) {
                continue;
            }
            ans += (d + lst) * n / 2;
        } else {
            i64 n = (e - d - 1) / f + 1, lst = d + n * f - f;
            if (e <= d) {
                continue;
            }
            ans += (d + lst) * n / 2;
        }
    }
    std::cout << ans << '\n';
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    init();
    int T = 1;
    // std::cin >> T;
    while(T --) solve();
    return 0;
}
/*
ans=0
for a in range(1,3):
    for b in range(5,1,-2):
        ans+=b
print(ans)

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

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3740kb

input:

ans=0
for a in range(1,3):
    for b in range(5,1,-2):
        ans+=b
print(ans)

output:

6

result:

wrong answer 1st lines differ - expected: '16', found: '6'