#include <bits/stdc++.h>
using namespace std;
//二进制转十进制
int Ten(string s){
int r = 0, t = 1, i;//t:表示权重
for (i = s.size() - 1; i >= 0; i--){
r = r + (s[i] - '0') * t;
t = t * 2;
}
return r;
}
//判断素数
bool prime(int a){
bool flag = 1;
for (int i = 2; i < a; i++){
if (a % i == 0){
flag = 0;
break;
}
}
return flag;
}
int n, k = 0;
int main(){
cin>>n;
string a[n];
for (int i = 0; i < n; i++){
cin >> a[i];
}
for (int i = 0; i < n; i++){
if (Ten(a[i]) != 0){
if (prime(Ten(a[i]))) k++;
}
}
cout << k;
}
1415:【入门】10 进制转 D 进制
#include<bits/stdc++.h>
using namespace std;
//10 进制转 D 进制
string s;
int n, x, D;
char c;
int main(){
cin >> n;
cin >> D;
while (n != 0){
x = n % D;//x:0,1
if (x < 10){
c = x + '0';
}else{
c = x + 'A' - 10;
}
s = c + s;
n = n / D;
}
if (s == ""){
cout << 0;
} else{
cout << s;
}
}