Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- // determina suma divizorilor lui x
- // neconsiderandu-se numarul in sine
- unsigned int suma_div(unsigned int x) {
- unsigned int suma = 1;
- for(unsigned int div = 2; div <= x/2; ++div) {
- if(x%div == 0) {
- suma += div;
- }
- }
- return suma;
- }
- int main() {
- ifstream fin("numere.txt");
- unsigned int x, y;
- // citesc cat timp in fisier exista numere
- while(fin >> x >> y) {
- // daca (x, y) respecta conditia ceruta le afisez
- if(suma_div(x) == y+1 && suma_div(y) == x+1) {
- cout << x << " " << y << "\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement