답안 #859759

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
859759 2023-10-10T15:26:00 Z alexia_726 NoM (RMI21_nom) C++14
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>

using namespace std;

int n,st[1000000], v[100005], m, cnt, ok;

void tipar(int p)
{
    ok=0;

    for (int i=1;i<p;i++)
    {
        if((v[st[i]]!=v[st[2*i]])&&(abs(v[st[i]]-v[st[i]+1])==1)) ok=1;

        for(int j=i+1;j<=p && ok;j+=(i+1))

            if((v[st[j]]-v[st[i]])%m==0) ok=0;



    }

    if(ok) cnt++;
}

int valid(int p)
{
    for (int i=1;i<p;i++)
        if (st[p]==st[i]) return 0;

    return 1;
}

void bec(int p)
{
    for (int k=1;k<=2*n;k++)
    {
        st[p]=k;

        if (valid(p))
            if (p==2*n)
            tipar(p);

        else
            bec(p+1);
    }
}

int main()
{
     cin>>n>>m; cnt=0;

     for(int i=1;i<=2*n;++i)
     {
         if(i>n) v[i]=i/2;
         else v[i]=i;
     }

    bec(1);

    cout<<cnt;
}

Compilation message

Main.cpp: In function 'void bec(int)':
Main.cpp:40:12: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   40 |         if (valid(p))
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -