【水】HDU2075 A|B?
阿新 • • 發佈:2018-12-14
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 24999 Accepted Submission(s): 18889 Problem Description 正整數A是否能被正整數B整除,不知道為什麼xhd會研究這個問題,來幫幫他吧。 Input 輸入資料的第一行是一個數據T,表示有T組資料。 每組資料有兩個正整數A和B(A,B<10^9)。 Output 對於每組輸入資料,輸出"YES"表示可以被整除,"NO"表示不能被整除。 Sample Input 2 4 2 5 3 Sample Output YES NO Author xhd Source ACM程式設計期末考試_熱身賽(感謝 xhd & 8600) Recommend lcy | We have carefully selected several similar problems for you: 2057 2096 2054 2090 2082
做取模運算,如果模為0則輸出YES; else 輸出 NO;程式碼如下:
#include<iostream> using namespace std; int main() { int t,a,b; cin>>t; while(t--) { cin>>a>>b; if(a%b==0) cout<<"YES"<<endl; else cout<<"NO"<<endl; } }