Go to diff to previous submission
#include <stdio.h> #include <vector> using namespace std; int main() { int n; char tmp, tmp2; while(scanf("%c%c%d\n", &tmp, &tmp2, &n) == 3) { int ans = 0; int ans2 = 0; 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; } } printf("%d\n", ans2+ans/2); } }
--- 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; } }