T7314 yyy chocolate (clock), t7314yyy chocolate

Source: Internet
Author: User

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 }

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.