Created
September 16, 2017 15:00
-
-
Save invatainfo/f7000973b32e2f5a5a7a77706413abc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream.h> | |
int f(int n) { | |
int s = 0, d = 2; | |
while (n > 1) | |
if (n % d == 0) { | |
s++; | |
n = n / d; | |
} else | |
d++; | |
return s; | |
} | |
void main() { | |
int n, x, y, z; | |
cin >> n; | |
if (n < 10) | |
if (f(n) == 1) | |
cout << "da"; | |
else | |
cout << "nu"; | |
else if (n < 100) | |
if (f(n) == 1 && f(n % 10 * 10 + n / 10) == 1) | |
cout << "da"; | |
else | |
cout << "nu"; | |
else { | |
x = n / 100; | |
y = n / 10 % 10; | |
z = n % 10; | |
if (f(n) == 1 && f(x * 100 + z * 10 + y) == 1 && | |
f(y * 100 + x * 10 + z) == 1 && f(y * 100 + z * 10 + x) == 1 && | |
f(z * 100 + x * 10 + y) == 1 && f(z * 100 + y * 10 + x) == 1) | |
cout << "da"; | |
else | |
cout << "nu"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment