当前位置:网站首页>[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;
}
边栏推荐
- Video media video
- "Green is better than blue". Why is TPC the last white lotus to earn interest with money
- How does win11 reinstall the system?
- Pyqt5 rapid development and practice 3.2 introduction to layout management and 3.3 practical application of QT Designer
- 中金证券vip账户找谁开安全啊?
- C#转整型的三种方式的区别以及效率对比
- 快速学会配置yum的本地源和网络源,并学会yum的使用
- Stop using xshell and try this more modern terminal connection tool
- [development tutorial 8] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - triaxial meter pace
- 2022 Niuke summer multi school training camp 2 (bdghjkl)
猜你喜欢

抓包与发流软件与网络诊断
It turns out that cappuccino information security association does this. Let's have a look.

A preliminary understanding of MVC and ECS design architectures

【Flutter -- 进阶】打包

PyQt5快速开发与实战 3.2 布局管理入门 and 3.3 Qt Designer实战应用

About the idea plug-in I wrote that can generate service and mapper with one click (with source code)

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

微信小程序---网络数据请求

"Green is better than blue". Why is TPC the last white lotus to earn interest with money

【开发教程9】疯壳·ARM功能手机-I2C教程
随机推荐
Current limiting comparison: how to choose sentinel vs hystrix?
量化交易之数字货币篇 - 通过时间戳与方向来合并逐笔成交数据(大单合并)
Operating system migration practice: deploying MySQL database on openeuler
Threads and processes
Stop using xshell and try this more modern terminal connection tool
正则表达式
【Flutter -- 进阶】打包
导数、微分、偏导数、全微分、方向导数、梯度的定义与关系
2022 Niuke summer multi school training camp 1 (acdgij)
Recurrence of historical loopholes in ThinkPHP
mysql锁机制(举例说明)
Packet capturing and streaming software and network diagnosis
C#事件和委托的区别
Thinkphp历史漏洞复现
PyQt5快速开发与实战 3.4 信号与槽关联
The Ministry of Public Security issued a traffic safety warning for summer tourism passenger transport: hold the steering wheel and tighten the safety string
"Green is better than blue". Why is TPC the last white lotus to earn interest with money
A preliminary understanding of MVC and ECS design architectures
IDEA 阿里云多模块部署
Matlab论文插图绘制模板第40期—带偏移扇区的饼图