QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#37670#1254. Biggest Set EverNaCly_FishtestCompile Error//C++143.1kb2022-07-02 14:13:342022-07-02 14:13:36

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-02 14:13:36]
  • 评测
  • [2022-07-02 14:13:34]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#define N 262147
#define ll long long
#define p 998244353
using namespace std;

inline int add(const int& x,const int& y){ return x+y>=p?x+y-p:x+y; }

inline int power(int a,int t){
    int res = 1;
    while(t){
        if(t&1) res = (ll)res*a%p;
        a = (ll)a*a%p;
        t >>= 1;
    }
    return res;
}
 
int siz;
int rev[N],rt[N];
 
void init(int n){
    int lim = 1;
    while(lim<=n) lim <<= 1,++siz;
    for(int i=0;i!=lim;++i) rev[i] = (rev[i>>1]>>1)|((i&1)<<(siz-1));
    int w = power(3,(p-1)>>siz);
    rt[lim>>1] = 1;
    for(int i=(lim>>1)+1;i!=lim;++i) rt[i] = (ll)rt[i-1]*w%p;
    for(int i=(lim>>1)-1;i;--i) rt[i] = rt[i<<1];
}
 
inline void dft(int *f,int n){
    static int a[N];
    int x,shift = siz-__builtin_ctz(n);
    for(int i=0;i!=n;++i) a[rev[i]>>shift] = f[i];
    for(int mid=1;mid!=n;mid<<=1)
    for(int j=0;j!=n;j+=(mid<<1))
    for(int k=0;k!=mid;++k){
        x = (ll)a[j|k|mid]*rt[mid|k]%p;
        a[j|k|mid] = (a[j|k]+p-x)%p;
        a[j|k] = (a[j|k]+x)%p;
    }
    for(int i=0;i!=n;++i) f[i] = a[i];
}
 
inline void idft(int *f,int n){
    reverse(f+1,f+n);
    dft(f,n);
    int x = p-((p-1)>>__builtin_ctz(n));
    for(int i=0;i!=n;++i) f[i] = (ll)f[i]*x%p;
}
 
inline int getlen(int n){
    return 1<<(32-__builtin_clz(n));
}

inline void multiply(const int *f,const int *g,int n,int *r){
	static int A[N],B[N];
	memcpy(A,f,n<<2),memcpy(B,g,n<<2);
	int lim = getlen(n<<1);
	memset(A+n,0,(lim-n+2)<<2),memset(B+n,0,(lim-n+2)<<2);
	dft(A,lim),dft(B,lim);
	for(int i=0;i!=lim;++i) A[i] = (ll)A[i]*B[i]%p;
	idft(A,lim);
	for(int i=0;i<n;++i) r[i] = add(A[i],A[i+n]);
}

inline void poly_pow(const int *f,int n,int t,int *r){
	static int g[N],h[N];
	memset(g,0,(n+1)<<3);
	memset(h,0,(n+1)<<3);
	memcpy(h,f,n<<2);
	g[0] = 1;
	while(t){
		if(t&1) multiply(g,h,n,g);
		t >>= 1;
		if(t==0) break;
		multiply(h,h,n,h);
	}
	for(int i=0;i!=n;++i) r[i] = g[i];
}

int n,rem,len,mdn,tmp,pw;
int T[N],qT[N],f[N],g[N];
char str[N];
ll ans;

int main(){
	//freopen("input.txt","r",stdin);
	scanf("%d%d",&n,&rem);
	init(n<<2);
	scanf("%s",str);
	len = strlen(str);
	for(int i=0;i!=len;++i) T[i] = str[len-i-1]-'0';
	T[0]--;
	for(int i=0;i<len;++i){
		if(T[i]>=0) break;
		T[i+1]--;
		T[i] += 10;
	}
	if(T[len-1]==0) --len;
	for(int i=len-1;~i;--i) mdn = (mdn*10+T[i])%n;
	for(int i=len-1;~i;--i){
		tmp = tmp*10+T[i];
		qT[i] = tmp/n;
		tmp %= n;
	}
	bool flag = false;
	for(int i=len-1;~i;--i){
		if(pw*l0ll+qT[i]>p-1) flag = true;
		pw = (pw*10ll+qT[i])%(p-1);
	}
	f[0] = 2;
	if(mdn==0) g[0] = 2;
	for(int i=1;i<n;++i){
		for(int j=(n<<1);j>=i;--j) f[j] = add(f[j],f[j-i]);
		for(int j=0;j!=n;++j){
			f[j] = add(f[j],f[j+n]);
			f[j+n] = 0;
		}
		if(i==mdn) memcpy(g,f,n<<2);
	}
	if(pw==0&&flag) pw = p-1;
	poly_pow(f,n,pw,f);
	int lim = getlen(n<<1);
	memset(f+n,0,(lim-n+2)<<2);
	for(int i=0;i<=rem;++i) ans += (ll)f[i]*g[rem-i]%p;
	for(int i=0;i<=n+rem;++i) ans += (ll)f[i]*g[n+rem-i]%p;
	printf("%lld",ans%p);
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:115:23: error: ‘l0ll’ was not declared in this scope
  115 |                 if(pw*l0ll+qT[i]>p-1) flag = true;
      |                       ^~~~
answer.code:95:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   95 |         scanf("%d%d",&n,&rem);
      |         ~~~~~^~~~~~~~~~~~~~~~
answer.code:97:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   97 |         scanf("%s",str);
      |         ~~~~~^~~~~~~~~~