Add FZOI Codes

This commit is contained in:
2024-06-26 22:14:00 +08:00
parent 8f564ca60e
commit b80791cfad
49 changed files with 1653 additions and 0 deletions

37
FZOI/亲密数对.cpp Normal file
View 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;
}