// General Statement:  Read a value N followed by 10 numbers.
// Determine how many of the 10 numbers will divide N evenly (without remainder).

// Input:  The first line in the data file is an integer that represents 
// the number of data sets to follow.   Each data set will contain 11 numbers. 
// The first number is the number to divide.  
// The ten numbers that follow will be used to divide the first number.

// Name of Data File : pr00.dat
// 
// Output:  Output how many of the 10 numbers divide evenly into the first number. 
// SAMPLE OUTPUT: 5 of the numbers go evenly into 20.
// 
// Assumptions:  Dividing by zero is a very bad thing.
// NOTICE: THIS IS A HINT!  I CHANGED MY DATA FILE TO INCLUDE A ZERO CASE RIGHT AWAY
import java.util.*; // Needed for Scanner objects
import java.io.*; // Needed for File objects

public class GoEvenly {
	public static void main(String[] args) {
		File f = new File("pr00.dat"); // File is in same folder as code
		
		try { // Hey, Java, give this a shot, but I know there might be a problem
			Scanner s = new Scanner(f); // read input from the file
			int inputCount = Integer.valueOf(s.nextLine()); // read the value on the firt line as a number
			for(int i = 0; i < inputCount; i++) { // loop over every line
				String line = s.nextLine(); // get the line
				Scanner lineScan = new Scanner(line); // build Scanner on the line
				int dividCount = 0; // start a divisor counter at 0
				int num = lineScan.nextInt(); // get number to divide
				while(lineScan.hasNextInt()) { // loop over all numbers to try and divide
					int toDivide = lineScan.nextInt();
					if(toDivide != 0 && // avoid division by 0
					   num % toDivide == 0) { // if evenly divisible
						dividCount++;
					}
				}
				System.out.println(dividCount + " of the numbers go evenly into " + num + ".");
			}
		} catch(FileNotFoundException e) { // If the file isn't found, catch the error
			System.out.println(e);          // and print it (instead of crashing)
		}
	}
}
