Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long q,a,b,k;
  5. string l,r;
  6.  
  7. int valid(long long x){
  8.     int ret=0;
  9.     long long tem=x;
  10.     while(tem){
  11.         if(tem%10)
  12.             ret+=!(x%(tem%10));
  13.         tem/=10;
  14.     }
  15.     return ret>=k;
  16. }
  17.  
  18. int main(){
  19.     cin>>q;
  20.     while(q--){
  21.         cin>>a>>b>>k;
  22.         int ans=0;
  23.         for(long long i=a;i<=b;i++)
  24.             ans+=valid(i);
  25.         cout<<ans<<endl;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement