1 条题解

  • 2
    @ 2025-12-7 1:01:10
    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
         int n,t,sum,ans=0;
         cin >> n;
         while(n--){
            cin >> t;
            //
            sum=0;
            while(t){
                sum+=t%10;
                t/=10;
            }
            //
            ans=max(ans,sum);
         }
         //
         cout << ans;
         //
         return 0;
    }
    
    
    • 1

    数位和(洛谷 B4065)(循环输入+循环数位拆分+求最大值)

    信息

    ID
    612
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    (无)
    递交数
    65
    已通过
    12
    上传者