Source code for submission s1012

Go to diff to previous submission

all.cpp

  1. #include <algorithm>
  2. #include <cctype>
  3. #include <cmath>
  4. #include <cstdio>
  5. #include <cstring>
  6. #include <iostream>
  7. #include <list>
  8. #include <map>
  9. #include <queue>
  10. #include <set>
  11. #include <sstream>
  12. #include <stack>
  13. #include <string>
  14. #include <utility>
  15. #include <vector>
  16. using namespace std;
  17.  
  18. #define DEBUG(x) cerr << ">> " << #x << ": " << x << endl;
  19. #define REP(i,a) for (int i =0; i < (a);++i)
  20. #define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
  21.  
  22. int n;
  23. char c,c2;
  24.  
  25. int main() {
  26. while (cin >> c >> c2 >> n)
  27. {
  28. /*
  29.   for (int n = 1; n < 100; n++)
  30.   {
  31.   cout << "n is " << n << ": ";
  32.   */int count = 0;
  33.  
  34.  
  35. for (int x = n+1; x <= 2*n;x++)
  36. {
  37. if ((n * x) % (x-n) == 0)
  38. {
  39. count++;
  40. //cout << "(" << ((n * x) / (x-n)) << "," << x << ") ";
  41. }
  42. }
  43. printf("%d\n", count);
  44. }
  45. return 0;
  46. }

Diff to submission s667

two2.cpp

--- c5.s667.cteam014.fl.cpp.0.two2.cpp
+++ c5.s1012.cteam014.fl.cpp.0.all.cpp
@@ -20,47 +20,27 @@
 #define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
 
-char pom;
 int n;
-unsigned long long x,y; 
-unsigned long long lft, rght;
-int counter = 0;
-bool once = false;
+char c,c2;
+
 int main() {
-  // while (scanf("%d%d",) != EOF)
-  while ( cin >> pom >> pom >> n ){
-      int x = n + 1;
-      y = x;
-      counter = 0;              
-      lft= n * ( x + y );
-      rght = x * y;
-      while ( true ){    
-        if ( lft == rght ){
-          once = false; 
-          //cout << "reseni " << x << " " << y;
-          x = x + 1;
-          y = x;
-          lft= n * ( x + y );
-          rght = x * y;
-          counter++;              
-        } else if ( lft < rght ){
-          if ( !once ){
-            //moc velka x a y
-            break;
-          }
-          x++;
-          y = x;
-          lft= n * ( x + y );
-          rght = x * y;
-          once = false;
-        } else {
-          once=true;
-          y++;    
-          lft = lft + n;
-          rght = rght + x;
-        }
+   while (cin >> c >> c2 >> n) 
+   {
+  /*
+  for (int n = 1; n < 100; n++)
+  {
+    cout << "n is " << n << ": ";
+    */int count = 0;
+    
+    
+    for (int x = n+1; x <= 2*n;x++)
+    {
+      if ((n * x) % (x-n) == 0)
+      {
+        count++;
+          //cout << "(" << ((n * x) / (x-n)) << "," << x << ") ";
       }
-      cout << counter << endl;
-      
-  }
+    }
+    printf("%d\n", count);
+  }  
   return 0;
 }
\ No newline at end of file