Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- vector <ll> s;
- ll check(ll n, ll a, ll b, ll c, ll d){
- return (a*n*n*n+b*n*n+c*n+d);
- }
- void poisk(ll n, ll a, ll b, ll c, ll d){
- for (ll i = 1; i*i <= abs(n); i++){
- if (n % i == 0){
- if (check(i, a, b, c, d) == 0)
- s.push_back(i);
- if (check(n/i, a, b, c, d) == 0)
- s.push_back(n/i);
- if (check(-1*i, a, b, c, d) == 0)
- s.push_back(-1*i);
- if (check(-1*n/i, a, b, c, d) == 0)
- s.push_back(-1*n/i);
- }
- }
- }
- int main(){
- ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- ll a, b, c, d;
- cin >> a >> b >> c >> d;
- if (a == 0 and b == 0 and c == 0 and d == 0){
- cout << -1;
- return 0;
- }
- if (a != 0 and b!=0 and c==0 and d==0 or a == 0 and b == 0 and c != 0 and d == 0 or a == 0 and b != 0 and c == 0 and d == 0 or a != 0 and b == 0 and c == 0 and d == 0 or a != 0 and b == 0 and c != 0 and d == 0 or a!= 0 and b!=0 and c!=0 and d==0)
- s.push_back(0);
- if (a == 0 and b != 0 and c != 0 and d == 0 or a != 0 and b == 0 and c != 0 and d == 0 or a!= 0 and b!=0 and c!=0 and d==0)
- poisk(c, a, b, c, d);
- if (a != 0 and b!=0 and c==0 and d==0)
- poisk(b, a, b, c, d);
- poisk(d, a, b, c, d);
- sort(s.begin(), s.end());
- s.erase((unique(s.begin(), s.end())), s.end());
- cout << s.size();
- for (ll i = 0; i < s.size(); i++)
- cout << " " << s[i];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement