2018 腾讯笔试 算法题
今天运气比较好,做的几个算法题还算简单,第一遍本来想先用暴力解法解出来再慢慢调通过率,结果居然一遍就过了,
其实思路很简单,没有任何技巧可言,估计是给的测试用例太少所以侥幸一遍过了,最近笔试多,挖个坑后面再调优吧
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); for(int j=1; j <= num; j++){ int A = sc.nextInt(); int B = sc.nextInt(); int C = sc.nextInt(); for (int i = 1; i <= 10000; i++) { if(i*A%B == C){ System.out.println("YES"); break; } if(i == 10000 && i*A%B != C){ System.out.println("NO"); } } } } }