当前位置:网站首页>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;
}
边栏推荐
- Design and implementation of spark offline development framework
- SAP HR 劳动合同信息 0016
- 保证接口数据安全的10种方案
- archery安装测试
- Open source hardware small project: anxinco esp-c3f control ws2812
- Alibaba cloud MySQL cannot connect
- SLAM面试总结
- C number of words, plus ¥, longest word, average value
- [experiment sharing] log in to Cisco devices through the console port
- HDU - 1260 Tickets(线性DP)
猜你喜欢
Lm12 rolling heikin Ashi double K-line filter
Right click the idea file to create new. There is no solution to create new servlet
蓝桥ROS中使用fishros一键安装
Anxinco EC series modules are connected to the multi protocol access products of onenet Internet of things open platform
SAP HR奖罚信息导出
Learn about scratch
ESP at installation esp8266 and esp32 versions
Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
The file format and extension of XLS do not match
Benchmarking Detection Transfer Learning with Vision Transformers(2021-11)
随机推荐
Flash download setup
JNI uses asan to check memory leaks
Anxin vb01 offline voice module access intelligent curtain guidance
C simple question 2
一份假Offer如何盗走了「Axie infinity」5.4亿美元?
go time包常用函数
MongoDB快速入门
Progress broadcast | all 29 shield machines of Guangzhou Metro Line 7 have been launched
Take you hand in hand to build Eureka client with idea
C - Fibonacci sequence again
postgres timestamp转人眼时间字符串或者毫秒值
MP4文件格式解析之结合实例分析
Flash encryption process and implementation of esp32
Chisel tutorial - 01 Introduction to Scala
0-1背包问题
正畸注意事项(持续更新中)
AITM3.0005 烟雾毒性测试
HB 5469民用飞机机舱内部非金属材料燃烧试验方法
[experiment sharing] log in to Cisco devices through the console port
MySQL架构