結果

問題 No.2208 Linear Function
ユーザー nono00
提出日時 2023-02-10 23:09:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 191,212 KB
最終ジャッジ日時 2025-02-10 13:33:16
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define rrep(i, r, l) for (int i = (int)(r); i > (int)(l); i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()


void solve() {
    int l, r, a, b;
    cin >> l >> r >> a >> b;
    if (a == 0) {
        cout << b << '\n';
    } else if (a > 0) {
        cout << (a * r + b) << '\n';
    } else {
        cout << (a * l + b) << '\n';
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
0