Codeforces 221 B. Little Elephant and Numbers
2 seconds
256 megabytes
standard input
standard output
The 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 andd have at least one common (the same) digit in their decimal representations.
Help the Little Elephant to find the described number.
A single line contains a single integer x (1 ≤ x ≤ 109).
In a single line print an integer — the answer to the problem.
- 1
- 1
- 10
- 2
- 题意:输出是x的因子且与x有相同数字的因子个数
- #include<cstdio>
- #include<cmath>
- using namespace std;
- int x,ans;
- bool v[];
- int main()
- {
- scanf("%d",&x);
- int n=sqrt(x),m=x;
- while(x) { v[x%]=true; x/=; }
- int k,j,i;
- for(k=;k<=n;k++)
- if(m%k==)
- {
- j=m/k;i=k;
- while(i)
- {
- if(v[i%])
- {
- ans++; break;
- }
- i/=;
- }
- if(j==k) continue;
- while(j)
- {
- if(v[j%])
- {
- ans++; break;
- }
- j/=;
- }
- }
- printf("%d",ans);
- }
Codeforces 221 B. Little Elephant and Numbers的更多相关文章
- Codeforces 221 E. Little Elephant and Shifts
E. Little Elephant and Shifts time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- Codeforces 221 D. Little Elephant and Array
D. Little Elephant and Array time limit per test 4 seconds memory limit per test 256 megabytes input ...
- Codeforces 221 C. Little Elephant and Problem
C. Little Elephant and Problem time limit per test 2 seconds memory limit per test 256 megabytes inp ...
- Codeforces 221 A. Little Elephant and Function
A. Little Elephant and Function time limit per test 2 seconds memory limit per test 256 megabytes in ...
- AC日记——Little Elephant and Numbers codeforces 221b
221B - Little Elephant and Numbers 思路: 水题: 代码: #include <cmath> #include <cstdio> #inclu ...
- Codeforces 221d D. Little Elephant and Array
二次联通门 : Codeforces 221d D. Little Elephant and Array /* Codeforces 221d D. Little Elephant and Array ...
- Codeforces Round #131 (Div. 1) B. Numbers dp
题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory ...
- Codeforces Beta Round #51 D. Beautiful numbers 数位dp
D. Beautiful numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/p ...
- Educational Codeforces Round 13 A. Johny Likes Numbers 水题
A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...
随机推荐
- 20181016-4 Alpha阶段第2周/共2周 Scrum立会报告+燃尽图 05
作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2288 Scrum master:王硕 一.小组介绍 组长:王一可 组员:范 ...
- 软件工程 speedsnail 第二次冲刺10
20150527 完成任务:蜗牛碰到线后速度方向的调整:已经基本实现多方向的反射: 遇到问题: 问题1 反射角的问题 解决1 利用tan()三角函数 明日任务: 大总结.找到新问题.布置下一次冲刺方案
- 用P4对数据平面进行编程
引言 SDN架构强调了对控制平面的可编程,数据平面只负责转发,导致数据平面很大程度上受制于功能固定的包处理硬件. P4语言的特性: 目标无关性:P4语言不受制于具体设备,所有可编程芯片都可以使用P4编 ...
- lintcode-65-两个排序数组的中位数
65-两个排序数组的中位数 两个排序的数组A和B分别含有m和n个数,找到两个排序数组的中位数,要求时间复杂度应为O(log (m+n)). 样例 给出数组A = [1,2,3,4,5,6] B = [ ...
- 利用canvas对上传图片进行上传前压缩
利用谷歌调式工具发现,图片大小直接影响着首屏加载时间. 且考虑到后期服务端压力,图片压缩特别必要. 本文是前端利用canvas实现图片.参考文章:https://www.cnblogs.com/007 ...
- libnl3.2.25安装编译
1,tar zxvf libnl-3.2.25.tar.gz 2,cd libnl-3.2.25 3,./configure --prefix=/usr --sysconfdir=/etc --d ...
- PHP面向对象之重写
覆盖(override): 基本概念 覆盖,又叫“重写”: 含义: 将一个类从父类中继承过来的属性和方法“重新定义”——此时相当于子类不想用父类的该属性或方法,而是想要定义. 覆盖的现实需要: 对于一 ...
- Spring MVC @RequestParam @RequestHeader @CookieValue用法
摘要: package com.hust.springmvc1; import org.springframework.stereotype.Controller; import org.spring ...
- Redis 备份数据的两种方式
既然是数据库,那就一定有数据备份方式了,而且 Redis 是内存形式的数据库,更需要数据备份了,要不然断电数据就全都丢失了. Redis 数据备份有两种方式: RDB(数据快照) AOF(记录操作日志 ...
- 【linux使用】bash shell命令行常用快捷键
移动: Ctrl + A: 移动到当前编辑的命令行首, Ctrl + E: 移动到当前编辑的命令行尾, Ctrl + F 或 ->:按字符右移(往命令行尾部方向,前移) Ctrl + B 或 & ...