QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#390800#8543. Periodic Sequence275307894aTL 1ms6028kbC++141.4kb2024-04-15 22:04:332024-04-15 22:04:33

Judging History

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

  • [2024-04-15 22:04:33]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:6028kb
  • [2024-04-15 22:04:33]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e6+5,M=2000+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-8;const ll INF=1e18+7;mt19937 rnd(181766);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,p;ll ans[N],f[N];
void Solve(){
	int i,j;scanf("%d%d",&n,&p);
	for(int i=1;i<=n;i++){
		fill(f+1,f+n-i+1,0);f[0]=1;ans[i]++;
		ll tot=0,sum=1;
		for(j=1;j<=n-i;j++){
			tot+=f[j-1];
			if(j>i) tot-=f[j-i-1];
			f[j]=tot%p;
			sum+=f[j];
			ans[j+i]+=sum%p;
		}
	}
	for(i=1;i<=n;i++) printf("%lld ",ans[i]%p);
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6028kb

input:

5 1000000007

output:

1 3 6 11 19 

result:

ok 5 number(s): "1 3 6 11 19"

Test #2:

score: -100
Time Limit Exceeded

input:

200000 567894337

output:


result: