2 条题解

  • 1
    @ 2023-7-12 17:40:50

    递归来喽~~~保证O(n)不超限(10ms)!!

    (用long long不为过吧😄 )

    警报,警报!!!!AC代码来到,AC代码已来到!!!!这不是演习!

    (不信试试就知道)

    #include <bits/stdc++.h>
    using namespace std;
    int alfa(long long x)
    {
        if (x < 10)
        {
            return x;
        }
        else
        {
            int j = 1;
            while (x > 0)
            {
                if (x % 10 != 0)
                {
                    j *= x % 10;
                }
                x /= 10;
            }
            return alfa(j);
        }
    }
    int main()
    {
        long long v;
        cin >> v;
        cout << alfa(v);
    }
    
    • 0
      @ 2023-1-16 10:09:39
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int x;
      	cin >> x;
      	//当这个数各个位的成绩不是一位数数时,对它的乘积继续求解
      	while(x >= 10){
      		int t = 1;
      		//计算整数非0位的乘积
      		while(x != 0){
      			//判断尾数不等于0就累乘
      			if(x%10 != 0){
      				t = t*(x%10);
      			} 
      			//去掉尾数
      			x = x/10; 
      		} 
      		x = t;
      	} 
      	cout << x << endl;
      	return 0;
      }
      
      
      
      • 1

      信息

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