Submission #288342

# Submission time Handle Problem Language Result Execution time Memory
288342 2020-09-01T12:27:27 Z Lawliet Trol (COCI19_trol) C++17
50 / 50
1 ms 288 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long int lli;

lli getValue(lli k)
{
	if( k%9 != 0 ) return k%9;
	return 9;
}

int main()
{
	int n;
	scanf("%d",&n);

	while( n-- )
	{
		lli L, R;
		scanf("%lld %lld",&L,&R);

		lli ans = 0;

		while( L%9 != 1 && L <= R )
			ans += getValue( L++ );

		while( R%9 != 0 && L <= R )
			ans += getValue( R-- );

		lli sz = (R - L + 1)/9;
		ans += sz*45;

		printf("%lld\n",ans);
	}
}

Compilation message

trol.cpp: In function 'int main()':
trol.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
trol.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |   scanf("%lld %lld",&L,&R);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 1 ms 256 KB Output is correct