# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
19011 | | kriii | 팔찌 (kriii4_V) | C++14 | | 0 ms | 20616 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |