CF221B Little Elephant and Numbers 题解
思路
按题意模拟即可。
在
注意:如果
#include <bits/stdc++.h>
using namespace std;
int a[10], b[10];
int x, ans, t;
bool check(int n)
{
memset(b, 0, sizeof b);
for(; n;) b[n % 10] = 1, n /= 10;
for(int i = 0; i < 10; ++ i)
if(a[i] && b[i])
return 1;
return 0;
}
main()
{
cin >> x;
t = x;
for(; t;) b[t % 10] = 1, t /= 10;
for(int i = 1; i <= x / i; ++ i)
if(x % i == 0)
{
ans += check(i);
if(x / i != i)
ans += check(x / i);
}
cout << ans;
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步