当前位置:网站首页>Magic fast power
Magic fast power
2022-07-07 23:44:00 【sophilex】

Ideas ;
Pure simulation is definitely a gift , There are many people who are looking for rules , Find the circular section and then pass .
I saw a show on the Internet and turned my thoughts : Treat an infection process as a multiplication operation , The operation object is the tag array , I've been through so much k operations , That is, take k Time , This is a fast power of deformation
Then just click on the fast power
The overall complexity is about m^2*log(k),4e7 The level of , Theoretically, it can pass
but, Time is still dead ( Maybe the constant is a little big ), You have to add all the miscellaneous optimizations : Fast reading ,register,inline...
Optimized to the extreme , To live through ...( Personal experience )
Although but , This idea is really the first time I have seen , Very good
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(x) x&(-x)
const int N=1500;
ll k;
int m,n;
inline ll read() {
register char ch;
while(!isdigit(ch=getchar()));
register ll x=ch^'0';
while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
return x;
}
bool mas[N],tp[N],ans[N];
inline void mul(bool a[],bool b[])
{
memset(tp,0,sizeof tp);
for(register int i=0;i<m;++i)
{
for(register int j=0;j<m;++j)
{
tp[i*j%m]|=a[i]&&b[j];
}
}
std::copy(&tp[0],&tp[m],a);
}
int main()
{//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
k=read();m=read();n=read();
for(register int i=1;i<=n;++i)
{
//a=read();
mas[read()]=1;
}
ans[1]=1;
while(k)
{
if(k&1) mul(ans,mas);
mul(mas,mas);
k>>=1;
}
for(register int i=0;i<m;++i) if(ans[i]) printf("%d ",i);
return 0;
}边栏推荐
- Aitm3.0005 smoke toxicity test
- Chisel tutorial - 01 Introduction to Scala
- Live server usage
- 【路径规划】使用垂距限值法与贝塞尔优化A星路径
- SAP HR family member information
- postgres timestamp转人眼时间字符串或者毫秒值
- gorm 关联关系小结
- [stm32+esp8266 connect Tencent cloud IOT development platform 2] stm32+esp8266-01s connect Tencent cloud
- Take you hand in hand to build Eureka server with idea
- Enumeration, simulation, and sorting
猜你喜欢

ASP. Net core middleware request processing pipeline

Get started with mongodb

SAP HR labor contract information 0016

二叉排序树【BST】——创建、查找、删除、输出

Take you hand in hand to build feign with idea

The file format and extension of XLS do not match

Map operation execution process

Apng2gif solutions to various problems

关于CH32库函数与STM32库函数的区别
![Given an array, such as [7864, 284, 347, 7732, 8498], now you need to splice the numbers in the array to return the](/img/21/2e99dd6173ab4925ec22290cd4a357.png)
Given an array, such as [7864, 284, 347, 7732, 8498], now you need to splice the numbers in the array to return the "largest possible number."
随机推荐
Rock-paper-scissors
C language greedy snake
SQL 使用in关键字查询多个字段
KeePass realizes automatic input of web pages
Pigsty:开箱即用的数据库发行版
Reverse output three digit and arithmetic sequence
[summary] some panels and videos seen
Restricted linear table
SAP HR 劳动合同信息 0016
SQL database execution problems
Pycharm basic settings latest version 2022
受限线性表
Pycharm essential plug-in, change the background (self use, continuous update) | CSDN creation punch in
【leetcode】day1
Wechat applet development beginner 1
Map operation execution process
How to login and enable synchronization function in Google browser
P1055 [noip2008 popularization group] ISBN number
B_ QuRT_ User_ Guide(38)
MySQL架构