Description
When cats see a larger cake than a biscuit, they generally think that the cake is better than a biscuit>. <. Therefore, if Freda gave me the I kitten cake and the kitten was the first to eat the cake, I + 2, I + 4, I + 6 ...... only a kitten cake.
That is to say, if a positive integer I exists, the following conditions are met:
1. For all 0 <j <I, the J-day kitten eats cookies.
2. Cat I eats a cake.
You must have:
For all I <k <= n, k mod 2 = I mod 2, the K kitten eats the cake.
Freda was too busy with a large number of kittens. How many possible methods does Freda offer to entertain the N kittens?
Question:
Enumerate the first place to eat the cake, determine the rest after the position, and then you can calculate the sum of the proportional series, and quickly create a power...
Code:
1 #include<cstdio> 2 3 #include<cstdlib> 4 5 #include<cmath> 6 7 #include<cstring> 8 9 #include<algorithm>10 11 #include<iostream>12 13 #include<vector>14 15 #include<map>16 17 #include<set>18 19 #include<queue>20 21 #include<string>22 23 #define inf 100000000024 25 #define maxn 500+10026 27 #define maxm 500+10028 29 #define eps 1e-1030 31 #define ll long long32 33 #define pa pair<int,int>34 35 #define for0(i,n) for(int i=0;i<=(n);i++)36 37 #define for1(i,n) for(int i=1;i<=(n);i++)38 39 #define for2(i,x,y) for(int i=(x);i<=(y);i++)40 41 #define for3(i,x,y) for(int i=(x);i>=(y);i--)42 43 #define mod 100000000744 45 using namespace std;46 47 inline ll read()48 49 {50 51 ll x=0,f=1;char ch=getchar();52 53 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}54 55 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}56 57 return x*f;58 59 }60 ll power(ll x,ll y)61 {62 ll t=1;63 for(;y;y>>=1,x=(x*x)%mod)64 if(y&1)t=(t*x)%mod;65 return t;66 }67 68 int main()69 70 {71 72 freopen("input.txt","r",stdin);73 74 freopen("output.txt","w",stdout);75 76 ll n=read();77 if((n&1)==0)printf("%lld\n",((power(2,n>>1)-1)*3+1)%mod);78 else printf("%lld\n",(power(2,(n+3)>>1)-2+mod)%mod);79 80 return 0;81 82 }
View code
"Poetize7" Freda guest