Submission #19011

#TimeUsernameProblemLanguageResultExecution timeMemory
19011kriii팔찌 (kriii4_V)C++14
0 / 100
0 ms20616 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...