mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-07 18:06:58 +08:00
Add FZOI Codes
This commit is contained in:
37
FZOI/亲密数对.cpp
Normal file
37
FZOI/亲密数对.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int sumOfDivisors(int n) {
|
||||
int sum = 0;
|
||||
for (int i = 2; i * i <= n; i++) {
|
||||
if (n % i == 0) {
|
||||
if(i * i != n)
|
||||
{
|
||||
sum += i;
|
||||
sum += n / i;
|
||||
}
|
||||
else{
|
||||
sum += i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int N;
|
||||
cin >> N;
|
||||
|
||||
for (int i = 2; i <= N; i++) {
|
||||
for(int j = 2; j <= N; ++ j)
|
||||
{
|
||||
if(sumOfDivisors(i) == j && sumOfDivisors(j) == i && i != j)
|
||||
{
|
||||
cout << i << " " << j << endl ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user