Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- int main()
- {
- const int N = 1000000;
- int* arr = new int[N + 1];
- double start = clock() * 1.0 / CLOCKS_PER_SEC;
- for (int i = 0; i <= N; i++)
- {
- arr[i] = 0;
- }
- for (int i = 1; i <= N; i++)
- {
- for (int j = i + i; j <= N; j += i)
- arr[j] += i;
- }
- for (int i = 1; i <= N; i++)
- {
- if (arr[i] <= N && arr[i] != i && arr[arr[i]] == i)
- std::cout << arr[i] << " " << i << std::endl;
- }
- delete[]arr;
- double end = clock() * 1.0 / CLOCKS_PER_SEC;
- std::cout << end - start << "sec" << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement