SRM434 Div2 Level.1
5つの数値が与えられて、5つのうち最低でも3つの数値で割りきれる最小の数を求める問題。
総当たりで適当に解いた。
using System; using System.Collections.Generic; using System.Text; class LeastMajorityMultiple { public int leastMajorityMultiple(int a, int b, int c, int d, int e) { int[] array = new int[5]; array[0] = a; array[1] = b; array[2] = c; array[3] = d; array[4] = e; for (int i = 1; i < 1000000000; i++) { int count = 0; foreach (int j in array) { if (i % j == 0) { count++; } } if (count > 2) { return i; } } return 0; } }