Source code for submission s713

Go to diff to previous submission

fl.cpp

  1. #include <stdio.h>
  2. #include <set>
  3.  
  4. using namespace std;
  5.  
  6. void solve(int n){
  7. int p = 1, y = n + 1, max = 2 * n;
  8.  
  9. while(y < max){
  10. if(!((n * y) % (y - n))){
  11. p++;
  12. }
  13. y++;
  14. }
  15.  
  16. printf("%d\n", p);
  17. }
  18.  
  19. int main(){
  20. int a, n;
  21. char c;
  22.  
  23. while(scanf("%d%c%d ", &a, &c, &n) == 3){
  24. solve(n);
  25. }
  26. }
  27.  

Diff to submission s641

fl.cpp

--- c5.s641.cteam052.fl.cpp.0.fl.cpp
+++ c5.s713.cteam052.fl.cpp.0.fl.cpp
@@ -5,30 +5,10 @@
 
 void solve(int n){
-        set<int> checked;
-        
-        int p = 0, y = n + 1, max = 2000000000;
-        bool first = true;
+        int p = 1, y = n + 1, max = 2 * n;
 
         while(y < max){
-                //printf("y %d\n", y);
-                //printf("max %d\n", max);
-                
-                if(checked.count(y)){
-                        y++;
-                        continue;
-                }
-                double d = (double)n * y / (y - n);
-                int x = (int)d;
-                checked.insert(x);
-                
-                if(x == d){
-                        if(first){
-                                max = x;
-                                first = false;
-                        }
-                        
+                if(!((n * y) % (y - n))){
                         p++;
                 }
-                
                 y++;
         }