-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1013_ans.cpp
48 lines (47 loc) · 994 Bytes
/
1013_ans.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
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int x)
{
for (int i = 2; i <= sqrt(x); i++)
{
if (x % i == 0)
{
return false;
}
}
return true;
}
int main()
{
int sub_prime = 0, print_prime = 0;
int m, n;
cin >> m >> n;
int if_print_space = 0;
for (int i = 2;; i++)
{
if (isPrime(i))
{
sub_prime++;
if (sub_prime >= m)
{
if (if_print_space == 1)
{
cout << " ";
}
cout << i;
print_prime++;
if_print_space = 1;
if (print_prime % 10 == 0)
{
cout << "\n";
if_print_space = 0;
}
}
if (sub_prime == n)
{
break;
}
}
}
return 0;
}