当前位置:网站首页>[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;
}
边栏推荐
- 微信小程序---网络数据请求
- [fluent -- advanced] packaging
- 带你一分钟了解对称加密和非对称加密
- What does it mean to lock financial products regularly? Can financial products be redeemed during the lock-in period?
- Docker install redis? How to configure persistence policy?
- The difference and efficiency comparison of three methods of C # conversion integer
- How to balance open utilization and privacy security compliance of public data?
- Thinkphp历史漏洞复现
- ES:Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes
- 公共数据如何兼顾开放利用和隐私安全合规?
猜你喜欢

2022软件测试技能 Postman+newman+jenkins 持续集成 实战教程
![[basic course of flight control development 2] crazy shell · open source formation UAV - timer (LED flight information light and indicator light flash)](/img/ad/e0bc488c238a260768f7e7faec87d0.png)
[basic course of flight control development 2] crazy shell · open source formation UAV - timer (LED flight information light and indicator light flash)

Win11 auto delete file setting method

Vscode batch delete

NUC 11构建 ESXi 7.0.3f安装网卡驱动-V2(2022年7月升级版)

vlang捣鼓之路

PyQt5快速开发与实战 3.4 信号与槽关联

MVC和ECS两种设计架构的初浅理解

我的sql没问题为什么还是这么慢|MySQL加锁规则

Nacos win10 installation and configuration tutorial
随机推荐
Current limiting comparison: how to choose sentinel vs hystrix?
面试时候常说的复杂度到底是什么?
PXE efficient batch network installation
Acl-ijcai-sigir top conference paper report meeting (AIS 2022) Note 3: dialogue and generation
Tensorflow Lite source code analysis
Matlab paper illustration drawing template issue 40 - pie chart with offset sector
Tcpdump命令详解
Tao and art of R & D Efficiency - Tao chapter
PyQt5快速开发与实战 3.2 布局管理入门 and 3.3 Qt Designer实战应用
srec_ Use of common cat parameters
Final consistency distributed transaction TCC
The Ministry of Public Security issued a traffic safety warning for summer tourism passenger transport: hold the steering wheel and tighten the safety string
Threads and processes
极大似然估计
PXE高效批量网络装机
【E-MR】NameNode的错误恢复记录
37.【重载运算符的类别】
MVC和ECS两种设计架构的初浅理解
It turns out that cappuccino information security association does this. Let's have a look.
抓包与发流软件与网络诊断