Submission #485659

# Submission time Handle Problem Language Result Execution time Memory
485659 2021-11-08T21:05:24 Z tato Trol (COCI19_trol) C++14
30 / 50
1000 ms 280 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll back(ll a)
{
	ll cnt=0;
	while(a>0)
		{
			cnt+=(a%10);
			a=a/10;
		}
		if(cnt>9)
			return back(cnt);
		else
		return cnt;
	
}

int main()
{
	int t;
	cin>>t;
	
	while(t--)
	{
		ll l,r;
		cin>>l>>r;
		ll cnt=0;
		for(ll k=l; k<=r; k++)
			cnt+=back(k);
			
		cout<<cnt<<endl;
		
	}
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Execution timed out 1096 ms 280 KB Time limit exceeded
5 Execution timed out 1095 ms 204 KB Time limit exceeded