QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#609571#6300. Best Carry Player 2zakeRE 0ms0kbC++17557b2024-10-04 13:27:342024-10-04 13:27:40

Judging History

你现在查看的是最新测评结果

  • [2024-10-04 13:27:40]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-04 13:27:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[100005]; 
void solve()
{
	int n;
	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<n-1;++i)
	{
		int k=1,p=0;
		int j=0;
		while(a[i]>0||j>0)
		{
			
			int x=a[i]%10+a[i+1]%10+j;
			a[i]/=10;
			a[i+1]/=10;
			j=x/10;
			if(j>0) ans++;
			p+=k*(x%10);
			k*=10;
		}
		a[i+1]=p;
	}
	cout<<ans<<"\n";
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	cin>>t;
	while(t--) solve();
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

4
12345678 0
12345678 5
12345678 18
990099 5

output:


result: