当前位置:网站首页>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;
}
边栏推荐
- Dependency injection 2 advantage lifecycle
- B_ QuRT_ User_ Guide(39)
- codeforces每日5题(均1500)-第八天
- SAP HR labor contract information 0016
- @Configuration注解的详细介绍
- Where are you going
- P1308 [noip2011 popularity group] count the number of words
- Extract the file name under the folder under win
- 通达信买基金安全吗?
- Installing gradle
猜你喜欢
蓝桥ROS中使用fishros一键安装
Installing gradle
[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code
MySQL架构
Benchmarking Detection Transfer Learning with Vision Transformers(2021-11)
postgis学习
Progress broadcast | all 29 shield machines of Guangzhou Metro Line 7 have been launched
C method question 1
Lm12 rolling heikin Ashi double K-line filter
Open source hardware small project: anxinco esp-c3f control ws2812
随机推荐
Installing gradle
2022.7.7-----leetcode.648
How to change the formula picture in the paper directly into the formula in word
通达信买基金安全吗?
BSS 7230 航空内饰材料阻燃性能测试
P1055 [noip2008 popularization group] ISBN number
Alibaba cloud MySQL cannot connect
aws-aws help报错
Chisel tutorial - 03 Combinatorial logic in chisel (chisel3 cheat sheet is attached at the end)
95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)
0-1背包问题
C - Fibonacci sequence again
C inheritance and interface design polymorphism
mysql8.0 ubuntu20.4
Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
Svn relocation
FFA与ICGA造影
MP4文件格式解析之结合实例分析
Possible SQL for Oracle table lookup information
Reverse output three digit and arithmetic sequence