# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
859759 | alexia_726 | NoM (RMI21_nom) | C++14 | 1 ms | 2396 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 <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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |