相亲数.c 395 B

12345678910111213141516171819202122232425
  1. #include <stdio.h>
  2. int xiangqin(int x) {
  3. printf("%d,",x);
  4. int i,result = 1;
  5. for(i = x; i > 1; i--) {
  6. if(x % i == 0 && i != 1 && i != x) {
  7. printf("%d+",i);
  8. result += i;
  9. }
  10. }
  11. printf("1=%d\n",result);
  12. return result;
  13. }
  14. int main() {
  15. int a,b;
  16. scanf("%d %d",&a,&b);
  17. int xa = xiangqin(a);
  18. int xb = xiangqin(b);
  19. if(xa == b && xb == a) printf("1");
  20. else printf("0");
  21. return 0;
  22. }