Here is my soln
#include
#include
#include
#define lli long long int
#define s(x) scanf("%lld", &x)
using namespace std;
int main() {
// your code goes here
lli min,tcase,max,i,j,k,temp,cnt;
char arr[165];
min = 1;
max = 161;
cnt = 0;
int a[8];
s(tcase);
while (tcase--) {
//cout << tcase << endl;
cnt = 0;
for (i = 0; i < 8; ++i)
s(a[i]);
for (i = 0; i < max; ++i)
arr[i] = '#';
arr[max] = '\0';
for (i = 0; i < 8; ++i) {
for (j = 1; j < max; ++j) {
if ((arr[j] == '#') && (j%(i+2) != 0) && (a[i] > 0)) {
arr[j] = '1';
--a[i];
if (cnt < j)
cnt = j;
}
}
}
printf("%lld\n", cnt);
}
return 0;
}
Can any 1 give me test case or point out my mistake and tell me why it is getting WA in KOPC12D??
Thnx for ur help…