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的更多相关文章

  1. 【HDU4333】Revolving Digits(扩展KMP+KMP)

    Revolving Digits   Description One day Silence is interested in revolving the digits of a positive i ...

  2. 【LeetCode】Add Digits

    Add Digits Given a non-negative integer num, repeatedly add all its digits until the result has only ...

  3. 【02_258】Add Digits

    Add Digits Total Accepted: 49702 Total Submissions: 104483 Difficulty: Easy Given a non-negative int ...

  4. 【HackerRank】How Many Substrings?

    https://www.hackerrank.com/challenges/how-many-substrings/problem 题解 似乎是被毒瘤澜澜放弃做T3的一道题(因为ASDFZ有很多人做过 ...

  5. 【LeetCode】Reverse digits of an integer

    Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Have you ...

  6. 【HackerRank】Running Time of Quicksort

    题目链接:Running Time of Quicksort Challenge In practice, how much faster is Quicksort (in-place) than I ...

  7. 【HackerRank】 Sherlock and The Beast

    Sherlock and The Beast Sherlock Holmes is getting paranoid about Professor Moriarty, his archenemy. ...

  8. 【hackerrank】Week of Code 30

    Candy Replenishing Robot Find the Minimum Number 直接模拟 Melodious password dfs输出方案 Poles 题意:有多个仓库,只能从后 ...

  9. 【hackerrank】Week of Code 26

    在jxzz上发现的一个做题网站,每周都有训练题,题目质量……前三题比较水,后面好神啊,而且类型差不多,这周似乎是计数专题…… Army Game 然后给出n*m,问需要多少个小红点能全部占领 解法:乘 ...

随机推荐

  1. 解决pip安装模块报错Cannot fetch index base URL http://pypi.python.org/simple/

    产生这个问题的原因呢和github一样,因为他们用的cdn被墙.经小伙伴反馈,解决办法如下. 通过指定国内镜像源来安装: pip --trusted-host 镜像源 install 模块名 -i 镜 ...

  2. samba在linux下的配置

    Samba配置过程容易遇到的问题 samba的安装很简单,搜索一下都能找到.我主要是记录一上我碰到的问题及解决的办法 第一个问题 防火墙的问题,粗暴的办法是直接把防火墙关掉,合适的做法是把samba用 ...

  3. Web 层由 Web,Web-MVC,Web-Socket 和 Web-Portlet 组成

    Web 层由 Web,Web-MVC,Web-Socket 和 Web-Portlet 组成,它们的细节如下: Web 模块提供面向web的基本功能和面向web的应用上下文,比如多部分(multipa ...

  4. Using Swift with Cocoa and Objective-C下载

    <Using Swift with Cocoa and Objective-C Building App > 下载地址 http://download.csdn.net/detail/sw ...

  5. 使用PHP函数输出前一天的时间和后一天的时间

    1.明确date()函数和time()函数的功能,其中time()函数是获取时间戳函数 2.输出前一天的当前时间: echo '一天之前的时间为:'.date('Y-m-d H:i:s',time() ...

  6. go反射----2值

    声明:文章内容取自雨痕老师<Go语言学习笔记> 和Type获取类型信息不同,Value专注于对象实例数据读写. 在前面章节曾提到过,接口变量会复制对象,且是unaddressable的,所 ...

  7. Servlet注解

    在Servle2.5能够使用注解 在web.xml的<web-app>标签下有一属性metadata-complete="true"在设置true时,Servlet中的 ...

  8. 简单的c语言小程序 回光返照

    主函数 int main(int argc,char * argv[]) -- arg代表英文的参数缩写 c代表count计数 argc { return 0;  -- 0返还给系统,代表程序正确运行 ...

  9. activity通过流程实例id动态获取流程图并展示在jsp页面上

    提供的Service方法如下: Java /** * 获取当前任务流程图 * * @param processInstanceId * @return */ @Override public Inpu ...

  10. CAFFE学习笔记(五)用caffe跑自己的jpg数据

    1 收集自己的数据 1-1 我的训练集与测试集的来源:表情包 由于网上一幅一幅图片下载非常麻烦,所以我干脆下载了两个eif表情包.同一个表情包里的图像都有很强的相似性,因此可以当成一类图像来使用.下载 ...