Codeforces Round #105 (Div. 2) / 148A Insomnia cure (枚举 || 数论)

MICS-6814多气体传感器与ESP32-C3 Mini接口构建空气监测系统 cararenuity C3 Mini的多个ADC引脚,Wi-Fi和蓝牙LE以及紧凑的设计使其成为嵌入式物联网应用的绝佳选择。在这个项目中,我们将把MICS-6814多气体传感器与基于esp32 -C3的开发板cararenuity C3 Mini连接起来。更多模拟引脚:与ESP8266只有一个ADC引脚不同,基于esp32 -C3的cararenuity C3 Mini提供多个ADC引脚,使其成为多传感器应用的理想选择。紧凑可靠:该板的小尺寸使其成为嵌入式应用的理想选择,而不会牺牲性能。 阅读详情

A. Insomnia cure
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.

However, just counting dragons was boring as well, so she entertained herself at best she could. Tonight she imagined that all dragons were here to steal her, and she was fighting them off. Every k-th dragon got punched in the face with a frying pan. Every l-th dragon got his tail shut into the balcony door. Every m-th dragon got his paws trampled with sharp heels. Finally, she threatened every n-th dragon to call her mom, and he withdrew in panic.

How many imaginary dragons suffered moral or physical damage tonight, if the princess counted a total of d dragons?

Input

Input data contains integer numbers k, l, m, n and d, each number in a separate line (1 ≤ k, l, m, n ≤ 10, 1 ≤ d ≤ 105).

Output

Output the number of damaged dragons.

Sample test(s)
input
1
2
3
4
12
output
12
input
2
3
4
5
24
output
17
Note

In the first case every first dragon got punched with a frying pan. Some of the dragons suffered from other reasons as well, but the pan alone would be enough.

In the second case dragons 1, 7, 11, 13, 17, 19 and 23 escaped unharmed.


暴力代码:

/*30ms,0KB*/

#include <cstdio>

int main(void)
{
	int k, l, m, n, d, s = 0;
	scanf("%d%d%d%d%d", &k, &l, &m, &n, &d);
	for (int i = 1; i <= d; ++i)
		if (!(i % k && i % m && i % n && i % l))
			s++;
	printf("%d\n", s);
	return 0;
}


神牛写的数论代码:(没看懂)

/*30ms,0KB*/

#include <cstdio>
#include <vector>
using namespace std;

int v[4], n;
bool bio[4][4];

inline int gcd(int a, int b)
{
	int ret = 1;
	for (int i = 2; i <= a; ++i)
		if (a % i == 0 && b % i == 0)
			ret = i;
	return ret;
}

inline int lcm(int a, int b)
{
	return a / gcd(a, b) * b;///为防止可能的数据超范围,先除再乘要更好。
}

vector<int> rek(int i, int k, vector<int> w)
{
	if (k == 0)
	{
		int ret = w[0];
		for (int j = 1; j < (int) w.size(); ++j)
			ret = lcm(ret, w[j]);
		return vector<int> (1, ret);
	}
	if (i == 4)
        return vector<int>();
	vector<int> ret;
	vector <int> ret2 = rek(i + 1, k, w);
	for (int j = 0; j < (int)ret2.size(); ++j)
		ret.push_back(ret2[j]);
	w.push_back(v[i]);
	vector<int> ret1 = rek(i + 1, k - 1, w);
	for (int j = 0; j < (int)ret1.size(); ++j)
		ret.push_back(ret1[j]);
	return ret;
}

int main(void)
{
	int ret = 0;
	scanf("%d%d%d%d%d", &v[0], &v[1], &v[2], &v[3], &n);
	for (int i = 1; i <= 4; ++i)
	{
		vector<int> div = rek(0, i, vector<int>());
		for (int j = 0; j < (int)div.size(); ++j)
			if (i % 2)
				ret += n / div[j];
			else
				ret -= n / div[j];
	}
	printf("%d",ret);
}


【物联网技术】ESP8266 ESP-01/01s 固件下载烧录+STM32串口通信接线 ESP8266 ESP-01/01s 工作模式接线与MQTT固件下载烧录接线 阅读详情

相关推荐

【一】Android MediaPlayer整体架构源码分析 -【初始化和创建】

本系列文章分析的安卓源码版本:【Android 10.0 版本】 一、MediaPlayer的简单调用关键流程 【这只是一个简单使用过程示例】 // 此处变量声明省略 private void play() { // 先获取SurfaceHolder mSurfaceView = findViewById(R.id.surface_view); mSurfaceHolder = mSurfaceView.getHolder(); mSurfac

CloverLHao的博客 4347

CODEFORCES --- 148A. Insomnia cure

然而,光是数龙也很无聊,所以她充其量地自娱自乐。今晚她想象所有的龙都来偷她,她正在击退它们。在第一种情况下,每条龙都会被煎锅打一拳。有些龙也遭受了其他原因的折磨,但仅平底锅就足够了。三龙»,——公主在数。她难以入睡,九岁时就厌倦了数羊羔。都把尾巴关在阳台门上。每m条龙的爪子都被锋利的高跟鞋踩踏。在第二种情况下,龙1、7、11、13、17、19和23毫发无伤地逃脱了。条龙,今晚有多少想象中的龙遭受了精神或身体上的伤害?n条龙都叫她妈妈,他惊慌失措地退了出去。条龙都被煎锅打了一拳。如果公主数一数总共有。

weixin_45691078的博客 297

管道机器人手臂机械结构设计cad【8张】+三维图+设计说明书+绛重

