221B - Little Elephant and Numbers
思路:
水题;
代码:
#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int n,ans=0; bool if_[11]; int main() { scanf("%d",&n); int pos=n; while(pos>0) if_[pos%10]=true,pos/=10; for(int i=1;i<=sqrt(n);i++) { if(n%i==0) { pos=i; while(pos>0) { if(if_[pos%10]) { ans++; break; } pos/=10; } pos=n/i; while(pos>0) { if(if_[pos%10]) { ans++; break; } pos/=10; } } } if(sqrt(n)*sqrt(n)==n) { pos=sqrt(n); while(pos>0) { if(if_[pos%10]) { ans--; break; } pos/=10; } } cout<<ans; return 0; }