【題解】Codeforces 1492A. Three swimmers

【題目敘述】http://codeforces.com/contest/1492/problem/A

#include <iostream>
using namespace std;
 
int t;
long long p, a, b, c;
 
int main() {
    cin >> t;
    while (t--){
        cin >> p >> a >> b >> c;
        cout << min((a-(p%a))%a, min((b-(p%b))%b, (c-(p%c))%c)) << "\n";
    }
}
分享本文 Share with friends