Source code for submission s492

Go to diff to previous submission

fl.cpp

  1. #include <stdio.h>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. char tmp, tmp2;
  8. while(scanf("%c%c%d\n", &tmp, &tmp2, &n) == 3) {
  9. int ans = 0;
  10. int ans2 = 0;
  11. for(int x = n+1; x < 3*n; x++) {
  12. int prod = x*n;
  13. int y = prod/(x-n);
  14. if(y < x) break;
  15. if(y*(x-n) == prod) {
  16. int y = prod/(x-n);
  17. if(x == y)
  18. ans2++;
  19. else ans+=2;
  20. }
  21. }
  22. printf("%d\n", ans2+ans/2);
  23. }
  24. }
  25.  

Diff to submission s473

fl.cpp

--- c5.s473.cteam042.fl.cpp.0.fl.cpp
+++ c5.s492.cteam042.fl.cpp.0.fl.cpp
@@ -8,15 +9,13 @@
                 int ans = 0;
                 int ans2 = 0;
-                for(int x = 1; x<50000; x++) {
-                        long long prod = x*n;
-                        if(x == n) continue;
-                        if(prod % (x-n) == 0) {
-                                long long y = prod/(x-n);
-                                if(y < x) continue;//break;
-                                if(x > 0 && y > 0) {
-                                        if(x == y)
-                                                ans2++;
-                                        else ans+=2;
-                                }
+                for(int x = n+1; x < 3*n; x++) {
+                        int prod = x*n;
+                        int y = prod/(x-n);
+                        if(y < x) break;
+                        if(y*(x-n) == prod) {
+                                int y = prod/(x-n);
+                                if(x == y)
+                                        ans2++;
+                                else ans+=2;
                         }
                 }