当前位置:网站首页>[Luogu cf643f] bears and juice (conclusion)
[Luogu cf643f] bears and juice (conclusion)
2022-07-26 16:55:00 【SSL_ TJH】
Bears and Juice
Topic link :luogu CF643F
The main idea of the topic
Yes n A bear p Bed , There are some wine barrels , You can set the quantity , One of them put wine and the other put fruit juice , Then each bear can choose a barrel to gather every day ( Can be null ), If the bear eats wine, it will occupy a bed to sleep , If there is not enough bed or the bear sleeps all, he will lose .
Then ask you to give you 1~q Time of day , How many barrels can you get at most , So that these bears must be able to find the location of the wine without losing .
Ideas
It's a magical question !
Consider how to distinguish wine barrels ( Because you can find your wine in that bucket ), Then let's consider how we can't distinguish .
Then we found another thing is that we can only get information from who is drunk , Useful information .
Let's consider how to distinguish , For a barrel, if we list a table, it means i i i Tiandi j j j Did the bear eat it .
Obviously, if the watch is different, it is a different bucket , How many watches are there ?
Consider enumerating how many bears ate this , Then for every bear it can be here x x x Eat on any day of the day .
R x = ∑ i = 0 min ( n − 1 , p ) ( n i ) x i R_x=\sum\limits_{i=0}^{\min(n-1,p)}\binom{n}{i}x^i Rx=i=0∑min(n−1,p)(in)xi
Then it's over !
( Since you can't invert, how many primes can you maintain for each combinatorial number , And then what is the big product )
( It's small. It may be i i i Removed , That is to say 130 130 130 Inside , For large ones, just record the product directly )
( Preprocessing R R R Can O ( min ( n , p ) q ) O(\min(n,p)q) O(min(n,p)q) Complete the answer )
( belt log \log log Whether it's written Lala or not /tp)
Code
#include<cstdio>
using namespace std;
int n, p, q;
unsigned int ans, sum, di, vals[131];
int val[131], id[131], tot, num[131];
unsigned int ksm(unsigned int x, int y) {
unsigned int re = 1;
while (y) {
if (y & 1) re = re * x;
x = x * x; y >>= 1;
}
return re;
}
void Run(int x, int gx) {
for (int i = 1; i <= tot; i++) {
while (x % val[i] == 0) {
num[i] += gx; x /= val[i];
}
}
di = di * x;
}
int main() {
for (int i = 2; i <= 130; i++) {
bool prime = 1;
for (int j = 2; j < i; j++) if (i % j == 0) {
prime = 0; break;}
if (prime) id[i] = ++tot, val[tot] = i;
}
scanf("%d %d %d", &n, &p, &q);
di = 1; vals[0] = 1;
for (int i = 1; i <= p && i < n; i++) {
Run(n - i + 1, 1); Run(i, -1);
sum = 1;
for (int j = 1; j <= tot; j++) sum *= ksm(val[j], num[j]);
vals[i] = sum * di;
}
for (int i = 1; i <= q; i++) {
sum = 0; di = 1;
for (int j = 0; j <= p && j < n; j++)
sum += vals[j] * di, di = di * i;
ans ^= sum * i;
}
printf("%u", ans);
return 0;
}
边栏推荐
- Re7: reading papers fla/mlac learning to predict charges for critical cases with legal basis
- Digital intelligence transformation, management first | jnpf strives to build a "full life cycle management" platform
- 快速学会配置yum的本地源和网络源,并学会yum的使用
- Can TCP and UDP use the same port?
- Guetzli simple to use
- srec_cat 常用参数的使用
- 如何保证缓存和数据库一致性
- PXE efficient batch network installation
- Win11怎么重新安装系统?
- Guangzhou Municipal Safety Committee Office issued warnings and reminders on safety precautions in hot weather
猜你喜欢

Definition and relationship of derivative, differential, partial derivative, total derivative, directional derivative and gradient

A preliminary understanding of MVC and ECS design architectures

抓包与发流软件与网络诊断
![Sharing of 40 completed projects of high-quality information management specialty [source code + Thesis] (VI)](/img/b9/629449d3c946b017075ed42eaa81bf.png)
Sharing of 40 completed projects of high-quality information management specialty [source code + Thesis] (VI)

该怎么写单元测试呢

Marxan model, reserve optimization and protection vacancy selection technology, application in invest ecosystem

如何借助自动化工具落地DevOps|含低代码与DevOps应用实践

Vscode batch delete

“青出于蓝胜于蓝”,为何藏宝计划(TPC)是持币生息最后的一朵白莲花

OA项目之我的会议(会议排座&送审)
随机推荐
How to use C language nested linked list to realize student achievement management system
我的sql没问题为什么还是这么慢|MySQL加锁规则
Threads and processes
JD Sanmian: I want to query a table with tens of millions of data. How can I operate it?
Using MySQL master-slave replication delay to save erroneously deleted data
Win11自动删除文件设置方法
How to implement Devops with automation tools | including low code and Devops application practice
Guangzhou Municipal Safety Committee Office issued warnings and reminders on safety precautions in hot weather
什么是分布式定时任务框架?
Tdengine landed in GCL energy technology, with tens of billions of data compressed to 600gb
【Flutter -- 进阶】打包
【无标题】
Re8: reading papers Hier spcnet: a legal stat hierarchy based heterogeneous network for computing legal case
2022 Niuke summer multi school training camp 2 (bdghjkl)
带你一分钟了解对称加密和非对称加密
C#转整型的三种方式的区别以及效率对比
Set up typera drawing bed
Comprehensively design an oppe homepage -- the design of the top and head
【开发教程8】疯壳·开源蓝牙心率防水运动手环-三轴计步伐
Win11怎么自动清理回收站?