当前位置:网站首页>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;
}
边栏推荐
- postgis学习
- 2022 certified surveyors are still at a loss when preparing for the exam? Teach you how to take the exam hand in hand?
- HDU - 1260 tickets (linear DP)
- mysql8.0 ubuntu20.4
- ESP at installation esp8266 and esp32 versions
- The for loop realizes 1-100 addition and eliminates the 4-digit tail number
- The file format and extension of XLS do not match
- @Configuration注解的详细介绍
- Right click the idea file to create new. There is no solution to create new servlet
- 2022.7.7-----leetcode.648
猜你喜欢
Live server usage
Restricted linear table
Chisel tutorial - 04 Control flow in chisel
ESP at installation esp8266 and esp32 versions
Flash encryption process and implementation of esp32
Arbre binaire équilibré [Arbre AVL] - Insérer et supprimer
List. How to achieve ascending and descending sort() 2020.8.6
Installing gradle
SAP HR reward and punishment information export
B_ QuRT_ User_ Guide(38)
随机推荐
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."
Learn about scratch
Live server usage
AITM3.0005 烟雾毒性测试
Anti climbing means cracking the second
ASP. Net core middleware request processing pipeline
Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
How to change the formula picture in the paper directly into the formula in word
C method question 1
C - linear table
Access database query all tables SQL
Dataguard 主备清理归档设置
Interface
Take you hand in hand to build feign with idea
KeePass realizes automatic input of web pages
Rock-paper-scissors
B_ QuRT_ User_ Guide(39)
C simple question 2
[summary] some panels and videos seen
激光slam学习(2D/3D、偏实践)