結果

問題 No.2622 Dam
ユーザー ayataka5
提出日時 2024-02-09 22:02:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 1,886 ms
コンパイル使用メモリ 192,516 KB
最終ジャッジ日時 2025-02-19 03:39:24
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int T;
    cin >> T;
    while(T--) {
        long long V, X;
        int F0, F1, Q, R;
        cin >> V >> X >> F0 >> F1 >> Q >> R;
        long long A((long long)(F1 - F0) * (long long)R), B(-(long long)F0 * (long long)(Q - R));
        string ans;
        if(A + B < 0) {
            if(X + A <= V) { ans = "Zero"; }
            else { ans = "Overflow"; }
        }
        if(0 < A + B) {
            if(X + A + B <= 0) { ans = "Zero"; }
            else { ans = "Overflow"; }
        }
        if(A + B == 0) {
            if(V <= X + A) { ans = "Overflow"; }
            else { ans = "Safe"; }
        }
        cout << ans << endl;
    }
    return 0;
}
0