【HackerRank】 Find Digits
2014-07-30 10:08
387 查看
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.
题解:
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】Utopian tree
- 【HackerRank】Game Of Rotation
- [hackerrank]Closest Number
- 【HackerRank】Pairs
- HackerRank# Stock Maximize
- Hackerrank - [Algo] Matrix Rotation
- HackerRank Extra long factorials
- HackerRank "Median Updates"
- HackerRank Truck Tour
- HackerRank "Manasa and Prime game"
- HackerRank "Favorite sequence"
- [HackerRank] Time Conversion
- HackerRank Fibonacci Modified
- [Hackerrank-algorithm-warmup]题解
- 【HackerRank】Functional Palindromes(回文树+后缀数组+lcp排序+字符串哈希+二分)
- 【Hacker Rank】02.Reading Raw Input
- Hackerrank How many substrings
- Codewars, Leetcode, Hackerrank. Online Judges Reviews
- hackerrank 和 leetcode的链表相关的题目的总结
- Hackerrank (70)Range Modular Query 莫队+暴力