QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#609571 | #6300. Best Carry Player 2 | zake | RE | 0ms | 0kb | C++17 | 557b | 2024-10-04 13:27:34 | 2024-10-04 13:27:40 |
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