【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,问需要多少个小红点能全部占领 解法:乘 ...
随机推荐
- LeetCode406. Queue Reconstruction by Height Add to List
Description Suppose you have a random list of people standing in a queue. Each person is described b ...
- ORACLE函数之日期时间转换函数
1. TO_CHAR 语法:TO_CHAR(X [,format]) 说明:将X按format格式转换成字符串.X是一个日期或者数字.format是一个规定了X採用何种格式转换 ...
- 【Mac + Appium】之运行报错:[UiAutomator] UiAutomator exited unexpectedly with code 0, signal null
产生下面的原因是因为:与uiautomator2的weditor冲突,两者不能同时使用. 有时打开appium时会报错: [UiAutomator] UiAutomator exited unexpe ...
- A Survey of Shape Feature Extraction Techniques中文翻译
Yang, Mingqiang, Kidiyo Kpalma, and Joseph Ronsin. "A survey of shape feature extraction techni ...
- Eclipse 首选项(Preferences)
Eclipse 首选项(Preferences) 设置首选项 该对话框可通过框架管理但是其他插件可以设置其他页面来管理首选项的配置. 我们可以通过 Window 菜单选择 Preferences 菜单 ...
- kafka 集群--3个broker 3个zookeeper创建实战
准备工作: 1. 准备3台机器,IP地址分别为:192.168.0.10,192.168.0.11,192.168.0.12 2. 下载kafka稳定版本,我的版本为:kafka_2.9.2-0.8. ...
- Git安装部署
1.1 最新git源码下载地址 https://github.com/git/git/releases https://www.kernel.org/pub/software/scm/git/ 1.2 ...
- jetty;linux 目录结构
[说明]今天看了看jetty这个web容器,上午看基础理论框架知识(后面半点没用到),下午下载了jetty,并且在上面部署了一个war应用,晚上在做eclipses整合jetty的时候出现了问题,下载 ...
- 【BZOJ1803】Spoj1487 Query on a tree III 主席树+DFS序
[BZOJ1803]Spoj1487 Query on a tree III Description You are given a node-labeled rooted tree with n n ...
- IIS无法连接LocalDb,怎么办?
最近安装了vs 2013,电脑配置不太好,所以没有安装数据库,直接使用vs2013自带的localdb工具,直接运行访问本地mdf数据库文件.但是部署到IIS就出问题了.问题就像下面的图片一样. 最后 ...