2020hdu多校第五场1012

#include <iostream>
#include <cstdio>      //定义输入/输出函数
#include <stack>      //STL 堆栈容器
#include <map>       //STL 映射容器
#include<set>
#include <vector>     //STL 动态数组容器
#include <string>     //字符串类
#include <iterator>        //STL迭代器
#include <cstdlib>     //定义杂项函数及内存分配函数
#include <cstring>     //字符串处理ed
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
#define ll long long
#define ull unsigned long long
#define FOR(ITER,BEGIN,END)  for(int  ITER=BEGIN;ITER<END;ITER++)
#define PER(ITER,TIMES) FOR(ITER,0,TIMES)
#define TIME(TIME_NUMBER) PER(_PETER_MRSCO_ITER_,TIME_NUMBER)
#define close_stdin ios::sync_with_stdio(false)
#define inf 0x3f3f3f3f
#define llm 1e16
#define out_put(l,r,aaaa) {for (int i=l;i<=r;i++){cout<<aaaa[i]<<" ";}cout<<"\n";}
const int maxn = 5e6;
ll iv[maxn+3];
const ll mod = 998244353;
ll n;
//快速幂 别版本
long long fastPower(long long base, long long power, long long mod) {
    long long result = 1;
    while (power > 0) {
        if (power & 1) {//此处等价于if(power%2==1)
            result = result * base % mod;
        }
        power >>= 1;//此处等价于power=power/2
        base = (base * base) % mod;
    }
    return result;
}
// 用于预处理 中 维护一个  inv[maxn] 复杂度只有O(n)极其好用
void presolve() {
    iv[1] = 1;
    for (ll i = 2;i <= 5e6;i++) { iv[i] = iv[mod % i] * (mod - mod / i) % mod; }
}
void solve() {
    cin >> n;
    for(int i=1;i<=n/2;i++){
        cout <<0<<" ";
    }
    ll s = fastPower(iv[2], n / 2, mod);
    cout << s;
    if (n == 1) { cout << "\n";return; }
    else { cout << " "; }
    for (ll i = n / 2+1 ;i <n;i++) {
        s = s * i % mod * iv[2 * i - n + 1] % mod;
        cout << s << (i==n-1?'\n':' ');
    }
}
int main() {
    close_stdin;
    cin.tie(0);
    cout.tie(0);
    presolve();
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
11-29 12:19
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务