|
|
back to board(C++)Got WA on test14, can you help me? #include <cstdlib> #include <iostream> #include <iomanip> using namespace std; int main(int argc, char *argv[]) {
double a,b,c,d,m,n=2,mn; cin>>a>>b; c=a/100; d=b/100; while (1) {m=1; while (m<n) {mn=m/n; if ((mn<d)&&(mn>c)) break; m++;} if (m!=n) break; n++;} cout<<n<<endl; system("PAUSE"); return EXIT_SUCCESS; } This is my project Got WA on test14. I think there's something wrong with digits But i cannot find it Can anyone help me with it? Thx! Re: (C++)Got WA on test14, can you help me? Posted by OpenGL 21 Mar 2010 00:07 I think, your mistake in precision. Try change: if ((mn<d)&&(mn>c)) -> if ((mn+eps<d)&&(mn-eps>c)) |
|
|