maybe a floating point issue?

czylabsonasa nobody at dev.null
Fri Sep 19 08:31:07 UTC 2025


... and even the following `julia` code is OK:

```jl
# Anthony_and_Cora_anthony

const _DBG_=false

fT=Float64

function solveIt()
    rL()=readline()
    rT(S,T=Int)=parse(T,S)

    A,C=rT.(rL()|>split)
    p=fill(fT(0.0),A+C-1)
    for i in 1:A+C-1
       p[i]=rT(rL(),fT)
    end
    win=fill(fT(-1.0),A+1,C+1) # no OffsetArrays on the kattis site
    for i in 1:A
       win[1+i,1+0]=1.0
    end
    for j in 0:C
       win[1+0,1+j]=0.0
    end
    function Trav(a,c,k)
       if win[1+a,1+c]<-0.5
          Trav(a-1,c,k+1)
          Trav(a,c-1,k+1)
          win[1+a,1+c]=p[k]*win[1+a,1+c-1]+(1-p[k])*win[1+a-1,1+c]
       end
    end

    Trav(A,C,1)

    println(round(win[1+A,1+C];digits=7))
end

solveIt()


```
(sorry, but no syntax highlighting here for julia)

As i see, the kattis site is using the `-O2` switch for compiling 
the source, as usual.
In the old times - 10 years ago - i experienced striking 
differences w/ gcc/g++ w/
floating point computations depending on optimization is enabled 
or not. Because eventually the 3 codes are the same, i am 
supposing that this the root cause of the issue.



More information about the Digitalmars-d mailing list