Settings
|
Sign in
|
Sign up
Bar
Post
Home
>
Bar 藍橋杯
>
View post
Reply the post
|
View author only
There are currently
28
posts.
First
Previous
1
2
3
Next
Last
編譯有錯誤
Floor 11
fengtianru117
11/27/15 8:19
前五個是正確的 後五個錯誤
Floor 12
fengtianru117
11/27/15 8:19
Floor 13
巨大八爪鱼
11/27/15 8:20
回復:11樓
只看第一個就行了
後五個都是歷史記錄而已
Floor 14
fengtianru117
11/27/15 8:20
Floor 15
fengtianru117
11/27/15 8:21
說明:請注意這裡的數據規模。
本題直接的想法是直接使用一個循環來累加,然而,當數據規模很大時,這種「暴力」的方法往往會導致超時。此時你需要想想其他方法。你可以試一試,如果使用1000000000作為你的程序的輸入,你的程序是不是能在規定的上面規定的時限內運行出來。
本題另一個要值得注意的地方是答案的大小不在你的語言默認的整型(int)範圍內,如果使用整型來保存結果,會導致結果錯誤。
如果你使用C++或C語言而且準備使用printf輸出結果,則你的格式字符串應該寫成%I64d以輸出long long類型的整數。
Floor 16
fengtianru117
11/27/15 8:22
可能是因為帖子長度限制 後面我都用文字的形式發出來
Floor 17
巨大八爪鱼
11/27/15 8:23
我知道了。因為數據類型是long long,所以在printf輸出的時候應該寫的是%I64d而不是%d
Floor 18
巨大八爪鱼
11/27/15 8:24
還有就是最好用首項加末項的方式來算,因為數據規模很大。
Floor 19
fengtianru117
11/27/15 8:28
6666
Floor 20
fengtianru117
11/27/15 8:28
非常棒的解答
First
Previous
1
2
3
Next
Last
Content converter:
No conversion
Mainland
Taiwan
Hong Kong
Singapore
Reply the post
Content:
User:
You are currently anonymous.
Captcha:
Unclear? Try another one.