QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#776560#8834. Formal FringAdd_CatalystAC ✓35ms15208kbC++143.1kb2024-11-23 19:22:392024-11-23 19:22:39

Judging History

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

  • [2024-11-23 19:22:39]
  • 评测
  • 测评结果:AC
  • 用时:35ms
  • 内存:15208kb
  • [2024-11-23 19:22:39]
  • 提交

answer

#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define ll long long
#define RCL(a,b,c,d) memset(a,b,sizeof(c)*(d))
#define tomin(a,...) ((a)=min({(a),__VA_ARGS__}))
#define tomax(a,...) ((a)=max({(a),__VA_ARGS__}))
#define FOR(i,a,b) for(int i(a); i<=(int)(b); ++i)
#define DOR(i,a,b) for(int i(a); i>=(int)(b); --i)
#define EDGE(g,i,x,y) for(int i(g.h[x]),y(g[i].v); ~i; y=g[i=g[i].nxt].v)
using namespace std;
constexpr int N(1e6+10),lN(20),lV(lN+1);

namespace IOEstream {
#define isdigit(ch) ('0'<=(ch)&&(ch)<='9')
#define DE(...) E(#__VA_ARGS__,__VA_ARGS__)

	struct Istream {
		char getc() {
			return getchar();
		}
		template<class T>void operator ()(T &x) {
			static bool sign(0);
			static char ch(0);
			sign=0,x=0;
			while(ch=getc(),!isdigit(ch))if(ch=='-')sign=1;
			do x=(x<<1)+(x<<3)+(ch^48);
			while(ch=getc(),isdigit(ch));
			if(sign)x=-x;
		}
		template<class T,class...Types>void operator ()(T &x,Types&...args) {
			return (*this)(x),(*this)(args...);
		}
	} I;

	struct Ostream {
		void putc(const char c) {
			putchar(c);
		}
		template<class T>void operator ()(T x,const char lst='\n') {
			static int top(0);
			static char st[50];
			if(x<0)x=-x,putc('-');
			do st[++top]=(x%10)^48,x/=10;
			while(x);
			while(top)putc(st[top--]);
			putc(lst);
		}
		template<class T,class...Types>void operator ()(const T x,const char lst='\n',const Types...args) {
			return (*this)(x,lst),(*this)(args...);
		}
	} O;

	struct Estream {
		template<class T>void operator ()(const char *fmt,const T x) {
			cerr<<fmt<<':'<<x<<".\n";
		}
		template<class T,class...Types>void operator ()(const char *fmt,const T x,const Types...args) {
			while(*fmt^',')cerr<<*fmt++;
			return cerr<<':'<<x<<", ",(*this)(++fmt,args...);
		}
	} E;

} using namespace IOEstream;

namespace Modular {
#define Mod 998244353
	template<class T1,class T2>constexpr auto add(const T1 a, const T2 b) {
		return a+b>=Mod?a+b-Mod:a+b;
	}

	template<class T1,class T2>constexpr auto mul(const T1 a,const T2 b) {
		return (ll)a*b%Mod;
	}

	template<class T,class...Types>constexpr auto add(const T a,const Types...args) {
		return add(a,add(args...));
	}

	template<class T,class...Types>constexpr auto mul(const T a,const Types...args) {
		return mul(a,mul(args...));
	}

	template<class T1,class T2>T1 &toadd(T1 &a,const T2 b) {
		return a=add(a,b);
	}

	template<class T1,class T2>T1 &tomul(T1 &a,const T2 b) {
		return a=mul(a,b);
	}

	template<class T0,class T,class...Types>T0 &toadd(T0 &a,const T b,const Types...args) {
		return toadd(a,b),toadd(a,args...);
	}

	template<class T0,class T,class...Types>T0 &tomul(T0 &a,const T b,const Types...args) {
		return tomul(a,b),tomul(a,args...);
	}

} using namespace Modular;

int n;
int f[N],g[N],Lg[N];

int main() {
	I(n),f[0]=1,g[0]=1,Lg[0]=-1;
	FOR(i,1,n)f[i]=i&1?f[i-1]:add(f[i-1],f[i>>1]);
	FOR(i,1,n) {
		Lg[i]=Lg[i>>1]+1;
		if(i==(1<<Lg[i]))g[i]=1;
		else if(i+1==(2<<Lg[i]))g[i]=f[i];
		else g[i]=i&1?g[i-1]:add(g[i-1],g[i>>1]);
		O(g[i],' ');
	}
	puts("");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 7788kb

input:

10

output:

1 1 2 1 1 3 6 1 1 2 

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 1ms
memory: 7716kb

input:

70

output:

1 1 2 1 1 3 6 1 1 2 2 5 5 11 26 1 1 2 2 4 4 6 6 11 11 16 16 27 27 53 166 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 37 37 48 48 64 64 80 80 107 107 134 134 187 187 353 1626 1 1 2 2 4 4 6 

result:

ok 70 numbers

Test #3:

score: 0
Accepted
time: 35ms
memory: 15208kb

input:

1000000

output:

1 1 2 1 1 3 6 1 1 2 2 5 5 11 26 1 1 2 2 4 4 6 6 11 11 16 16 27 27 53 166 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 37 37 48 48 64 64 80 80 107 107 134 134 187 187 353 1626 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 36 36 46 46 60 60 74 74 94 94 114 114 140 140 166 166 203 203 240 240 288 288 336 336 400 ...

result:

ok 1000000 numbers

Extra Test:

score: 0
Extra Test Passed