Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- using namespace std;
- bool search(int digit);
- int main()
- {
- ifstream fin("INPUT.TXT");
- ofstream fout("OUTPUT.TXT");
- int digit;
- cin >> digit;
- int idigit = digit;
- int k = 0;
- while (digit > 0)
- {
- k++;
- digit /= 10;
- }
- int *Array = new int[k];
- for (size_t i = 0; i < k; i++)
- {
- if (idigit % 10 == 0)
- {
- cout << "No";
- return 0;
- }
- *(Array + i) = idigit % 10;
- idigit /= 10;
- }
- int ten = k - 1, l = 0;
- for (size_t i = 1; i < 10; i++)
- {
- for (size_t j = 0; j < k; j++)
- {
- if (*(Array + j) == i)
- {
- digit = digit + i*pow(10, ten);
- if (l == 0 && i % 2 == 0)
- {
- cout << "No";
- return 0;
- }
- idigit = idigit + i*pow(10, l);
- l++;
- ten--;
- }
- }
- }
- if (search(digit) == true)
- {
- cout << "No";
- }
- else
- {
- if (search(idigit) == true)
- {
- cout << "No";
- }
- else
- {
- cout << "Yes";
- }
- }
- fin.close();
- fout.close();
- return 0;
- }
- bool search(int digit)
- {
- int k = 0;
- for (int i = 2; i <= digit/2; i++)
- {
- if (digit%i == 0)
- {
- return true;
- }
- }
- if (k == 0)
- {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement