D1. Submarine in the Rybinsk Sea (easy edition)

it2022-05-05  245

思路:每个第k位(从1开始)都会恰好在2k和2k−1位各贡献n次

#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <queue> #include <cmath> #include<string> #include<map> #define ll long long #define inf 0x3f3f3f3f #define mod 998244353 #define maxn 1008611 using namespace std; ll n,a,num[maxn]; int main(){ cin>>n; ll ans=0; for(int i=0;i<n;i++){ cin>>a; ll k=0; while(a){ num[k++]=a; a/=10; } reverse(num, num+k); ll tmp=0; for(ll j=0;j<k;j++){ tmp=(tmp*100)%mod; tmp=(tmp+num[j])%mod; } ans=(ans+(tmp*n)%mod)%mod; ans=(ans+((tmp*10)%mod*n)%mod)%mod; } cout<<ans<<endl; return 0; }

 


最新回复(0)