您的位置:首页 > 其它

Coderforces Nearly Lucky Number

2017-06-15 08:55 363 查看
http://codeforces.com/problemset/problem/110/A

import java.util.Scanner;

public class Nearly_Lucky_Number {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long n = scanner.nextLong();
//计数幸运数字的个数
int count = 0;
while(n >0) {
long temp = n % 10;
if(temp == 4 || temp == 7) count++;
n = n /10;
}
if(count == 0) {
System.out.println("NO");
return ;
}
boolean flag = lucky(count);
if(!flag) {
for(int i = 2; i*i <= n; i++) {
if(n % i == 0 && (lucky(i) || lucky(count/i))) {
System.out.println("YES");
return;
}
}
System.out.println("NO");
} else {
System.out.println("YES");
}
}

public static boolean lucky(int n) {
while(n > 0) {
int temp = n %10 ;
if(temp != 4 && temp != 7) {
return false;
}
n = n /10;
}
return true;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: