T7314 yyy chocolate (clock), t7314yyy chocolate
Description
Input/Output Format
Input Format:
Output Format:
Input and Output sample input sample #1:
Output sample #1:
Description
M-1
We can think like this, 1*1 chocolate must be opened by 1*2
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<algorithm> 6 #include<queue> 7 #include<stack> 8 #define lli long long 9 using namespace std;10 const int mod=998244353;11 void read(int &n)12 {13 char c='+';int x=0;bool flag=0;14 while(c<'0'||c>'9'){c=getchar();if(c=='-')flag=1;}15 while(c>='0'&&c<='9')16 x=(x<<1)+(x<<3)+c-48,c=getchar();17 flag==1?n=-x:n=x;18 }19 lli n,m;20 int fastmul(int x,int p)21 {22 int now=x;23 int ans=0;24 while(p)25 {26 if(p&1)27 {28 --p;29 ans=(ans+now)%mod;30 }31 p>>=1;32 now=(now+now)%mod;33 }34 return (ans-1)%mod;35 }36 int main()37 {38 // freopen("bpmp.in","r",stdin);39 // freopen("bpmp.out","w",stdout);40 //read(n);read(m);41 cin>>n>>m;42 cout<<fastmul(n,m)%mod;43 return 0;44 }