-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnakseo.cpp
69 lines (58 loc) · 1.26 KB
/
nakseo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <string>
#include <vector>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int number = 1000001; // 구하고자 하는 소수의 범위
int primeNum[1000001];
bool isPrime(int n)
{
// Corner case
if (n <= 1)
return false;
// Check from 2 to n-1
for (int i = 2; i < sqrt(n); i++)
if (n % i == 0)
return false;
return true;
}
string n_jinsu(int n, int k){
int nn = n;
string ret;
while(nn!=0){
int mod = nn%k;
nn=nn/k;
ret+=char(48+mod);
}
reverse(ret.begin(),ret.end());
return ret;
}
int solution(int n, int k) {
int answer = 0;
string njinsu = n_jinsu(n,k);
string nowint;
for(int i=0;i<njinsu.size();i++){
if(njinsu[i]!='0')
nowint+=njinsu[i];
if(njinsu[i]=='0' || i==njinsu.size()-1) {
if(nowint!=""){
long long now = stoll(nowint);
if(isPrime(now))
answer++;
}
nowint="";
continue;
}
}
return answer;
}
int main(){
vector<vector<int>> v;
vector<int> vv(10,0);
v.push_back(vv);
v.push_back(vv);
cout<<v.size()<<' '<<v[0].size();
}