置頂

GeoGebra 文章目錄

GeoGebra 文章目錄  更新日期:2018/2/8 我將 GeoGebra 相關的文章及檔案連結都整理在這篇裡,之後如果有新的文章也會同時更新這個目錄。上傳到 GeoGebraTube 的檔案,我有試著用 Google Chrome 63.0.3239.13...

熱門文章

2026年5月29日 星期五

ZeroJudge 解題筆記:d281. 10499 - The Land of Justice

作者:王一哲
日期:2026年5月29日


ZeroJudge 題目連結:d281. 10499 - The Land of Justice

解題想法


不論切成幾等份,整個球外側的表面積皆為 $4 \pi r^2$。如果切成 $n$ 等份,$n \geq 2$ 才會有新的切面,每一等份會增加表面積 $\pi r^2$,因此答案為 $$ \frac{n \pi r^2}{4 \pi r^2} \times 100\% = 25n \% $$ 題目中的四捨五入根本用不到。

Python 程式碼


使用時間約為 9 ms,記憶體約為 9.8 MB,通過測試。
def solve():
    import sys

    result = []
    data = sys.stdin.read().split()
    ptr = 0
    while ptr < len(data):
        n = int(data[ptr])
        ptr += 1
        if n < 0: break
        if n == 1:
            result.append("0%\n")
        else:
            result.append(f"{n*25:d}%\n")
    sys.stdout.write("".join(result))

if __name__ == "__main__":
    solve()


C++ 程式碼


用 int 會溢位,要用 long。使用時間約為 1 ms,記憶體約為 1.5 MB,通過測試。
#include <cstdio>

int main() {
    long n;
    while(scanf("%ld", &n) != EOF && n > 0) {
        if (n == 1) puts("0%");
        else printf("%ld%%\n", n*25);
    }
    return 0;
}


沒有留言:

張貼留言