QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#619436#9255. Python Programucup-team5071#RE 0ms0kbC++202.4kb2024-10-07 14:11:412024-10-07 14:11:44

Judging History

你现在查看的是最新测评结果

  • [2024-10-07 14:11:44]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-07 14:11:41]
  • 提交

answer

#include <bits/stdc++.h>

#define fp(i, a, b) for (int i = (a), i##_ = (b) + 1; i < i##_; ++i)
#define fd(i,a,b) for (int i = (a), i##_ = (b) - 1; i > i##_; ++i)
using ll = int64_t;
using namespace std;
const int max = 1e5+5,P = 998244353;
#define ADD(a,b) (((a) += (b)) >= P ? (a) -= P:0)
#define SUB(a,b) (((a) -= (b)) < 0  ? (a) += P:0)
#define MUL(a,b) ((ll) (a)*(b) % P)

int POW(ll a,int b = P-2, ll x = 1){for (; b; b >>= 1,a = a*a%P) if(b&1) x= x*a%P;return x;}
namespace NTT{
    const int g = 3;
    vector<int> Omega(int L){
        int wn = POW(g,P/L);
        vector<int> w(L); w[L>>1] = 1;
        fp(i, L / 2 + 1, L - 1) w[i] = MUL(w[i-1],wn);
        fd(i, L / 2 - 1, 1) w[i] = w[i << 1];
        return w;
    }
    auto w = Omega(1 << 21);
    void DIF(int* a, int n) {
        for (int k = n >> 1; k; k >>= 1)
            for (int i = 0, y; i < n; i += k << 1)
                fp(j,0,k-1)
                    y = a[i+j+k], a[i+j+k] = MUL(a[i+j] - y + P,w[k+j]),ADD(a[i+j],y);
    }
    void IDIT(int *a, int n){
        for (int k = 1; k < n; k <<= 1)
            for(int i = 0,x,y; i < n; i += k << 1)
                fp(j, 0, k-1)
                    x = a[i+j], y = MUL(a[i + j + k],w[k+j]), a[i+j+k] = x-y < 0 ? x - y + P : x - y,ADD(a[i+j],y);
        int Inv = P - (P-1) / n;
        fp(i,0,n-1) a[i] = MUL(a[i],Inv);
        reverse(a+1,a+n);
    }
    
}
namespace Polynomial{
    using Poly = std::vector<int>;
    void DFT(Poly &a) {NTT::DIF(a.data(),a.size());}
    void IDFT(Poly &a) {NTT::IDIT(a.data(),a.size());}
    int norm(int n) {return 1 << (32 - __builtin_clz(n-1));}
    void norm(Poly& a) {if (!a.empty()) a.resize(norm(a.size()),0);}
    Poly &dot(Poly &a, Poly &b){
        fp(i, 0, a.size()-1) a[i] = MUL(a[i],b[i]);
        return a;
    }
    Poly operator*(Poly a,Poly b){
        int n = a.size() + b.size() - 1, L = norm(n);
        if (a.size() <= 8 || b.size() <= 8){
            Poly c(n);
            fp(i, 0 ,a.size() - 1) fp(j,0,b.size()-1)
                c[i + j] = (c[i+j] + (ll) a[i]*b[j]) % P;
            return c;
        }
        a.resize(L); b.resize(L);
        DFT(a), DFT(b), dot(a,b), IDFT(a);
        return a.resize(n), a;
    }
}
using namespace Polynomial;

int main(){
    Poly a{1,2,3};
    Poly b{1,2,3};
    Poly c = a*b;
    for (auto x : c){
        cout << x;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

ans=0
for a in range(1,3):
    for b in range(5,1,-2):
        ans+=b
print(ans)

output:


result: