ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1142. Relations

Whats wrong with my formula?
Posted by Dijkztra 14 Nov 2009 09:33
z = fact(z)/(2*pow(log(2),n+1));

if(fmod(z,1)>=0.5) z = floor(z) + 1;
else z = floor(z);


I tried the example test case and got true, but got WA with 1st test case... T_T
Re: Whats wrong with my formula?
Posted by [MSU Detritus] freopen 25 Aug 2010 16:29
I sent your formula and got AC. Try to output answer so:

cout << fixed << setprecision(0) << z;

or so:

printf("%.0lf",z);

And you must use double instead of float
Re: Whats wrong with my formula?
Posted by yangdong 18 Oct 2010 18:12
function g(x,k:longint):comp;
var i:longint; q:comp;
begin
    q:=1;
    for i:=1 to k do q:=q*i;
        g:=q*x;
end;
var
f:array[0..20,0..20] of longint;
a:array[0..20] of comp;
    i,j,n,k:longint;
begin
for i:=0 to 10 do begin f[i,1]:=1; f[i,i]:=1; end;
f[0,1]:=0;
for i:=1 to 10 do
    for j:=2 to i-1 do f[i,j]:=f[i-1,j-1]+f[i-1,j]*j;
for i:=2 to 10 do
    for j:=1 to 10 do a[i]:=a[i]+g(f[i,j],j);
readln(n);
    while n>0 do
        begin
        writeln(a[n]:0:0);
        readln(n);
        end;
end.