1. #include <stdio.h>
2. #include <math.h>
3. #define ERROMAX 0.0001
4.
5. int main (void) {
7. int falsosPositivos = 0;
8. for ( int cat1 = 1 ; cat1 <= 100 ; cat1++ )
9. for ( int cat2 = cat1 ; cat2 <= 100 ; cat2++ )
10. for ( int hip = 1 ; hip <= 100 ; hip++ ) {
11. int semConversao = (hip == sqrt(pow(cat1,2) + pow(cat2,2)));
12. int inteiro = (hip == (int)sqrt(pow(cat1,2) + pow(cat2,2)));
14. int maxErro = (fabs((float)hip - sqrt(pow(cat1,2) + pow(cat2,2))) < ERROMAX);
16. printf("(%d,%d,%d) %d%d%d%d\n", cat1, cat2, hip,
18. }
19. else if ( inteiro ) {
20. falsosPositivos++;
21. }
22. }
23. printf("\nFalsos positivos: %d\n", falsosPositivos);
24.
26. falsosPositivos = 0;
27. for ( float cat1 = 0.1 ; cat1 <= 10 ; cat1 += 0.1 )
28. for ( float cat2 = cat1 ; cat2 <= 10 ; cat2 += 0.1 )
29. for ( float hip = 0.1 ; hip <= 10 ; hip += 0.1 ) {
30. int semConversao = (hip == sqrt(pow(cat1,2) + pow(cat2,2)));
31. int inteiro = (hip == (int)sqrt(pow(cat1,2) + pow(cat2,2)));
33. int maxErro = (fabs((float)hip - sqrt(pow(cat1,2) + pow(cat2,2))) < ERROMAX);
35. printf("(%f,%f,%f) %d%d%d%d\n", cat1, cat2, hip,
37. }
38. else if ( inteiro ) {
39. falsosPositivos++;
40. }
41. }
42. printf("\nFalsos positivos: %d\n", falsosPositivos);
43. return 0;
44. }
Success #stdin #stdout 0.47s 2008KB
stdin
Standard input is empty
stdout
(3,4,5) 1111
(5,12,13) 1111
(6,8,10) 1111
(7,24,25) 1111
(8,15,17) 1111
(9,12,15) 1111
(9,40,41) 1111
(10,24,26) 1111
(11,60,61) 1111
(12,16,20) 1111
(12,35,37) 1111
(13,84,85) 1111
(14,48,50) 1111
(15,20,25) 1111
(15,36,39) 1111
(16,30,34) 1111
(16,63,65) 1111
(18,24,30) 1111
(18,80,82) 1111
(20,21,29) 1111
(20,48,52) 1111
(21,28,35) 1111
(21,72,75) 1111
(24,32,40) 1111
(24,45,51) 1111
(24,70,74) 1111
(25,60,65) 1111
(27,36,45) 1111
(28,45,53) 1111
(28,96,100) 1111
(30,40,50) 1111
(30,72,78) 1111
(32,60,68) 1111
(33,44,55) 1111
(33,56,65) 1111
(35,84,91) 1111
(36,48,60) 1111
(36,77,85) 1111
(39,52,65) 1111
(39,80,89) 1111
(40,42,58) 1111
(40,75,85) 1111
(42,56,70) 1111
(45,60,75) 1111
(48,55,73) 1111
(48,64,80) 1111
(51,68,85) 1111
(54,72,90) 1111
(57,76,95) 1111
(60,63,87) 1111
(60,80,100) 1111
(65,72,97) 1111

Falsos positivos: 3934

(0.300000,0.400000,0.500000) 0001
(0.500000,1.200000,1.300000) 0001
(0.600000,0.800000,1.000000) 0001
(0.700000,2.400000,2.500000) 0001
(0.800000,1.500000,1.700000) 0001
(0.900000,1.200000,1.500000) 0001
(0.900000,3.999998,4.099998) 0001
(1.000000,2.400000,2.600000) 0001
(1.100000,5.999997,6.099997) 0001
(1.200000,1.600000,2.000000) 0001
(1.200000,3.499999,3.699999) 0001
(1.300000,8.399996,8.499996) 0001
(1.400000,4.799998,4.999998) 0001
(1.500000,2.000000,2.500000) 0001
(1.500000,3.599999,3.899998) 0001
(1.600000,2.999999,3.399999) 0001
(1.600000,6.299996,6.499996) 0001
(1.800000,2.400000,2.999999) 0001
(1.800000,7.999995,8.199995) 0001
(2.000000,2.100000,2.899999) 0001
(2.000000,4.799998,5.199997) 0001
(2.100000,2.799999,3.499999) 0001
(2.100000,7.199996,7.499995) 0001
(2.400000,3.199999,3.999998) 0001
(2.400000,4.499998,5.099998) 0001
(2.400000,6.999996,7.399995) 0001
(2.500000,5.999997,6.499996) 0001
(2.700000,3.599999,4.499998) 0001
(2.799999,4.499998,5.299997) 0001
(2.999999,3.999998,4.999998) 0001
(2.999999,7.199996,7.799995) 0001
(3.199999,5.999997,6.799996) 0001
(3.299999,4.399998,5.499997) 0001
(3.299999,5.599997,6.499996) 0001
(3.499999,8.399996,9.099998) 0001
(3.599999,4.799998,5.999997) 0001
(3.599999,7.699995,8.499996) 0001
(3.899998,5.199997,6.499996) 0001
(3.899998,7.999995,8.899998) 0001
(3.999998,4.199998,5.799997) 0001
(3.999998,7.499995,8.499996) 0001
(4.199998,5.599997,6.999996) 0001
(4.499998,5.999997,7.499995) 0001
(4.799998,5.499997,7.299995) 0001
(4.799998,6.399996,7.999995) 0001
(5.099998,6.799996,8.499996) 0001
(5.399997,7.199996,8.999998) 0001
(5.699997,7.599995,9.500000) 0001
(5.999997,6.299996,8.699997) 0001
(6.499996,7.199996,9.700001) 0001

Falsos positivos: 0