乘积尾零(蓝桥杯2018C)

cpp 复制代码
#include<iostream>
typedef long long ll;
using namespace std;
int main() {
	ll result = 1;
	int line = 10, num, zero = 0;
	for (int i = 0; i < line;i++) {
		do {
			scanf_s("%d",&num);
			result *= num;
			while (result%10 == 0) {
				result /= 10;
				zero++;
			}
			result %= 100000000;
		} while ((getchar())!='\n');
	}
	cout << zero << endl;
	return 0;
}
cpp 复制代码
#include<iostream>
using namespace std;
int main() {
    int c2 = 0, c5 = 0;
    int num;
    for (int i = 0; i < 10;i++) {
        do {
            scanf_s("%d",&num);
            while (num % 2 == 0) {
                c2++;
                num /= 2;
            }
            while (num%5 == 0) {
                c5++;
                num /= 5;
            }
        } while (getchar() != '\n');
    }
    cout << min(c2, c5);
    return 0;
}
相关推荐
qq_459234425 天前
【题库】| 商用密码应用安全性评估从业人员考核题库(四十)
职场和发展·密码学·学习方法·考核·商用密码·商用密码应用安全性评估·密评
敲敲了个代码5 天前
[特殊字符] 空数组的迷惑行为:为什么 every 为真,some 为假?
前端·javascript·react.js·面试·职场和发展
诚思报告YH5 天前
视频面试软件市场洞察:2026 - 2032年复合年均增长率(CAGR)为10.3%
面试·职场和发展
重生之后端学习5 天前
74. 搜索二维矩阵
开发语言·数据结构·算法·职场和发展·深度优先
tyb3333335 天前
leetcode:吃苹果和队列
算法·leetcode·职场和发展
Pitiless-invader5 天前
MySQL 相关知识及面试问题汇总
面试·职场和发展
重生之后端学习5 天前
35. 搜索插入位置
java·数据结构·算法·leetcode·职场和发展·深度优先
逆境不可逃5 天前
【从零入门23种设计模式08】结构型之组合模式(含电商业务场景)
线性代数·算法·设计模式·职场和发展·矩阵·组合模式
筱昕~呀5 天前
冲刺蓝桥杯-DFS板块(第二天)
算法·蓝桥杯·深度优先
zheshiyangyang5 天前
前端面试基础知识整理【Day-10】
前端·面试·职场和发展