【HackerRank】 Find Digits
Problem Statement
Given a number you have to print how many digits in that number exactly divides that number.
Input format
The first line contains T (number of test cases followed by t lines each containing n
Constraints
1 <=T <= 15
0 < N < 1010
Output Format
Number of digits in that number exactly divides that number.
题解:
import java.io.*;
import java.util.*; public class Solution { public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int i = 0; i < t; i++){
Long num = in.nextLong();
System.out.println(FindDigits(num));
}
} private static int FindDigits(Long num){ //Write code to solve each of the test over here
Long copy_num = num;
int count = 0;
while(num>0){
Long digit = num%10;
if(digit!=0 && copy_num%digit==0)
count++;
num /= 10;
}
return count;
} }
【HackerRank】 Find Digits的更多相关文章
- 【HDU4333】Revolving Digits(扩展KMP+KMP)
Revolving Digits Description One day Silence is interested in revolving the digits of a positive i ...
- 【LeetCode】Add Digits
Add Digits Given a non-negative integer num, repeatedly add all its digits until the result has only ...
- 【02_258】Add Digits
Add Digits Total Accepted: 49702 Total Submissions: 104483 Difficulty: Easy Given a non-negative int ...
- 【HackerRank】How Many Substrings?
https://www.hackerrank.com/challenges/how-many-substrings/problem 题解 似乎是被毒瘤澜澜放弃做T3的一道题(因为ASDFZ有很多人做过 ...
- 【LeetCode】Reverse digits of an integer
Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Have you ...
- 【HackerRank】Running Time of Quicksort
题目链接:Running Time of Quicksort Challenge In practice, how much faster is Quicksort (in-place) than I ...
- 【HackerRank】 Sherlock and The Beast
Sherlock and The Beast Sherlock Holmes is getting paranoid about Professor Moriarty, his archenemy. ...
- 【hackerrank】Week of Code 30
Candy Replenishing Robot Find the Minimum Number 直接模拟 Melodious password dfs输出方案 Poles 题意:有多个仓库,只能从后 ...
- 【hackerrank】Week of Code 26
在jxzz上发现的一个做题网站,每周都有训练题,题目质量……前三题比较水,后面好神啊,而且类型差不多,这周似乎是计数专题…… Army Game 然后给出n*m,问需要多少个小红点能全部占领 解法:乘 ...
随机推荐
- Spring MVC4使用Servlet3 MultiPartConfigElement文件上传实例
在这篇文章中,我们将使用Spring MultipartResolver 实现 StandardServletMultipartResolver在Servlet3环境中实现单点和多文件上传功能.Spr ...
- python django -5 进阶
高级知识点包括: 静态文件处理 中间件 上传图片 Admin站点 分页 使用jquery完成ajax 管理静态文件 项目中的CSS.图片.js都是静态文件 配置静态文件 在settings 文件中定义 ...
- 2017 css新特性
2017年要学习的三个CSS新特性 这是翻译的一篇文章,原文是:3 New CSS Features to Learn in 2017,翻译的不是很好,如有疑问欢迎指出. 新的一年,我们有一系列新的东 ...
- (转)Unity 导出XML配置文件,动态加载场景
参考:http://www.xuanyusong.com/archives/1919 http://www.omuying.com/article/48.aspx 主要功能: 1.导出场景的配置文 ...
- PHP和Java 加解密
http://www.jb51.net/article/64961.htm http://www.jb51.net/article/129218.htm http://www.jb51.net/art ...
- python数据分析之numpy
知乎:https://zhuanlan.zhihu.com/p/26514493 numoy安装:http://blog.csdn.net/wyc12306/article/details/53705 ...
- 第10章 Docker Machine 相关问题
10.1 打开命令行后,看到下载啥 boot2docker.iso,然后总是超时失败,怎么办? 装了 Docker Toolbox 的 Windows 用户,或者第一次使用 docker-machin ...
- SET ANSI_NULLS ON 在T-SQL中是什么意思
from:https://www.cnblogs.com/kekong/p/6731321.html Transact-SQL 支持在与空值进行比较时,允许比较运算符返回 TRUE 或 FALSE. ...
- IOS时间与日期处理
本文转载至 http://blog.sina.com.cn/s/blog_9cd1705d0102v5x4.html 主要有以下类: NSDate -- 表示一个绝对的时间点NSTimeZone ...
- iptables 实际操作 之 规则查询 2
在之前的文章中,我们已经总结过,iptables 为我们预定义了4张表,他们分别是raw 表,mangle表,nat表,filter表,不同的表拥有不同的功能. filter 负责过滤功能,比如允许那 ...