【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,问需要多少个小红点能全部占领 解法:乘 ...
随机推荐
- javascript simple MVC
<h3>javascript simple MVC</h3> <div> <select name="" id="setAnim ...
- 问题解决 —— Http Status 500
在完成JavaWeb项目的过程中经常会出现这种错误 500:指的是服务器内部错误 通常遇到这种情况,我会去看控制台的信息,那里肯定会有提示,空指针(值没有传过去),或者java.sql.SQLExce ...
- poj 3469(网络流模版)
题目链接:http://poj.org/problem?id=3469 思路:终于把网络流的模版测试好了,在Dinic和Sap之间还是选择了Sap,事实证明Sap确实比Dinic效率高,在此贴出自己的 ...
- GUN C中的socket学习(一)
socket是用于通信的工具. 套接字其实是一个广义上的进程间通信的信道.就像pipe一样,在GUN环境下socket也被用一个文件表示.不同的socket文件可以用于不同的进程间通信,甚至可以用来在 ...
- 在PC端或移动端应用中接入商业QQ
前两天在做一个项目XXX的时候,遇见一个问题,在页面中需要接入企业的QQ,在查找腾讯API后无果,则请求人工服务,然后人家给一网址(就是API接口),然后你只需要登录你的QQ,然后选择相应的显示类型, ...
- 转:: 刺鸟:用python来开发webgame服务端(1)
来源:http://ciniao.me/article.php?id=9 --------------- 刺鸟原创文章,转载请注明出处 在开始之前,先简单描述一下项目的特点:我要实现的是一个mm ...
- Core Services层
本文转载至 http://jingyan.baidu.com/article/cdddd41c57360853cb00e124.html Core Services层是系统很多部分的基础部分,也许应用 ...
- [Spring Data Repositories]学习笔记--为repository添加通用的方法
如果想把一个方法加到所有的repository中,用前一篇提到的方法就不合适了. 英文原版,请看 http://docs.spring.io/spring-data/data-mongo/docs/1 ...
- web容器 web服务器 servlet/jsp容器 之间的区别和关系是什么?
web容器 web服务器 servlet/jsp容器 之间的区别和关系是什么? 这是我在网上找的一些资料:1. Web浏览器除了可以在本地硬盘上打开网页文档外,还可以使用http网络协议从网络上的We ...
- 自制的几个jquery插件
1.颜色插件,比用css方便些 //1.插件编写 ;(function ($) { $.fn.extend({ "color":function(value){ return th ...