-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProblem_#27_Quadratic_primes.cpp
53 lines (52 loc) · 1.09 KB
/
Problem_#27_Quadratic_primes.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
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
int prime(int n){
if(n < 2) return false;
for(int i=2;i*i<=n;i++){
if(n%i == 0){
return false;
}
}
return true;
}
int main(){
int n; scanf("%d", &n);
int ans = 0;
int A, B;
for(int i=-n;i<=n;i++){
for(int j=-n;j<=n;j++){
//n^2 + i*n + j
int primes = 0;
for(int k=0;;k++){
if(prime(k*k+i*k+j)){
primes++;
}else{
break;
}
}
if(primes > ans){
//cout << primes<<endl;
ans = primes;
A = i;
B = j;
}
}
}
cout << A<<" "<<B <<endl;
}