#include<iostream>
#include<algorithm>
using namespace std;
int n;
pair<pair<int,int>,int> a[25];
int calc_cnt2(int x)
{
int rez=0;
for(int i=0;i<30;i++)
{
if(((1<<i)&x))
rez++;
}
return rez;
}
int calc_cnt3(int x)
{
int rez=0;
while(x>0)
{
if(x%3==1)
rez++;
x/=3;
}
return rez;
}
signed main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].second;
a[i].first = {calc_cnt2(a[i].second), calc_cnt3(a[i].second)};
}
sort(a+1,a+1+n);
long long rez=0;
do
{
rez++;
for(int i=1;i<n;i++)
{
if(a[i].first.first!=a[i+1].first.first && a[i].first.second!=a[i+1].first.second)
{
rez--;
break;
}
}
}while(next_permutation(a+1,a+1+n));
cout<<rez;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
35 ms |
348 KB |
Output is correct |
7 |
Correct |
29 ms |
348 KB |
Output is correct |
8 |
Correct |
68 ms |
348 KB |
Output is correct |
9 |
Incorrect |
17 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |