Submission
Status:
PPPPPxxPxx
Subtask/Task Score:
60/100
Score: 60
User: patty
Problemset: การเรียงสับเปลี่ยน
Language: cpp
Time: 0.008 second
Submitted On: 2026-03-13 19:23:08
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int m,n,count,check;
string a;
cin >> m >> n;
for(int i=0;i<m;i++) {
count = 0;
cin >> a;
sort(a.begin(),a.end());
do{
check = 0;
int b = stoi(a);
// cout << a << ' ' << b << '\n';
if(b==2) count+=1;
else if(b%2==0) continue;
else {
for(int i=3;i*i<=b;i+=2) {
if(b%i==0) check+=1;
}
if(check==0) count+=1;
}
} while (next_permutation(a.begin(),a.end()));
cout << count << '\n';
}
}