当前位置:网站首页>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;
}
边栏推荐
- P2141 [noip2014 popularization group] abacus mental arithmetic test
- P1055 [noip2008 popularization group] ISBN number
- Summary of common methods of object class (September 14, 2020)
- How can we make money by making video clips from our media?
- Boost regex library source code compilation
- Fibonacci number of dynamic programming
- Arbre binaire équilibré [Arbre AVL] - Insérer et supprimer
- C simple question one
- Balanced binary tree [AVL tree] - insert, delete
- Chisel tutorial - 04 Control flow in chisel
猜你喜欢
How to change the formula picture in the paper directly into the formula in word
SAP HR labor contract information 0016
神奇快速幂
Chisel tutorial - 02 Chisel environment configuration and implementation and testing of the first chisel module
Markdown
c—线性表
Pycharm essential plug-in, change the background (self use, continuous update) | CSDN creation punch in
2022 certified surveyors are still at a loss when preparing for the exam? Teach you how to take the exam hand in hand?
0-1背包问题
SAP memory parameter tuning process
随机推荐
Flash encryption process and implementation of esp32
Flash download setup
保证接口数据安全的10种方案
webflux - webclient Connect reset by peer Error
受限线性表
Codeworks 5 questions per day (average 1500) - day 8
gorm 关联关系小结
解析token的网址
Navicat connects Oracle
P1308 [noip2011 popularity group] count the number of words
2022.7.7-----leetcode.648
Map operation execution process
通达信买基金安全吗?
Chisel tutorial - 01 Introduction to Scala
SAP HR奖罚信息导出
Lm12 rolling heikin Ashi double K-line filter
Alibaba cloud MySQL cannot connect
C # exchange number, judge to pass the exam
One of the anti climbing methods
C method question 1