Editorial for WC '15 Contest 4 J1 - Telling Time
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Given a positive integer and a list of other positive integers, this question asks to find the number of integers in the list which are multiples of . The solution is to just loop through the list and check if each integer is a multiple of . If so, increment a running counter variable.
Checking if a number is a multiple of can be done with the modulo (or remainder) operator in most programming languages (the %
operator in C++/Java/Python, for instance). That is, is a multiple of if and only if is equal to . Since we loop through an array of size , this runs in .
Comments