Codeforces Round #136 (Div. 2)——B
来源:互联网 发布:喷泉动画小软件 编辑:程序博客网 时间:2024/06/09 17:15
B. Little Elephant and Numbers
time limit per test
2 secondsmemory limit per test
256 megabytesinput
standard inputoutput
standard outputThe Little Elephant loves numbers.
He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations.
Help the Little Elephant to find the described number.
Input
A single line contains a single integer x (1 ≤ x ≤ 109).
Output
In a single line print an integer — the answer to the problem.
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;int a[20];int b[20];int getnum(int x){ memset(b,0,sizeof(b)); int i=0; while(x) { b[i++]=x%10; x/=10; } return i-1;}int getn(int x){ memset(a,0,sizeof(a)); int i=0; while(x) { a[i++]=x%10; x/=10; } return i-1;}int main(){ int n,cnt=0,i,j,k; scanf("%d",&n); int lena=getn(n); int p=sqrt(n); if(n==1) { printf("1\n"); return 0; } for(i=1; i<=p; i++) if(n%i==0) { int lenb=getnum(i); int t=0; for(j=0; j<=lena; j++) { for(k=0; k<=lenb; k++) if(a[j]==b[k]) { cnt++; t=1; if(i*i==n) cnt--; break; } if(t==1) break; } lenb=getnum(n/i); t=0; for(j=0; j<=lena; j++) { for(k=0; k<=lenb; k++) if(a[j]==b[k]) { cnt++; t=1; break; } if(t==1) break; } } printf("%d\n",cnt); return 0;}
- Codeforces Round #136 (Div. 2)——B
- Codeforces Round #154 (Div. 2)——B
- Codeforces Round #156 (Div. 2)——B
- Codeforces Round #151 (Div. 2)——B
- Codeforces Round #152 (Div. 2)——B
- Codeforces Round #149 (Div. 2)——B
- Codeforces Round #146 (Div. 2)——B
- Codeforces Round #144 (Div. 2)——B
- Codeforces Round #142 (Div. 2)——B
- Codeforces Round #157 (Div. 2)——B
- Codeforces Round #134 (Div. 2)——B
- Codeforces Round #141 (Div. 2)——B
- Codeforces Round #140 (Div. 2)——B
- Codeforces Round #137 (Div. 2)——B
- Codeforces Round #135 (Div. 2)——B
- Codeforces Round #124 (Div. 2)——B
- Codeforces Round #123 (Div. 2)——B
- Codeforces Round #117 (Div. 2)——B
- PBT技术的产生与发展
- linux进程后台运行的几种方法
- 更改pushViewController和popViewController的动画效果
- 各种基本算法实现小结(六)—— 查找算法
- 性能分析:处理器、磁盘I/O、进程、网络分析方法
- Codeforces Round #136 (Div. 2)——B
- iPhone/iPad 参考网站
- pushViewController自定义动画(转)
- 各种基本算法实现小结(一)—— 链 表
- 银行系统1(改进)
- [乐意黎原创] 基于selenium生成Csdn 博客文章简索的excel文件
- Linux tail 命令详解
- java中遍历HashMap的方法
- php 框架学习