Source code for submission s1079

Go to diff to previous submission

druhy.cpp

  1. #include<stdlib.h>
  2. #include<stdio.h>
  3.  
  4.  
  5. int main(){
  6. int n;
  7. int pole[1000];
  8. char a, b;
  9. bool pom = true;
  10.  
  11. while(scanf("%c %c %d \n",&a, &b, &n)==3)
  12. {
  13. pom = true;
  14. int sum = 0;
  15. int pocet = 0;
  16. for(int y = n+1; y<n*n+2; y++)
  17. {
  18.  
  19. //if(y-n > 0)
  20. //{
  21. if((n*y)%(y-n)==0)
  22. {
  23. for(int i = 0; i <pocet; i++)
  24. {
  25. if(pole[i]==y || pole[i] == (n*y)/(y-n))
  26. {
  27. pom = false;
  28. break;
  29. }
  30.  
  31. }
  32. if(pom)
  33. {
  34. pole[pocet] = y;
  35. pole[pocet +1] = (n*y)/(y-n);
  36. pocet += 2;
  37. sum++;
  38. pom = true;
  39. }
  40. }
  41.  
  42. //}
  43.  
  44.  
  45. }
  46. printf("%d\n", sum);
  47. }
  48.  
  49. return 0;
  50. }
  51.  

Diff to submission s1040

druhy.cpp

--- c5.s1040.cteam068.fl.cpp.0.druhy.cpp
+++ c5.s1079.cteam068.fl.cpp.0.druhy.cpp
@@ -14,9 +14,9 @@
                 int sum = 0;
                 int pocet = 0;
-                for(int y = 2; y<n*n+2; y++)
+                for(int y = n+1; y<n*n+2; y++)
                 {
                         
-                        if(y-n > 0)
-                        {
+                        //if(y-n > 0)
+                        //{
                                 if((n*y)%(y-n)==0)
                                         {
@@ -40,5 +40,5 @@
                                         }
                                 
-                        }
+                        //}