返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         int K,N,total;
  7.         re:
  8.         cin>>N>>K;
  9.         if(N<1||N>500000||K<1||K>9)
  10.         {
  11.                 goto re;
  12.         }
  13.         for(int i=1;i<=N;i++)
  14.         {
  15.                 if(i%K==0)
  16.                 {       
  17.                         total+=1;
  18.                 }       
  19.                 else if(i%10==K||i/10==K)
  20.                 {
  21.                         if(i%10>=10||i/10>K)
  22.                         {
  23.                                 i/10;
  24.                         }
  25.                         else
  26.                         {
  27.                                 total+=1;
  28.                         }
  29.                 }
  30.         }
  31.         cout<<total;
  32.         system("pause");
  33.         return 0;
  34. }
複製代碼

TOP

返回列表