标签:style blog http ar io color os sp for
题目链接:点击打开链接
题意:
#include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include <string> #include <cctype> #include <vector> #include <cstdio> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> #define maxn 10000002 #define _ll __int64 #define ll long long #define INF 0x3f3f3f3f #define Mod 10000007 #define pp pair<int,int> #define ull unsigned long long using namespace std; char s[1010]; ll pow_mod(ll a,ll n,ll p) { if(n==0)return 1; ll ans=pow_mod(a,n/2,p); ans=ans*ans%Mod; if(n&1)ans=ans*a%Mod; return ans; } void solve() { ll len=strlen(s),ans=0; for(ll i=0;i<len;i++){ ll d=s[i]-'a'+1; ans=(ans+(d*pow_mod(4,len-i-1,Mod))%Mod)%Mod; } printf("%lld\n",ans); } int main() { int T;scanf("%d",&T); while(T--){ scanf("%s",s); solve(); } return 0; }
标签:style blog http ar io color os sp for
原文地址:http://blog.csdn.net/qq_16255321/article/details/41983919