#54052: c++解法


0967104065 (Jcy)


int main() {
    int t;
    cin >> t;
    while (t--) {
        long long a, b, c, d;
        cin >> a >> b >> c >> d;

        if ((b - a) == (c - b) && (c - b) == (d - c)) {
            long long diff = b - a;
            cout << d + diff << "\n";
        }

        else {
            long long r = b / a;
            cout << d * r << "\n";
        }
    }
    return 0;
}
#54053: Re: c++解法


0967104065 (Jcy)


#include<iostream>
using namespace std;
int main(){
    int t;
    cin >> t;

    while(t--){
        int A[4];
        for(int i = 0; i < 4; i++)
            cin >> A[i];

        if(A[1] - A[0] == A[2] - A[1] && A[2] - A[1] == A[3] - A[2]){
            int d = A[1] - A[0];
            cout << A[0] << " " << A[1] << " " << A[2] << " " << A[3] << " " << A[3] + d << endl;
        }

        else{
            int r = A[1] / A[0];
            cout << A[0] << " " << A[1] << " " << A[2] << " " << A[3] << " " << A[3] * r << endl;
        }
    }

    return 0;
}