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. mysql存储引擎的种类与差别(innodb与myisam)

    查找数据库的存数引擎: show engines show variables like '%storage_engine%' 更改数据库的引擎更改配置文件/etc/my.cnf 改动default- ...

  2. Win2k8&&vCenter部署全流程

    几个不同的组件 vCenter Server:对ESXi主机进行集中管理的服务器端软件,安装在windows server 2008R2或以上的操作系统里,通过SQL 2008R2 或以上版本的数据库 ...

  3. Vsphere笔记07 Vcenter 部署流程 2

    7.Vcenter 部署流程 2   Vcenter 安装需求   1.硬件要求 CPU:支持VT-X技术并开启内存:4G或4G 以上   2.系统要求 Windows 2008 R2 x64 Vsp ...

  4. Eclipse Debug 调试

    Debug 调试 Java 程序 我们可以在 Package Explorer 视图调试 Java 程序,操作步骤如下: 鼠标右击包含 main 函数的 java 类 选择 Debug As > ...

  5. websocket数据流解析

    ceilometer获取数据暂时先不做解答,本篇注重websocket解决浏览器与openstack组件之间的实时状态更新. 大致流程如下: nginx配置的反向代理如下: /etc/nginx/ng ...

  6. openstack组件通讯端口定义

    openstack 组件通讯是通过ZeroMQ+ceilometer发送组件调用信息,具体是通过TCP通讯,发送数据和接收数据是用同一个端口(在配置文件指定),下面通过代码稍作解析: IceHouse ...

  7. node.js调用函数

    首先EditPlus编辑器,打开新建的文本文档,另存为副本 调用函数分为调用本地函数,和其他文件的函数 1.调用本地函数 var http = require('http'); http.create ...

  8. linux下不错的小软件

    1.Shutter截图软件 可以完成基本截图功能,而且还有图片编辑功能,可以涂鸦添加水印等. 以下的截图全部归功于shutter软件. 2.VLC media player 媒体播放器 3.Termi ...

  9. Restoring Road Network

    D - Restoring Road Network Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem State ...

  10. Palindrome Function

    Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 256000/256000 K (Java/Others)Total Submissio ...