Wednesday, September 08, 2010

[UVa] 10050 - Hartals

It's just a simulation. Mods and Mods that's all.


#include <stdio.h>
int parties[101];
int main() {
int I, J, T, N, P, COUNT;
scanf("%d",&T);
while (T--) {
scanf("%d",&N);
scanf("%d",&P);
for (I=0 ; I<P ; I++) {
scanf("%d",&parties[I]);
}
for (I=1, COUNT=0 ; I<=N ; I++) {
if ((I%7)!=6 && (I%7)!=0) {
for (J=0 ; J<P ; J++) {
if (!(I%parties[J])) {
COUNT++;
break;
}
}
}
}
printf("%d\n",COUNT);
}
return 0;
}

4 comments:

  1. Anonymous1:02 PM

    this give wrong answer. why?

    ReplyDelete
  2. Which one? My code? I tested it again. It got Accepted. If you're getting Wrong Answer with your code, please kindly pass it to me so that I can debug it. You can use ideone or codepad.org to paste the codes.

    ReplyDelete
  3. http://ideone.com/0hAOjU
    check this one please.

    ReplyDelete
  4. why do u use T-- on the while and not scanf("%d",&T) and a T--; down?

    ReplyDelete

Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...