Pages

3/09/2014

UVA 10050 Hartals Java Solution

import java.util.*;;

public class Main {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
while (tc-- >0) {
int noOfDays = sc.nextInt();
//int[] weekList = new int[noOfDays+1];
int[] parties = new int [sc.nextInt()];
for(int i=0; i<parties.length;i++){
parties[i]= sc.nextInt();
}
int ctr =0;
outer:
for (int i =1 ;i<=noOfDays;i++) {
if (!(i%7==6 || i%7==0)){
for (int j =0;j< parties.length; j++ ) {
if ( i%parties[j]==0) {
ctr++;
continue outer;
}
}
}
}
System.out.println(ctr);

}
}

}

No comments :

Post a Comment