当前位置:网站首页>[8.2] Code Source - [Currency System] [Coins] [New Year's Questions (Data Enhanced Edition)] [Three Stages]
[8.2] Code Source - [Currency System] [Coins] [New Year's Questions (Data Enhanced Edition)] [Three Stages]
2022-08-05 04:01:00 【ZhgDgE】
#852. 货币系统
题意:给定货币系统.for a value,小 t Each time, the maximum currency that does not exceed the amount to be paid will be found from the wallet,用于支付,until payment.if for all positive integer values,The total number of currencies for which no other payment scheme exists is strictly less than small t of payment currencies,then this country is smart. 1 ≤ n ≤ 1000 , 1 = a i < a 2 < ⋯ a n ≤ 10000 1\leq n \leq 1000,1=a_i<a_2<\cdots a_n\leq 10000 1≤n≤1000,1=ai<a2<⋯an≤10000
思路:首先有个结论(不会证): ∀ w > 2 × max ( a i ) , w \forall w>2\times \max(a_i),w ∀w>2×max(ai),w 是聪明的.
Then we only need to judge the number below this upper bound.First brute force to calculate each small value t of payment currencies,The knapsack can then be used to find the minimum number of coins for each value,One by one to judge whether it is smart.put a face value a i a_i ai regarded as the volume of a i a_i ai ,价值为 1 1 1 的物品,Ask the least value for what you happen to fill your backpack with,Just run the backpack.
AC代码:http://oj.daimayuan.top/submission/315376
#815. 硬币
题意:略.
思路:不会,直接抄的题解.
AC代码:http://oj.daimayuan.top/submission/316043
#856. new year question(数据加强版)
题意:给定一个 n × m n×m n×m 的矩阵,requires that exactly one number be selected in each column,And there are two numbers in these numbers on the same line,request to make this m m m The minimum and maximum number of,输出该值. 2 ≤ n , m ≤ 2500 , a i , j ≤ 1 0 9 2\leq n,m\leq 2500,a_{i,j}\leq 10^9 2≤n,m≤2500,ai,j≤109
思路:二分最小值,Determine if there is an option.判断的话,Keep elements greater than or equal to two fractions,if each column has elements,and there exists a row with at least two elements,there are options.
Here we should pay attention to a constant optimization related to the addressing mode.
my traversal(400+ms):
rep(j, 1, m) rep(i, 1, n)
if(a[i][j] >= down){
// solve
}
AC代码遍历(220ms):
rep(i, 1, n) rep(j, 1, m)
if(a[i][j] >= down){
// solve
}
Whether the array is one-dimensional or high-dimensional,are stored contiguously in memory.后者遍历,The vast majority of addressing is contiguous,因为 cache 的存在,We can all quickly get it based on the last address.while the former traverses,Each time we address the array, we jump instead of consecutively,Counting will be slow.
AC代码:http://oj.daimayuan.top/submission/316533
#872. 三段式
题意:有一个长度为 n ( 1 ≤ n ≤ 1 0 5 ) n(1\leq n\leq 10^5) n(1≤n≤105) 的序列 a ( ∣ a i ∣ ≤ 1 0 5 ) a(|a_i|\leq 10^5) a(∣ai∣≤105) ,现在我们想把它切割成三段(每一段都是连续的),使得每一段的元素总和都相同,请问有多少种不同的切割方法.
思路:前缀和.设 b a s e = p r e n 3 base=\frac {pre_n} 3 base=3pren ,那么对于每个 p r e i = 2 × b a s e pre_i=2\times base prei=2×base ,See how many are ahead j ( j ∈ [ 1 , i − 1 ] ) j(j\in[1,i-1]) j(j∈[1,i−1]) 满足 p r e j = b a s e pre_j=base prej=base .注意 i i i cannot be enumerated to n n n ,because it is not empty.时间复杂度 O ( n log n ) O(n\log n) O(nlogn) .
边栏推荐
- 【 8.4 】 source code - [math] [calendar] [delete library 】 【 is not a simple sequence (Bonus) 】
- [MRCTF2020]Ezpop(详解)
- Ffmpeg - sources analysis
- 36-Jenkins-Job迁移
- Summary of common methods of arrays
- Defect detection (image processing part)
- DEJA_VU3D - Cesium功能集 之 057-百度地图纠偏
- BI业务分析思维:现金流量风控分析(二)信用、流动和投资风险
- 如何解决复杂的分销分账问题?
- UE4 更改组件变量 (以修改第一人称角色模板的最大行走速度和跳跃高度为例)
猜你喜欢
![[SWPU2019]Web1](/img/06/36e69a2d7d5475a6749a7d81edf50f.png)
[SWPU2019]Web1

Use Unity to publish APP to Hololens2 without pit tutorial

Ice Scorpion V4.0 attack, security dog products can be fully detected

Solana NFT开发指南

【8.4】代码源 - 【数学】【历法】【删库】【不朴素的数列(Bonus)】

Confessing the era of digital transformation, Speed Cloud engraves a new starting point for value

Ali's local life's single-quarter revenue is 10.6 billion, Da Wenyu's revenue is 7.2 billion, and Cainiao's revenue is 12.1 billion
![[Paper Notes] MapReduce: Simplified Data Processing on Large Clusters](/img/89/8adef42b0cfd154e6fa7205afaeade.png)
[Paper Notes] MapReduce: Simplified Data Processing on Large Clusters

多列属性column元素的可见性:display、visibility、opacity、垂直对齐方式:vertical-align、z-index 越大越显示在上层

BI业务分析思维:现金流量风控分析(二)信用、流动和投资风险
随机推荐
BI业务分析思维:现金流量风控分析(二)信用、流动和投资风险
2022-08-04T17:50:58.296+0800 ERROR Announcer-3 io.airlift.discovery.client.Announcer appears after successful startup of presto
Spark Basics [Introduction, Getting Started with WordCount Cases]
Redis1: Introduction to Redis, basic features of Redis, relational database, non-relational database, database development stage
Android实战开发-Kotlin教程(入门篇-登录功能实现 3.3)
SkiaSharp 之 WPF 自绘 粒子花园(案例版)
Getting Started with Kubernetes Networking
多列属性column元素的可见性:display、visibility、opacity、垂直对齐方式:vertical-align、z-index 越大越显示在上层
Summary of common methods of arrays
[TA-Frost Wolf_may-"Hundred Talents Project"] Graphics 4.3 Real-time Shadow Introduction
Industry Status?Why do Internet companies prefer to spend 20k to recruit people rather than raise their salary to retain old employees~
[Paper Notes] MapReduce: Simplified Data Processing on Large Clusters
36-Jenkins-Job迁移
【Mysql进阶优化篇02】索引失效的10种情况及原理
[BSidesCF 2019]Kookie
Dive into how it works together by simulating Vite
包拉链不可用,但是是被另一个包。
cross domain solution
[8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]
10 years of testing experience, worthless in the face of the biological age of 35