履带式管道机器人适用于各种管道环境,包括直管道、弯曲管道、水平管道、垂直管道等,其灵活性和适应性使得它可以应对不同形状和尺寸的管道,完成全面的检测和维护工作。管道机器人研究具有重要的现实意义和深远的社会影响,通过提高工作效率、降低人员风险、提升服务质量、节约成本资源和促进科技创新等方面的作用,为现代工程技术领域的发展和进步做出了积极的贡献。管道机器人是一种能够在管道内部执行各种任务的智能机器人,而管道机器人的机械臂对于管道机器人在管道内执行任务的灵活性、稳定性和效率至关重要。

kejigongjiang的博客 943

A. Insomnia cure

A. Insomnia cure time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output «One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting la

AlberTesla的博客 1351

国密(3)- 预主密钥/主密钥计算和Finished消息的加解密

国密的ECC-SM3-SM4-CBC模式下的预主密钥和主密钥的生成过程介绍,以及Finished消息的加解密介绍

weixin_43408952的博客 6512

KMS服务器一键部署与激活实战指南

本文详细介绍了KMS服务器的一键部署与激活实战指南,包括快速入门、安装步骤、服务管理技巧及常见问题排查。特别针对Windows和Mac用户提供了Office激活的具体操作步骤,并分享了高级配置与优化方案,帮助IT管理员高效管理批量授权激活。

weixin_29305313的博客 461

Codeforces Round 105

A B C E

原原的博客 385

Unity 调用安卓内部安装apk

一、申请权限 应用内安装其他应用的权限属于特殊权限,需要在特殊申请。 Uri packageURI = Uri.parse("package:" + mContext.getPackageName()); Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageURI); startA...

BDDNH的博客 1240

Problem--148A--Codeforces--A. Insomnia cure

A. Insomnia cure time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output «One dragon. Two dragon. Three dragon», — the princess w

qq_36667106的博客 907

Tessent实战:网表扫描链插入全流程解析

本文详细解析了使用Tessent工具为网表插入扫描链(Scan Chain)的全流程。从前期环境配置、网表检查,到扫描链数量、时钟域等核心配置,再到执行扫描单元替换与连接,最后进行结果验证与文件输出。文章提供了关键命令与实用技巧,帮助工程师高效完成DFT设计,确保芯片可测试性。

hhh00的博客 747

树莓派4B+Ubuntu22.04+思岚RPLIDAR C1激光雷达应用

树莓派+Ubuntu22.04+思岚RPLIDAR C1激光雷达简单应用

techfuture的博客 3704

codeforces 105 div2 A

A. Insomnia cure time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output «One dragon. Two dragon. Three dragon», —

丿聪丶 741

Matlab/simulink频率响应分析方法

Matlab/Simulink仿真系列问题一.电气模块与信号模块 一.电气模块与信号模块

virtuoso~晓晓 3万+

Codeforces Round #105 (Div. 2)A

A. Insomnia curetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs w

qq_62079079的博客 273

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Insomnia cure

文章目录一、Insomnia cure总结 一、Insomnia cure 本题链接:Insomnia cure 题目: A. Insomnia cure time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output «One dragon. Two dragon. Three dragon», — the princess was counting. S.

佛系更新 711

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

codeforces-148A. Insomnia cure-题解

题目大意: 公主晚上睡不着,想到了一个数龙的方法让自己睡着,但是仅仅数龙也很无聊,她想尽可能地娱乐自己。今晚,她想象着所有的龙都在她搏斗。每k-th条龙都被一只煎锅打在脸上,每l-th条龙的尾巴都被关在阳台的门里,每m-th条龙的爪子都被锋利的脚后跟踩着,最后,她威胁每n-th条龙叫她妈妈。如果公主数出d条龙的总数,那么今晚有多少条想象中的龙受到了精神或肉体上的伤害? 输入数据包含整数k, l...

金鳞踏雨 852

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

【水题】CodeForces - 148A Insomnia cure

Problem Description 输入k,l,m,n,d。d代表dragon的数量。不满足k,l,m,n倍数的恐龙不能消除。让你求最多能消除几只龙 代码:#include<bits/stdc++.h> using namespace std; int main() { int a, b, c, d; while(~scanf("%d %d %d %d", &a, &b, &

ACMer 梁剑锋 的博客 582

codeforces-148A-Insomnia cure

148A-Insomnia cure

Linoy 1308

CodeForces-148A-Insomnia cure

A. Insomnia cure time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output «One dragon. Two dragon. Three dragon», —

Spikerman的专栏 786

Codeforces刷题之路——148A Insomnia cure

A. Insomnia cure time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output «One dragon. Two dragon. Three dragon», —

莫欺少年穷 923

CF148 A Insomnia cure

«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine. However, just counting dragons was boring a

Kelisiya 573

Insomnia cure CodeForces - 148A (数论的扩展解法)

«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine. However, just counting dragons was boring a

SunMoonVocano的博客 669

Insomnia 替代 postman

http://gd.greenxf.com:8099/macsoft/Insomnia(www.greenxf.com).dmg

gwdgwd123的博客 3258

CodeForce 148A Insomnia cure(筛法)

«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine. However, just counting dragons was boring as well, so she entertained herself at best she could. Ton

Jacob0824的博客 310
上一篇: Codeforces Beta Round #91 (Div. 2) / 122A Lucky Division (数论)
下一篇: 一、初级篇——指针(*)、取地址(&)、解引用(*)与引用(&)的区别
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值