本文共 2122 字,大约阅读时间需要 7 分钟。
1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 using namespace std; 13 typedef long long ll; 14 const int inf=0x7fffffff; 15 const int N=100000+100; 16 const int M=50000+10; 17 const ll mod=998244353; 18 ll k; 19 ll n; 20 string s[N]; 21 ll ans=0; 22 ll kuaisu(ll x) 23 { 24 ll ans=1,a=10; 25 while(x) 26 { 27 if(x%2==1) ans=((ans%mod)*(a%mod))%mod; 28 x/=2; 29 a=((a%mod)*(a%mod))%mod; 30 } 31 return ans; 32 } 33 ll cheng(ll a,ll b) 34 { 35 return ((a%mod)*(b%mod))%mod; 36 } 37 int main() 38 { 39 scanf("%lld",&k); 40 for(ll i=1;i<=k;i++) 41 cin>>s[i]; 42 for(ll i=1;i<=k;i++) 43 { 44 ll kk=0,cnt=0; 45 for(int j=s[i].size()-1;j>=0;j--) 46 { 47 kk+=cheng(kuaisu(cnt),s[i][j]-'0'); 48 kk+=cheng(kuaisu(cnt+1),s[i][j]-'0'); 49 cnt+=2; 50 } 51 ans+=kk%mod; 52 ans%=mod; 53 //cout< < =s[j].size()) 57 { 58 kk=0; cnt=0; 59 for(int kkk=s[j].size()-1;kkk>=0;kkk--) 60 { 61 kk+=cheng(kuaisu(cnt),s[j][kkk]-'0'); 62 kk+=cheng(kuaisu(cnt+1),s[j][kkk]-'0'); 63 cnt+=2; 64 } 65 ans+=kk%mod; 66 ans%=mod; 67 //cout< < =s[i].size()-cc;kkk--) 71 { 72 kk+=cheng(kuaisu(cnt),s[i][kkk]-'0'); 73 kk+=cheng(kuaisu(cnt+1),s[i][kkk]-'0'); 74 cnt+=2; 75 //cout< < =0;kkk--) 79 { 80 kk+=cheng(kuaisu(cnt),(s[i][kkk]-'0')*2); 81 cnt++; 82 } 83 ans+=kk%mod; 84 ans%=mod; 85 } 86 else if(s[i].size() =0;kkk--) 90 { 91 kk+=cheng(kuaisu(cnt),s[i][kkk]-'0'); 92 kk+=cheng(kuaisu(cnt+1),s[i][kkk]-'0'); 93 cnt+=2; 94 } 95 ans+=kk%mod; 96 ans%=mod; 97 int cc=s[i].size(); 98 kk=0; cnt=0; 99 for(int kkk=s[j].size()-1;kkk>=s[j].size()-cc;kkk--)100 {101 kk+=cheng(kuaisu(cnt),s[j][kkk]-'0');102 kk+=cheng(kuaisu(cnt+1),s[j][kkk]-'0');103 cnt+=2;104 }105 for(int kkk=s[j].size()-cc-1;kkk>=0;kkk--)106 {107 kk+=cheng(kuaisu(cnt),(s[j][kkk]-'0')*2);108 cnt++;109 }110 ans+=kk%mod;111 ans%=mod;112 }113 }114 }115 116 117 118 printf("%lld\n",ans);119 120 121 return 0;122 }
转载于:https://www.cnblogs.com/Kaike/p/11204617.html