题解:AT_arc048_c [ARC048C] 足の多い高橋君
好猎奇的远古 ARC,但是为什么没人写题解。
简要题意
有
思路
首先最短串的反转肯定会被包含在其他串中,设它的长度为
考虑剩下的部分。容易发现如果设
最后总的方案数为
代码
温馨提示:远古 AT 题目最后输出要换行。
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const int N=1e5+5,mod=1e9+7;
const ll inf=1e18;
ll qpow(ll a,ll b){
ll res=1;
while(b){
if(b&1) res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
ll n,l[N],mn=inf,g;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++) cin>>l[i],mn=min(mn,l[i]);
for(int i=1;i<=n;i++) g=gcd(g,l[i]-mn);
cout<<qpow(2,mn+(g+1)/2)<<endl;
return 0;
}