You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
492 B
C++
26 lines
492 B
C++
#include <cstdio>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
bool check(int x)
|
|
{
|
|
int sum = 0;
|
|
for (int i = 1; i < x; i++)
|
|
if (x % i == 0)
|
|
sum += i;
|
|
return sum == x;
|
|
}
|
|
int main()
|
|
{
|
|
int a, b, n, x;
|
|
scanf("%d", &n);
|
|
while (n--)
|
|
{
|
|
x = 0;
|
|
scanf("%d%d", &a, &b);
|
|
if (a > b) swap(a, b);
|
|
for (int i = a; i <= b; i++)
|
|
if (check(i)) x++;
|
|
printf("%d\n", x);
|
|
}
|
|
return 0;
|
|
} |