hdu2099 整除的位數(暴力)
阿新 • • 發佈:2017-05-23
ring content .cn lan using div math 整數 沒有
Problem Description
http://acm.hdu.edu.cn/showproblem.php?pid=2099
一個整數,僅僅知道前幾位。不知道末二位,被還有一個整數除盡了,那麽該數的末二位該是什麽呢? Input 輸入數據有若幹組,每組數據包括二個整數a,b(0<a<10000, 10<b<100),若遇到0 0則處理結束。
Output 相應每組數據,將滿足條件的全部尾數在一行內輸出,格式見樣本輸出。
Sample Input
Sample Output
http://acm.hdu.edu.cn/showproblem.php?pid=2099
一個整數,僅僅知道前幾位。不知道末二位,被還有一個整數除盡了,那麽該數的末二位該是什麽呢? Input 輸入數據有若幹組,每組數據包括二個整數a,b(0<a<10000, 10<b<100),若遇到0 0則處理結束。
Output 相應每組數據,將滿足條件的全部尾數在一行內輸出,格式見樣本輸出。
同組數據的輸出,其每一個尾數之間空一格,行末沒有空格。
Sample Input
200 40
1992 95
0 0
Sample Output
00 40 80 15 題目分析; 直接暴力就可以。 AC代碼:/** *直接暴力模擬 */ #include<iostream> #include<cstdio> #include<map> #include<cstring> #include<string> #include<algorithm> #include<queue> #include<vector> #include<stack> #include<cstdlib> #include<cctype> #include<cstring> #include<cmath> using namespace std; int main() { int a,b,s; while(cin>>a>>b&&(a+b>0)){ int ok=0;//控制輸出空格 for(int i=0;i<=9;i++){ for(int j=0;j<=9;j++){ s=a*100+i*10+j; if(s%b==0){ if(!ok){ cout<<i<<j; ok=1; } else cout<<" "<<i<<j; } } } cout<<endl; } return 0; }
hdu2099 整除的位數(暴力)