# NOI 3247:回文素数

#### 题目

http://bailian.openjudge.cn/practice/3247/

#### 源码

``````//
//  3247.cpp
//  test
//
//  Created by bytedance on 2020/9/7.
//
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

bool isP(int n){
int sq = sqrt(n)+1;
for(int i = 2;i <= sq;++i){
if(n%i==0)return false;
}
return true;
}
int main(){
int n;
cin >> n;
if(n == 1){
cout <<"4\n2 3 5 7";
}else if(n==2)cout<<"1\n11";
else if(n==4||n==6||n==8) cout<<"0";
else{
int len = n/2;
int mn = pow(10,len-1);
int mx = pow(10,len)-1;
int cnt;
vector<int> res;
for(int i = mn;i <= mx;++i){
vector<int> hui(10,i);
int temp = i;
for(int i = 0;i < 10;++i){
hui[i]=hui[i]*10+i;

}
while(temp!=0){
for(int i = 0;i < 10;++i){
hui[i]=hui[i]*10+temp%10;
}
temp/=10;
}
//            cout<<i<<endl;
for(int i = 0;i < 10;++i){
if(isP(hui[i]))res.push_back(hui[i]);
//                cout << hui[i]<<" ";
}
}
cout << res.size()<<endl;
for(int i = 0;i < res.size();++i){
cout <<res[i]<<" ";
}
}
return 0;
}
``````

# NOI 22:因子分解 唯一分解定理

#### 题目

http://noi.openjudge.cn/ch0113/22/

#### 源码

``````//
//  22.cpp
//  test
//
//  Created by bytedance on 2020/9/7.
//

#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

int ps[1000];
int main(){
int n;
cin >> n;
memset(ps,0,sizeof(ps));
for(int i = 2;i < 1000;++i){
for(int j = i*2;j<1000;j+=i){
ps[j] = 1;
}
}
string res = "";
for(int i = 2;i<1000;++i){
if(ps[i]==1||n==1)continue;
int cnt = 0;
while(n%i==0){
n/=i;
cnt++;
}
if(cnt!=0){
if(cnt==1)res=res+"*"+to_string(i);
else res=res+"*"+to_string(i)+"^"+to_string(cnt);
}
}
res.erase(res.begin());
cout <<res;
return 0;
}

``````