第九届蓝桥杯大赛个人赛省赛(软件类)真题C 语言 A 组-乘积尾零

在这里插入图片描述

solution

找末尾0的个数,即找有多少对2和5
==>问题等价于寻找所给数据中,有多少个2和5的因子,较少出现的因子次数即为0的个数

#include <iostream>
using namespace std;
int main()
{
  // 请在此输入您的代码
  printf("31");
  return 0;
}
#include<stdio.h>
#include<math.h>
typedef long long ll;
int main(){
	ll  x, two = 0, five = 0, ans = 0;
	for(int i = 0; i < 100; i++){
		scanf("%lld", &x);
		while(x % 2 == 0){
			two++;
			x /= 2;
		}
		while(x % 5 == 0){
			five++;
			x /= 5;
		}
	}
	if(two > five) two = five;
	printf("%lld", two);
	return 0;
}

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-26 13:12:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-26 13:12:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-26 13:12:02       87 阅读
  4. Python语言-面向对象

    2024-03-26 13:12:02       96 阅读

热门阅读

  1. 最小覆盖子串 - LeetCode 热题 12

    2024-03-26 13:12:02       38 阅读
  2. python项目练习——5.自动化批量重命名图片文件

    2024-03-26 13:12:02       37 阅读
  3. Web框架开发-基于Ajax实现的登录

    2024-03-26 13:12:02       43 阅读
  4. C语言 strcmp

    2024-03-26 13:12:02       37 阅读
  5. 从零学算法212

    2024-03-26 13:12:02       40 阅读
  6. 计算机网络(02)

    2024-03-26 13:12:02       38 阅读
  7. 蓝桥杯刷题_day2

    2024-03-26 13:12:02       40 阅读
  8. 网络的warm up

    2024-03-26 13:12:02       39 阅读