#24144: c,c++都能過,而python第二測資就是TLE


doppler (doppler)


python要如何優化?

輸入已優化sys.stdin.readline()

輸出已優化sys.stdout.write()

還要怎麼優化,測資二就是TLE

 

#24145: Re:c,c++都能過,而python第二測資就是TLE


asnewchien@gmail.com (david)


python要如何優化?

輸入已優化sys.stdin.readline()

輸出已優化sys.stdout.write()

還要怎麼優化,測資二就是TLE

 


您好像誤以爲,只要輸出入優化就一定能ac

#24151: Re:c,c++都能過,而python第二測資就是TLE


doppler (doppler)


python要如何優化?

輸入已優化sys.stdin.readline()

輸出已優化sys.stdout.write()

還要怎麼優化,測資二就是TLE

 


您好像誤以爲,只要輸出入優化就一定能ac

不是喔!是這題應該無法用python AC吧!

 

 

 

#24152: Re:c,c++都能過,而python第二測資就是TLE


doppler (doppler)


python要如何優化?

輸入已優化sys.stdin.readline()

輸出已優化sys.stdout.write()

還要怎麼優化,測資二就是TLE

 


您好像誤以爲,只要輸出入優化就一定能ac

是想請教您是怎麼寫的!

 

 

 



#24153: Re:c,c++都能過,而python第二測資就是TLE


asnewchien@gmail.com (david)


那您是怎寫的

#24154: Re:c,c++都能過,而python第二測資就是TLE


doppler (doppler)


那您是怎寫的


謝謝喔!!用python AC了!!只是寫了好幾種方式!!只有這種字串的方式過的!不知高手您怎麼寫的!

        a,b,n=sys.stdin.readline().split()        

        k=str(int(a)*10**int(n)//int(b))

        l= len(k)-int(n)

        ans=''

        if l>0:

            print('%s.%s'%(k[:l],k[l:len(k)]))

        else:

            ans='0'*(abs(l))

            k=ans+k

            print('0.%s'%(k))   

 

#24157: Re:c,c++都能過,而python第二測資就是TLE


asnewchien@gmail.com (david)


差不多的方法啦。

#24158: Re:c,c++都能過,而python第二測資就是TLE


doppler (doppler)


差不多的方法啦。


下次還有問題,請不吝賜教,感謝!