/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 320.0 KiB
#3 Wrong Answer 1ms 532.0 KiB

Code

#include <bits/stdc++.h>     //   All praise is due to Allah alone, and peace and blessings be
using namespace std;         //         upon him, after whom there is no other Prophet.

const int mod = 998244353;
int pow_mod(const int64_t n, const int k) {
    int64_t x = n % mod, r = 1;
    int p = k;
    while (p) {
        if (p & 1) r = r * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return r;
}
int add(const int64_t a, const int b) {
    return (a + b) % mod;
}
int sub(const int64_t a, const int b) {
    int64_t x = a % mod, y = b % mod;
    x -= y;
    return x < 0 ? x + mod : x;
}
int mul(const int64_t a, const int b) {
    return (a * b) % mod;
}
int mdiv(const int a, const int b) {
    return int64_t(a) * pow_mod(b, mod - 2) % mod;
}
int64_t lcm(const int64_t a, const int64_t b) {
    return (a / __gcd(a, b)) * b;
}
int64_t c_dist(const int64_t x1, const int64_t y1, const int64_t x2, const int64_t y2) {
    return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}
int msb(const int64_t x) {
    return x ? 63 - __builtin_clzll(x) : -1;
}
int lsb(const int64_t x) {
    return x ? __builtin_ctzll(x) : -1;
}
bool kthbit(const int64_t x, const int k) {
    return (x >> k) & 1;
}

struct Array { int f, inf; }; vector<Array> Cc;
void combinatorics(const int N) {
    Cc.resize(N);
    Cc[0].f = 1;
    for (int i = 1; i < N; i++) {
        Cc[i].f = int64_t(Cc[i - 1].f) * i % mod;
    }
    Cc[N - 1].inf = pow_mod(Cc[N - 1].f, mod - 2);
    for (int i = N - 2; i >= 0; i--) {
        Cc[i].inf = int64_t(Cc[i + 1].inf) * (i + 1) % mod;
    }
}
int ncr(const int n, const int r) {
    return mul(mul(Cc[n].f, Cc[r].inf), Cc[n - r].inf);
}
int npr(const int n, const int r) {
    return mul(Cc[n].f, Cc[n - r].inf);
}

vector<int> spf, pr;
void SPF(const int len) {
    spf.resize(len + 1);
    iota(spf.begin(), spf.end(), 0);
    for (int i = 2; i * i <= len; i++) {
        if (spf[i] == i) {
            for (int j = i * i; j <= len; j += i) {
                if (spf[j] == j) spf[j] = i;
            }
        }
    }
}
void prime(const int len) {
    SPF(len);
    pr.push_back(2);
    for (int i = 3; i <= len; i += 2) {
        if (spf[i] == i) pr.push_back(i);
    }
}
vector<pair<int,int>> pf(int n) {
    vector<pair<int,int>> f;
    while (n > 1) {
        int p = spf[n], cnt = 0;
        while (n % p == 0) {
            n /= p;
            cnt++;
        }
        f.emplace_back(p, cnt);
    }
    return f;
}
bool is_prime(const int n) {
    if (n <= 1) return false;
    if (n == 2 || n == 7 || n == 61) return true;
    if (n % 2 == 0) return false;
    int64_t d = n - 1;
    while ((d & 1) == 0) d >>= 1;
    int64_t bases[3] = {2, 7, 61};
    for (int64_t a: bases) {
        if (a >= n) continue;
        int64_t t = d, y = 1, b = a % n;
        while (t) {
            if (t & 1) y = y * b % n;
            b = b * b % n;
            t >>= 1;
        }
        t = d;
        while (t != n - 1 && y != 1 && y != n - 1) {
            y = y * y % n;
            t <<= 1;
        }
        if (y != n - 1 && (t & 1) == 0) return false;
    }
    return true;
}
vector<int> gd_spf(int num) {
    vector<int> divs = {1};
    while (num > 1) {
        int p = spf[num], cnt = 0;
        while (num % p == 0) {
            num /= p;
            cnt++;
        }
        int sz = divs.size();
        for (int i = 0; i < sz; i++) {
            int cur = divs[i];
            for (int j = 1; j <= cnt; j++) {
                cur *= p;
                divs.push_back(cur);
            }
        }
    }
    return divs;
}
vector<int> gd(const int n) {
    vector<int> v;
    for (int i = 1; int64_t(i) * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i != n / i) v.push_back(n / i);
        }
    }
    return v;
} // not sorted

int32_t main() {
    cin.tie(0)->sync_with_stdio(false);

    int32_t Case = 1;    //cin >> Case;
    for (int T = 1; T <= Case; T++) {

        string s; cin >> s;
        int64_t n; cin >> n;

        string a, b;
        int i = 0;
        for( i = 0; i < s.size(); i++) {
            if(s[i] == '+') break;
            a.push_back(s[i]);
        }
        for(i++; i < s.size(); i++) {
            if(s[i] == '+') break;
            b.push_back(s[i]);
        }
        int64_t A = stoll(a), B = stoll(b);
        cout << n / 2.0 * (A * 2 + (n - 1) * (B - A)) << '\n';
    }
    return 0;
}

// 2.5 * (2 + 4 * 2)

Information

Submit By
Type
Submission
Problem
P1231 Busy Friend
Contest
LUCC Presents Intra LU Junior Programming Contest - Replay
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-02 16:42:40
Judged At
2025-09-02 16:42:40
Judged By
Score
10
Total Time
1ms
Peak Memory
532.0 KiB