当前位置:网站首页>[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) .
边栏推荐
- Getting Started with Kubernetes Networking
- token, jwt, oauth2, session parsing
- 商业智能BI业务分析思维:现金流量风控分析(一)营运资金风险
- Queue Topic: Recent Requests
- Mysql's redo log detailed explanation
- Kubernetes 网络入门
- 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
- 【8.2】代码源 - 【货币系统】【硬币】【新年的问题(数据加强版)】【三段式】
- GC Gaode coordinate and Baidu coordinate conversion
猜你喜欢
![[BSidesCF 2019]Kookie](/img/29/19e7c244feb86b37ab32a53aa11f25.png)
[BSidesCF 2019]Kookie

Getting Started with Kubernetes Networking

Some conventional routines of program development (1)

Index Mysql in order to optimize paper 02 】 【 10 kinds of circumstances and the principle of failure

How to solve the three major problems of bank data collection, data supplementary recording and index management?

UE4 通过互动(键盘按键)开门
![[CISCN2019 South China Division]Web11](/img/15/843334fec0a5cc8cfaba92aab938db.png)
[CISCN2019 South China Division]Web11

bytebuffer 使用demo

token, jwt, oauth2, session parsing

Developing Hololens encountered The type or namespace name 'HandMeshVertex' could not be found..
随机推荐
Swing有几种常用的事件处理方式?如何监听事件?
Some conventional routines of program development (1)
DEJA_VU3D - Cesium功能集 之 058-高德地图纠偏
What is the function of industrial-grade remote wireless transmission device?
[SWPU2019]Web1
DNS被劫持如何处理?
事件解析树Drain3使用方法和解释
Mysql的redo log详解
bytebuffer 使用demo
[极客大挑战 2019]FinalSQL
A 35-year-old software testing engineer with a monthly salary of less than 2W, resigns and is afraid of not finding a job, what should he do?
炎炎夏日教你利用小米智能家居配件+树莓派4接入Apple HomeKit
Detailed and comprehensive postman interface testing practical tutorial
MySql index learning and use; (I think it is detailed enough)
This year's Qixi Festival, "love vegetables" are more loving than gifts
Mysql's redo log detailed explanation
Developing Hololens encountered The type or namespace name 'HandMeshVertex' could not be found..
[Software testing] unittest framework for automated testing
[MRCTF2020]PYWebsite
UE4 后期处理体积 (角色受到伤害场景颜色变淡案例)