Submission #208092

# Submission time Handle Problem Language Result Execution time Memory
208092 2020-03-10T02:07:27 Z dOAOb Trol (COCI19_trol) C++14
30 / 50
1000 ms 376 KB
#include<iostream>
using namespace std;

#define int long long

#ifdef lioraju
	#define ndbg(x) 
#else
	#define ndbg(x) x
#endif

int f(int i)
{
	if (i<10) return i;
	
	int sum = 0;
	while (i)
		sum += i%10, i/=10;
	return f(sum);
}

signed main()
{
	ndbg( ios::sync_with_stdio(0); cin.tie(0); );
	int q; cin>>q;
	for (int qi=0; qi<q; qi++)
	{
		int l, r, sum = 0; cin>>l>>r;
		for (int i=l;i<=r;i++)
			sum += f(i);
		
		cout<<sum<<'\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Execution timed out 1067 ms 376 KB Time limit exceeded
5 Execution timed out 1089 ms 376 KB Time limit exceeded