#include #include #include #include #define asdigit(c) (c - '0') #define LOG(x) cout << #x << "=" << (x) << endl; using namespace std; string analyze_pid(string word); int main(int argc, char **argv) { int n,s; while (true) { int n,s; cin >> n; if (!n) break; cin >> s; int days[n]; int nmax[n]; for (int i=0; i> days[i]; nmax[i] = 0; } int skip = 0, loop = 0; int last_max_i = -1; for (int i=0; i i) { nmax[i] = days[last_max_i]; skip++; continue; } int act_max = i+1; loop++; for (int j=i+2; j 0) cout << max-s+s%days[mi]; else cout << "0"; cout << endl; } return 0; }