Submission #19011

# Submission time Handle Problem Language Result Execution time Memory
19011 2016-02-17T02:59:03 Z kriii 팔찌 (kriii4_V) C++14
0 / 100
0 ms 20616 KB
#include <stdio.h>
#include <algorithm>
using namespace std;

int N,K,A[50],B; bool chk[20000000]; long long cnt;

int enc()
{
	int r = 0;
	for (int i=0;i<N;i++) r = r * K + A[i];
	return r;
}

void go(int a)
{
	if (a == N){
		if (chk[enc()]) return;
		cnt++;
		for (int k=0;k<2;k++){
			reverse(A,A+N);
			int t = enc();
			for (int i=0;i<N;i++){
				t = t % B * K + A[i];
				chk[t] = 1;
			}
		}
	}
	else{
		for (int i=0;i<K;i++){
			A[a] = i;
			go(a+1);
		}
	}
}

int main()
{
	int n; scanf ("%d %d",&n,&K);
	cnt = 1;
	B = 1;
	for (N=1;N<=n;N++) {
		for (int i=0;i<B*K;i++) chk[i] = 0;
		go(0);
		B *= K;
		printf ("%lld\n",cnt);
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 20616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -