#55195: cpp_answer


yp11451202@yphs.tp.edu.tw (705-38黃鈺潤)


#include <iostream>
#include <vector>
#include <string>

using namespace std;

// 五次多項式計算,使用 __int128 完美防溢位
__int128 f_128(long long x, long long a, long long b, long long c, long long d, long long e, long long f) {
    __int128 X = x;
    return ((((a * X + b) * X + c) * X + d) * X + e) * X + f;
}

int main() {
    // 提升 I/O 效率
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    long long a, b, c, d, e, f_coef;
    
    // 多筆測資直到檔案結束 (EOF)
    while (cin >> a >> b >> c >> d >> e >> f_coef) {
        
        // 特殊情況 1:恆等於 0,也就是所有係數皆為 0 時,有無限多組根
        if (a == 0 && b == 0 && c == 0 && d == 0 && e == 0 && f_coef == 0) {
            cout << "Too many... = =\"\n";
            continue;
        }
        
        vector<string> answers;
        
        // 依照題目提示,由小到大掃描整數區間
        for (int x = -35; x <= 35; x++) {
            __int128 fx = f_128(x, a, b, c, d, e, f_coef);
            
            // 點根判定:如果恰好等於 0
            if (fx == 0) {
                answers.push_back(to_string(x) + " " + to_string(x));
            }
            
            // 區間根判定:嚴格一正一負
            if (x < 35) {
                __int128 fx_next = f_128(x + 1, a, b, c, d, e, f_coef);
                if ((fx > 0 && fx_next < 0) || (fx < 0 && fx_next > 0)) {
                    answers.push_back(to_string(x) + " " + to_string(x + 1));
                }
            }
        }
        
        // 輸出判定
        if (answers.empty()) {
            // 特殊情況 2:無實根
            cout << "N0THING! >\\\\\\<\n"; // C++ 中反斜線 \ 需要用 \\ 來轉義
        } else {
            for (const string& ans : answers) {
                cout << ans << "\n";
            }
        }
    }
    
    return 0;
}