当前位置:网站首页>【 8.7 】 source code - card to LCM with GCD 】 【 】
【 8.7 】 source code - card to LCM with GCD 】 【 】
2022-08-08 16:33:00 【ZhgDgE】
#968. 抽卡
题意:
题解:UNICORN Programming Contest 2021(AtCoder Beginner Contest 225) 部分题目题解
思路:考虑 DP .先排一下序,然后定义 d p ( i , j ) dp(i,j) dp(i,j) 表示后 i i i string selection j j j The smallest lexicographic order of spellings. d p ( i , j ) = min ( d p ( i + 1 , j ) , s i + d p ( i + 1 , j − 1 ) ) dp(i,j)=\min(dp(i+1,j),s_i+dp(i+1,j-1)) dp(i,j)=min(dp(i+1,j),si+dp(i+1,j−1)) ,注意边界条件.
There are two things to say:
- 我们要按照 a + b < b + a a+b<b+a a+b<b+a 的方式排序,而不是 a < b a<b a<b 的方式.For example, in order of the latter b , b a b,ba b,ba ,But the spelling is not the least lexicographical order.We sort by the former,就能保证 A subset of strings in minimal lexicographic concatenation 等于 These strings are spelled from left to right according to the sorted subscripts.
- As for why it fell DP ,Probably because of the front i − 1 i-1 i−1 Minimum lexicographical order of strings,Concatenate with the current string,not necessarily ex i i i Minimum lexicographical order of strings.不是很懂.
AC代码:http://oj.daimayuan.top/submission/325124
#953. LCM与GCD
题意:
思路:Another formula question.等价于 x ⋅ a gcd ( a , b ) ⋅ b gcd ( a , b ) − y = k gcd ( a , b ) x\cdot \frac a{\gcd(a,b)}\cdot \frac b{\gcd(a,b)}-y=\frac k {\gcd(a,b)} x⋅gcd(a,b)a⋅gcd(a,b)b−y=gcd(a,b)k ,容易知道 gcd ( a , b ) \gcd(a,b) gcd(a,b) 一定是 k k k 的因子,The root sign enumerates the factors.
for an enumerated factor,Let's push the formula again: a gcd ( a , b ) ⋅ b gcd ( a , b ) = k gcd ( a , b ) + y x = M \frac a{\gcd(a,b)}\cdot \frac b{\gcd(a,b)}=\frac{\frac k {\gcd(a,b)}+y}x=M gcd(a,b)a⋅gcd(a,b)b=xgcd(a,b)k+y=M ,The question turns into how many logarithms are coprime and the product is M M M .The root sign enumerates the types of prime factors.
边栏推荐
- 智能指针学习笔记
- 【MATLAB项目实战】基于Morlet小波变换的滚动轴承故障特征提取研究
- 非常菜的一个批量布置waf脚本
- 论文解读(soft-mask GNN)《Soft-mask: Adaptive Substructure Extractions for Graph Neural Networks》
- laravel - 查询构建器2
- 【MySQL哪些字段适合建索引,哪些查询条件会导致索引失效】
- 【8.7】代码源 - 【抽卡】【LCM与GCD】
- 广东大学生网络安全攻防大赛CTF部分WP
- 基于华为云弹性云服务器ECS(搭载openEuler的鲲鹏通用计算增强型)完成鲲鹏代码迁移工具实践【华为云至简致远】
- 【入门PCB】立创eda的学习
猜你喜欢
随机推荐
【LeetCode】试题总结:深度优先搜索 (DFS)
2020年适用于Linux的10个顶级开源缓存工具
手机注册股票开户的流程?网上开户安全?
[深入研究4G/5G/6G专题-54]: L3信令控制-3-软件功能与流程的切分-CU-UP网元的信令
ESP8266-Arduino编程实例-ADXL345三轴加速计驱动
数字图像处理(六)—— 图像压缩
【论文阅读】RAL 2022: Receding Moving Object Segmentation in 3D LiDAR Data Using Sparse 4D Convolutions
C语言学习概览(四)
Is it safe to open an account with CICC Wealth?How does it work?
基于ECS实现一分钟自动化部署【华为云至简致远】
急了,Mysql索引中最不容易记的三个知识点通透了
小米产品使用体验,问题分析及建议
好用的项目工时管理系统有哪些
抓住时代趋势,网赚新逻辑:平台+个人模式超清晰解读(附产品评测)
leetcode 155. Min Stack最小栈(中等)
The origin and creation of Smobiler's complex controls
使用pymongo保存数据到MongoDB的工具类
MVCC,主要是为了做什么?
MySQL中常见的内些...啥
Kubernetes二进制部署高可用集群