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. linux无密登录

    ssh-keygen -t rsa ssh-copy-id -i ~/.ssh/id_rsa.pub bigdata@cor2

  2. tp 大致执行流程

    http://www.thinkphp.cn/code/305.html http://document.thinkphp.cn/manual_3_2.html#wechat

  3. Android 图片压缩的方法大全

    public static Bitmap revitionImageSize(String path) throws IOException { BufferedInputStream in = ne ...

  4. Asp.net 基于Cookie简易的权限判断

    基于Cookie简易的权限判断代码,需要的朋友可以参考下. 写入Cookie页面,创建cookie后,设置cookie属性,并添加到Response.Cookies中读取cookie,利用cookie ...

  5. Caffe模型读取

    caffe模型最终保存使用过的protobuf形式,将一个已经训练好的caffe模型读取出来,可以参考如下: 1,包含的头文件: #include <google/protobuf/io/cod ...

  6. php简单工厂模式

    工厂类中有一个创建对象的方法,根据传入参数的不同来生成不同的对象 class Operation extends Model{ private $numberA; private $numberB; ...

  7. filter、map函数的区别

    def even(num): if num%2==0: return True return False lis = [1,2,3,4,5,6,7,8,9] res = filter(even,lis ...

  8. [Spring MVC]学习笔记--@RequestMapping支持的返回类型

    下面针对官方文档列出的支持类型进行举例. (本篇例子存于github上, https://github.com/lemonbar/spring-mvc-requestmapping) 可以直接下载, ...

  9. EasyNVR摄像机无插件直播进行摄像机云台控制的接入及调用详解

    EasyNVR云台接入及控制详解 摄像机云台控制在摄像机当中很常见摄像机能将当前状态下云台的水平角度.倾斜角度和摄像机镜头焦距等位置参数存储到设备中,需要时可以迅速调用这些参数并将云台和摄像头调整至该 ...

  10. java 对list 排序

    Comparable用Collections.sort方法对list排序有两种方法第一种是list中的对象实现Comparable接口,如下: /*** 根据order对User排序*/public  ...