题解 | #第二杯半价#

第二杯半价

https://ac.nowcoder.com/acm/contest/75483/A

#include <bits/stdc++.h>

#define int long long
#define endl '\n'
[[maybe_unused]]const int INF = 1e16 + 50, MOD = 10007;
[[maybe_unused]] typedef std::pair<int, int> pii;

void solve() {
    int n, x;
    std::cin >> n >> x;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i & 1)
            ans += std::ceil((double)x / 2);
        else
            ans += x;
    }
    std::cout << ans << endl;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr), std::cout.tie(nullptr);
    int Lazy_boy_ = 1;
    std::cin >> Lazy_boy_;
    while (Lazy_boy_--)
        solve();
    return 0;
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务