1 条题解

  • 0
    @ 2026-11-8 23:30:07

    使用 printf("%05d\n", n)。5 是最小输出宽度,0 表示宽度不足时在左侧补零,超过宽度时保留完整数字。时间复杂度 O(log(n+1))(输出位数),额外空间 O(1)。

    完整 C 程序

    #include <stdio.h>
    
    int main(void)
    {
        int n;
        scanf("%d", &n);
        printf("%05d\n", n);
        return 0;
    }
    
    • 1

    信息

    ID
    642
    时间
    1000ms
    内存
    128MiB
    难度
    5
    标签
    递交数
    20
    已通过
    13
    上传者