답안 #335226

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335226 2020-12-11T15:44:59 Z CaroLinda Trol (COCI19_trol) C++14
50 / 50
1 ms 364 KB
#include <bits/stdc++.h>

#define ll long long

using namespace std ;

int Q ;
ll L , R ;

int main()
{

	scanf("%d", &Q ) ;
	
	ll val[9] = {9,1,2,3,4,5,6,7,8} ;
	ll cte = 45 ;

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

		ll ans = 0LL ;

		if(R - L + 1 <= 1000 )
		{
			for(ll i = L ; i <= R ; i++ ) ans += val[ i%9 ] ;
			printf("%lld\n", ans ) ;
			continue ;				
		}

		for(; L % 9 != 0 ; L++ ) ans += val[L%9] ;
		for(; R % 9 != 8 ; R--) ans += val[ R%9 ] ;

		ans += cte * ( (R-L+1)/9LL ) ;

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

	}

}

Compilation message

trol.cpp: In function 'int main()':
trol.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%d", &Q ) ;
      |  ~~~~~^~~~~~~~~~~
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 ) ;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct