题解 | #时间银河#

时间银河

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

可以对数据分组处理.

#include <bits/stdc++.h>

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

int cal(int x) {
    return x / 4 - x / 100 + x / 400;
}

void solve() {
    int l, r;
    std::cin >> l >> r;
    std::cout << 365 * (r - l + 1) - cal(l - 1) + cal(r) << 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;
}
全部评论

相关推荐

吴offer选手:学到了,下次面试也放张纸在电脑上,不然老是忘记要说哪几个点
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务