-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhalf_sushu.cpp
More file actions
68 lines (58 loc) · 822 Bytes
/
half_sushu.cpp
File metadata and controls
68 lines (58 loc) · 822 Bytes
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
#include<map>
#include<iostream>
#include<cmath>
using namespace std;
int sushu(int n)
{
if(n==1)
return 0;
else
{
if(n==2)
return 1;
else
{
int i=2;
for(;i<=(int)sqrt(n);i++)
{
if((n%i)==0)
{
// return 1;
break;
}
}
if(i>(int)sqrt(n))
return 1;
else
return 0;
}
}
}
int main(void)
{
map<int,int> map_;
//map_.insert(pair<int,int>(1,1));
cout<<sushu(6)<<endl;
int n;
cin>>n;
if(!sushu(n))
{
cout<<"no"<<endl;
}
else
{
for(int i=2;i<=sqrt(n);i++)
{
if(n%i==0)
map_.insert(pair<int,int>(i,n/i));
}
}
for(map<int,int>::iterator it=map_.begin();it!=map_.end();it++)
{
// cout<<it->first<<" "<<it->second<<endl;
if(sushu(it->first)&&sushu(it->second))
{
cout<<it->first<<" "<<it->second<<endl;
}
}
}