当前位置:网站首页>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;
}
边栏推荐
- MongoDB快速入门
- Rock-paper-scissors
- MP4文件格式解析之结合实例分析
- SAP HR reward and punishment information export
- SAP HR labor contract information 0016
- Possible SQL for Oracle table lookup information
- Anxin vb01 offline voice module access intelligent curtain guidance
- SAP HR family member information
- 【LeetCode】20、有效的括号
- SAP memory parameter tuning process
猜你喜欢
平衡二叉树【AVL树】——插入、删除
Idea automatically generates serialVersionUID
KeePass realizes automatic input of web pages
[stm32+esp8266 connect Tencent cloud IOT development platform 2] stm32+esp8266-01s connect Tencent cloud
Wechat applet development beginner 1
Learn about scratch
【路径规划】使用垂距限值法与贝塞尔优化A星路径
Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
Ora-02437 failed to verify the primary key violation
平衡二叉樹【AVL樹】——插入、删除
随机推荐
SAP HR family member information
aws-aws help报错
C simple question 2
MongoDB快速入门
How to login and enable synchronization function in Google browser
Live server usage
Chisel tutorial - 04 Control flow in chisel
SAP HR 劳动合同信息 0016
C inheritance and interface design polymorphism
@Configuration注解的详细介绍
AITM3.0005 烟雾毒性测试
2022.7.7-----leetcode.648
SAP HR labor contract information 0016
受限线性表
Chisel tutorial - 00 Ex.scala metals plug-in (vs Code), SBT and coursier exchange endogenous
The for loop realizes 1-100 addition and eliminates the 4-digit tail number
Pigsty:开箱即用的数据库发行版
C cat and dog
Summary of common methods of object class (September 14, 2020)
Apng2gif solutions to various problems