Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 16, 2017 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invatainfo/f7000973b32e2f5a5a7a77706413abc5 to your computer and use it in GitHub Desktop.
Save invatainfo/f7000973b32e2f5a5a7a77706413abc5 to your computer and use it in GitHub Desktop.
#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