UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#193877#3398. countquhaoran10053ms2752kbC++566b2023-10-14 17:32:552023-10-14 18:39:41

answer

#include<bits/stdc++.h>
using namespace std;
long long a[100005],w[100005],p[25],cnt[25];
int main()
{
	long long i,j,n,t,ans=0,mod=1e9+7;
	cin>>n;
	p[0]=1;
	for(i=1;i<=18;i++) p[i]=p[i-1]*10ll;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		for(j=1;j<=18;j++)
		{
			if(a[i]<p[j])
			{
				w[i]=j;
				cnt[j]++;
				break;
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		cnt[w[i]]--;
		for(j=1;j<=18;j++)
		{
			ans=ans+((((p[j]%mod)*cnt[j])%mod)*a[i]%mod);
			ans%=mod;
		}
		ans=ans+(n-1)*a[i];
		ans%=mod;
		cnt[w[i]]++;
	}
	cout<<ans;
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 20
Accepted
time: 0ms
memory: 1216kb

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: 1216kb

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: 1216kb

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: 1212kb

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: 53ms
memory: 2752kb

input:

100000
227552529 170886571 513851125 46675201 188079376 255537313 266819605 69661658 214521435 33384...

output:

677195751

result:

ok single line: '677195751'