Applese 涂颜色
生活随笔
收集整理的這篇文章主要介紹了
Applese 涂颜色
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
https://ac.nowcoder.com/acm/contest/330/E
Python版本一
題解:
std
一個比較顯然的結論是,對于每一列,有 2n 種涂色方法。
我們可以發現,當確定了第一列之后,由于左右相鄰不能同色,所以后面每一列的涂色方案也隨之確定。因此答案就是 2n 。
注意本題的 n 為高精度,需要使用指數循環節降冪或者十進制快速冪。(或者python)
C++版本一
/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,q; ll ans,cnt,flag,temp; char b[N],a[N]; ll qpow(ll x,ll n) //?? {ll ans=1;while(n){if(n%2==1) ans=ans*x%MOD;x=x*x%MOD;n/=2;}return ans; } int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endifscanf("%s%s",b,a);//scanf("%d",&t);//while(t--){}ll phic=MOD-1;int i,len=strlen(b);ll res=0;for(int i=0;i<len;i++){res=res*10+b[i]-'0';res%=phic;}ans=qpow(2,res)%MOD;cout<<ans<<endl;//cout << "Hello world!" << endl;return 0; }?
總結
以上是生活随笔為你收集整理的Applese 涂颜色的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Applese 填数字
- 下一篇: Applese 的QQ群