abner's blog

Blogs

求助

2025-06-02 16:48:52 By abner

题目就是有n种(1≤n<10^5)钱,每个钱都有面值ai,(1<ai<10^6),第1种是1元,买一个东西优先取面值较大的,有q次询问(1<q<10^6),每次询问给出一个值m,(1<m<10^9),问m张钱能买多少钱的东西

链接:https://qoj.ac/contest/2058/problem/11379

m是十的九次方,那么最多有十的六次方张钱不是an,那么只需要考虑m%an张钱,这个数量级是10^6次方,然后再预处理出10^6以内的钱需要多少张钱(计划化复杂度On),然后再统计1~k张钱能获得多少钱sum[k],然后因为an没有限制,所以就是0~m%an张an元都可能,所以答案就是sum[m%an]

我也不知道思路哪里错了,代码应该对了,不会用markdown,凑合看吧

Comments

abner
题目链接:https://qoj.ac/contest/2058/problem/11379
  • 2025-06-02 16:56:16
  • Reply
Redcrown
“最多有十的六次方张钱不是an”这句话不能推出“那么只需要考虑m%an张钱”这个结论,而是应该得到“只需要考虑min(an,m)张钱”的结论,对应的答案是sum[min(an,m)]。
  • 2025-06-24 01:01:35
  • Reply

Post a comment

You can refer to mike by using "@mike", and "mike" will be highlighted. If you want to type the character "@", please use "@@" instead.

You can enter "/kel" to use the emoticon "kel".