Source code for submission s472

Go to diff to previous submission

fl.cpp

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

Diff to submission s464

fl.cpp

--- c5.s464.cteam042.fl.cpp.0.fl.cpp
+++ c5.s472.cteam042.fl.cpp.0.fl.cpp
@@ -8,13 +8,14 @@
                 int ans = 0;
                 int ans2 = 0;
-                for(int x = 1; x < 10000*n; x++) {
+                for(int x = 1; x<1000000; 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++;
+                                        else ans+=2;
                                 }
                         }