Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>;
- using namespace std;
- int sum_num(int x) {
- int answ = 0;;
- while (x > 0) {
- answ += x % 10;
- x /= 10;
- }
- return answ;
- }
- bool elementary(int x) {
- for (int i = 2; i < x; i++) {
- if (x % i == 0) {
- return false;
- }
- }
- return true;
- }
- int sum_mn(int x) {
- int answ = 0;
- while (x != 1) {
- for (int i = 2; i <= x; i++) {
- if (x % i == 0 && elementary(i)) {
- if (answ == 0 && i == x) {
- return -1;
- }
- else {
- answ += sum_num(i);
- x /= i;
- break;
- }
- }
- }
- }
- return answ;
- }
- int main() {
- std::ifstream fin("input.txt");
- std::ofstream fout("output.txt");
- vector<int> a;
- int x;
- while (fin >> x) {
- a.push_back(x);
- }
- for (int i = 0; i < a.size(); i++) {
- if (sum_num(a[i]) == sum_mn(a[i])) {
- fout << '1';
- }
- else {
- fout << '0';
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment