ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#193802 | #3398. count | xv_hyy | 100 | 10ms | 2712kb | C++11 | 1.0kb | 2023-10-14 14:45:01 | 2023-10-14 18:37:35 |
answer
#include<bits/stdc++.h>
using namespace std;
#define ls(p) (p<<1)
#define rs(p) (ls(p)^1)
#define int long long
typedef pair<int,int> pii;
//typedef long long ll;
const int mod=1e9+7;
const double eps=1e-6;
const int INF=9223372036854775807;
const int N=1e5+5;
pii a[N];
int fac[10];
inline int read();
inline void solve(){
int n=read(),ans=0,sum=0,sumfac=0;fac[0]=1;
for(int i=1;i<=10;++i)fac[i]=fac[i-1]*10%mod;
for(int i=1;i<=n;++i){
int x=read(),cnt=0;
sum=(sum+x)%mod;
a[i].first=x;
while(x>0){
x/=10,cnt++;
}
a[i].second=cnt;
sumfac=(sumfac+fac[a[i].second])%mod;
}
ans=(n-1)*sum%mod;
for(int i=1;i<=n;++i){
int tmp=((sumfac-fac[a[i].second])%mod+mod)%mod;
ans=(ans+tmp*a[i].first%mod)%mod;
}
printf("%lld\n",ans);
}
signed main(){
int T=1;
// int T=read();
while(T--)solve();
return 0;
}
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return x*f;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 20
Accepted
time: 0ms
memory: 2708kb
input:
1000 332109541 265698305 339007233 386487277 65597920 217218907 436378017 221884663 270433433 268014...
output:
675688319
result:
ok single line: '675688319'
Test #2:
score: 20
Accepted
time: 0ms
memory: 2708kb
input:
1000 108652253 396843081 18739163 168730297 41598432 22132831 155692945 617160601 164753707 86147692...
output:
653845876
result:
ok single line: '653845876'
Test #3:
score: 20
Accepted
time: 0ms
memory: 2708kb
input:
1000 71158753 11073019 119630785 162780801 25368543 517705 123835636 254874371 4127795 157084999 201...
output:
126629477
result:
ok single line: '126629477'
Test #4:
score: 20
Accepted
time: 0ms
memory: 2712kb
input:
1000 496106605 30223789 139619196 52432001 12405522 405765988 35664524 102798391 192246625 760951562...
output:
891456070
result:
ok single line: '891456070'
Test #5:
score: 20
Accepted
time: 10ms
memory: 2712kb
input:
100000 227552529 170886571 513851125 46675201 188079376 255537313 266819605 69661658 214521435 33384...
output:
677195751
result:
ok single line: '677195751'