Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- bool prime(int n) {
- if (n < 2) return false;
- for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
- return true;
- }
- signed main() {
- ios::sync_with_stdio(0);
- cin.tie(0); cout.tie(0);
- int maxn = 0, ma, mb;
- for (int a = -999; a < 1000; a++) {
- for (int b = -1000; b < 1001; b++) {
- int n = 0;
- while (prime(n * n + a * n + b)) ++n;
- if (n > maxn) {
- maxn = n;
- ma = a;
- mb = b;
- }
- }
- }
- cerr << ma << ' ' << mb << endl;
- cout << ma * mb;
- }
Advertisement
Add Comment
Please, Sign In to add comment