萌新求调qwq
查看原帖
萌新求调qwq
560516
喵仔牛奶楼主2022/10/7 11:52

https://www.luogu.com.cn/record/89002249

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll mod = 1e17;
ll n, high, low, ht, lt;
int main(){
    cin >> n;
    for (int i = 1;i <= n; i ++) {
        ht = 0, lt = 1;  
        for (int j = 1; j <= i; j ++) {
            lt *= j, ht *= j;
            ht += lt / mod, lt %= mod;
        }
        high += ht, low += lt;
        high += low / mod, low %= mod;
    }
    if (high) cout << high;
    cout << low << '\n';
    return 0;
}
2022/10/7 11:52
加载中...