烦人的TLE

P1035 [NOIP2002 普及组] 级数求和

fioerjfo @ 2023-12-06 18:35:39

为啥我TLE了,小白求助!


by OldDriverTree @ 2023-12-06 19:00:44

@fioerjfo 你不发代码我怎么帮你?


by immortal_water @ 2023-12-06 19:20:03

@fioerjfo 1/n换成1.0/n


by immortal_water @ 2023-12-06 19:21:59

@fioerjfo 1,n是整数,在赋值给sum前会按整数除法算出0,然后导致死循环


by Kelly_1 @ 2023-12-18 10:31:44

或者声明n的时候用double,输出的时候用%.0lf


by Whl0924 @ 2023-12-18 15:10:17

@fioerjfo 你要发代码!


by Silversnowflake @ 2023-12-31 15:23:26

@fioerjfo 发一下代码,才能帮你看


|