【HackerRank】 Find Digits
2024-09-01 13:55:09
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;
} }
最新文章
- UITableView使用
- 读取.properties配置文件
- AspJpeg使用 .
- 深入webx框架(li)
- ASP.NET MVC Json()处理大数据异常解决方法,字符串的长度超过了为 maxJsonLength
- Windows Server 2012 R2在桌面上顯示我的電腦等圖示
- mysql基本命令(转)
- Java 遍历Map时 删除元素
- poj3714Raid(平面最近点对)
- 如何在腾讯云快速构建一个Wordpress个人站点
- DBA_Tablespace表空间的概念和管控(概念)
- mysql变量使用总结
- UIBezierPathStudyDemo
- Metaspace 之二--Java 8的元空间(metaspace)、metaspace监控方法
- osg 笔记一 (转)
- (二)Java对象与内存控制
- hdu4717 The Moving Points 三分法
- css字体设置
- replication factor
- Quartz2.2.x官方教程