6 条题解

  • 0
    @ 2025-9-5 18:31:41
    $$\left \lfloor \lg\ n\right \rfloor = \text{len}(n)-1$$
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        freopen("log.in","r",stdin);// 文件读取
        freopen("log.out","w",stdout);// 文件写入
        char a=getchar();// 获取一个字符
        int ans=-1;// 之所以 ans 初始值为 -1,是因为答案是 len(n) - 1
        while(a!='\n'){// 若 a 为 \n 就不是数字了
            ans++;// 因为 a 还是数字所以加上 1
            a=getchar();// 获取一个字符
        }
        cout<<ans<<endl;// 输出
        fclose(stdin);// fclose 好习惯
        fclose(stdout);// fclose 好习惯
        return 0;// return 好习惯
    }
    

    信息

    ID
    2
    时间
    1000ms
    内存
    512MiB
    难度
    2
    标签
    递交数
    118
    已通过
    25
    上传者