当前位置:网站首页>[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) .
边栏推荐
- 商业智能BI业务分析思维:现金流量风控分析(一)营运资金风险
- UE4 在游戏运行时更改变量 (通过鼠标滑轮来更改第一人称角色的最大行走速度)
- The test salary is so high?20K just graduated
- Mathematics - Properties of Summation Symbols
- token、jwt、oauth2、session解析
- Initial solution of the structure
- Android实战开发-Kotlin教程(入门篇-登录功能实现 3.3)
- bytebuffer 使用demo
- [Paper Notes] MapReduce: Simplified Data Processing on Large Clusters
- UE4 opens doors with overlapping events
猜你喜欢
随机推荐
bytebuffer 使用demo
cross domain solution
markdown如何换行——md文件
[BJDCTF2020]EasySearch
Defect detection (image processing part)
Getting Started with Kubernetes Networking
Based on holding YOLOv5 custom implementation of FacePose YOLO structure interpretation, YOLO data format conversion, YOLO process modification"
工业级远距离无线传输装置的功能有哪些?
Some conventional routines of program development (1)
Bosses, I noticed that a mysql CDC connector parameters scan. The incremental. Sna
Queue Topic: Recent Requests
UE4 更改组件变量 (以修改第一人称角色模板的最大行走速度和跳跃高度为例)
shell脚本:for循环与while循环
重载运算符
[CISCN2019 华东南赛区]Web11
第一次性能测试实践,有“亿”点点紧张
public static
List asList(T... a) What is the prototype? UE4 opens doors with overlapping events
Mysql的redo log详解
Kubernetes 网络入门







![[CISCN2019 华东南赛区]Web11](/img/15/843334fec0a5cc8cfaba92aab938db.png)
![[GYCTF2020]EasyThinking](/img/40/973411c69d1e4766d22f6a4a7c7c01.png)
![[MRCTF2020] PYWebsite](/img/d4/57e8e5ee45b742894679f3f5671516.png)