Submission #17633316


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
ll A[202020][305];
ll S[305];
const ll mo=998244353;

ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		A[i][0]=1;
		cin>>A[i][1];
		for(j=2;j<=300;j++) A[i][j]=A[i][j-1]*A[i][1]%mo;
		FOR(j,301) (S[j]+=A[i][j])%=mo;
	}
	
	for(i=1;i<=K;i++) {
		ll ret=0;
		FOR(j,i+1) (ret+=comb(i,j)*S[j]%mo*S[i-j])%=mo;
		ll tmp=S[i];
		FOR(j,i) tmp=2*tmp%mo;
		ret-=tmp;
		ret=(ret%mo+mo)*((mo+1)/2)%mo;
		cout<<ret<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task D - Powers
User kmjp
Language C++ (GCC 9.2.1)
Score 600
Code Size 1609 Byte
Status AC
Exec Time 648 ms
Memory 489504 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:34:10: warning: unused variable ‘k’ [-Wunused-variable]
   34 |  int i,j,k,l,r,x,y; string s;
      |          ^
./Main.cpp:34:12: warning: unused variable ‘l’ [-Wunused-variable]
   34 |  int i,j,k,l,r,x,y; string s;
      |            ^
./Main.cpp:34:14: warning: unused variable ‘r’ [-Wunused-variable]
   34 |  int i,j,k,l,r,x,y; string s;
      |              ^
./Main.cpp:34:16: warning: unused variable ‘x’ [-Wunused-variable]
   34 |  int i,j,k,l,r,x,y; string s;
      |                ^
./Main.cpp:34:18: warning: unused variable ‘y’ [-Wunused-variable]
   34 |  int i,j,k,l,r,x,y; string s;
      |                  ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:7:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    7 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
./Main.cpp:60:38: note: in expansion of macro ‘FOR’
   60 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                      ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 30
Set Name Test Cases
Sample 00_sample_01, 00_sample_02, 00_sample_03
All 00_sample_01, 00_sample_02, 00_sample_03, 10_small_01, 10_small_02, 10_small_03, 10_small_04, 10_small_05, 10_small_06, 10_small_07, 10_small_08, 10_small_09, 10_small_10, 20_random_01, 20_random_02, 20_random_03, 20_random_04, 20_random_05, 20_random_06, 20_random_07, 20_random_08, 20_random_09, 20_random_10, 30_max_01, 30_max_02, 30_max_03, 30_max_04, 30_max_05, 31_max_01, 31_max_02
Case Name Status Exec Time Memory
00_sample_01 AC 32 ms 12924 KB
00_sample_02 AC 30 ms 12836 KB
00_sample_03 AC 26 ms 12952 KB
10_small_01 AC 26 ms 13432 KB
10_small_02 AC 29 ms 13328 KB
10_small_03 AC 24 ms 13292 KB
10_small_04 AC 26 ms 13432 KB
10_small_05 AC 30 ms 13272 KB
10_small_06 AC 33 ms 13228 KB
10_small_07 AC 22 ms 12940 KB
10_small_08 AC 25 ms 13668 KB
10_small_09 AC 28 ms 13336 KB
10_small_10 AC 25 ms 13500 KB
20_random_01 AC 259 ms 187872 KB
20_random_02 AC 291 ms 214880 KB
20_random_03 AC 124 ms 88640 KB
20_random_04 AC 339 ms 252592 KB
20_random_05 AC 529 ms 388608 KB
20_random_06 AC 444 ms 336700 KB
20_random_07 AC 326 ms 245384 KB
20_random_08 AC 500 ms 379128 KB
20_random_09 AC 621 ms 461868 KB
20_random_10 AC 641 ms 484336 KB
30_max_01 AC 646 ms 489396 KB
30_max_02 AC 648 ms 489456 KB
30_max_03 AC 647 ms 489460 KB
30_max_04 AC 645 ms 489464 KB
30_max_05 AC 648 ms 489424 KB
31_max_01 AC 646 ms 489504 KB
31_max_02 AC 648 ms 489472 KB