Note that there are some explanatory texts on larger screens.

plurals
  1. PO10341 - Solve It WA
    primarykey
    data
    text
    <p>I was working on this problem from the ACM Uva webpage, and I've tried every single input from the forums, and it works perfectly. It keeps giving me "Wrong answer", and as I'm not an english speaker, maybe I'm forgetting something. Maybe someone from here had submitted this solution. This is the 5th submit I've made from this problem and it's always wrong. Thanks a lot. EDIT:</p> <p>Solve the equation:</p> <blockquote> <blockquote> <p>p*e-x + q*sin(x) + r*cos(x) + s*tan(x) + t*x2 + u = 0</p> <p>where 0 &lt;= x &lt;= 1.</p> </blockquote> </blockquote> <p>Input</p> <p>Input consists of multiple test cases and terminated by an EOF. Each test case consists of 6 integers in a single line: p, q, r, s, t and u (where 0 &lt;= p,r &lt;= 20 and -20 &lt;= q,s,t &lt;= 0). There will be maximum 2100 lines in the input file.</p> <p>Output</p> <p>For each set of input, there should be a line containing the value of x, correct upto 4 decimal places, or the string "No solution", whichever is applicable.</p> <pre><code>#include &lt;math.h&gt; #include &lt;stdio.h&gt; #define eps 0.00001 int p, q, r,s,t,u; long double fdex(long double x) { long double res=p*exp(-x)+ q*sin(x)+r*cos(x)+s*tan(x)+t*x*x+u; return res; } int main() { freopen("input.txt","rt",stdin); freopen("output.txt","wt",stdout); long double x,inf,sup,fx; while(scanf("%d %d %d %d %d %d\n",&amp;p, &amp;q, &amp;r,&amp;s,&amp;t,&amp;u)!=EOF) { long double x1; inf=0.0; sup=1.0; if (p==0 &amp;&amp; q==0 &amp;&amp; r==0 &amp;&amp; s==0 &amp;&amp; t==0) printf("0.0000\n"); else if((fdex(inf)*fdex(sup)&gt;0.0)) printf("No solution\n"); else { do { x=(inf+sup)/2.0; fx=fdex(x); if(fx&gt;eps) { inf=x; } else if(fx&lt;-eps) { sup=x; } }while( fx&lt;-eps || fx&gt;eps); printf("%.4llf\n",x); } } } </code></pre> <p><a href="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=24&amp;page=show_problem&amp;problem=1282" rel="nofollow">Problem</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload