# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
735262 | aykhn | Trol (COCI19_trol) | C++14 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
/*
author: aykhn
5/1/2023
*/
using namespace std;
typedef long long ll;
const int oo = INT_MAX;
const ll ooo = LONG_MAX;
const ll mod = 1e9 + 7;
#define OPT ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define mpr make_pair
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define inf 0x3F3F3F3F
#define tos to_string
#define infll 0x3F3F3F3F3F3F3F3FLL
#define bpc __builtin_popcount
#define print(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout<<endl;
char make(int i)
{
string s = tos(i);
while (s.length() > 1)
{
int x = 0;
for (int j = 0; j < s.length(); j++) x += s[j] - '0';
s = tos(x);
}
return s[0];
}
int main()
{
OPT;
int q;
cin >> q;
while (q--)
{
ll l, r;
cin >> l >> r;
ll res = 0;
while ((l - 1)%9 + 1 != 1 && l <= r)
{
res += (l - 1)%9 + 1;
l++;
}
while ((r - 1)%9 + 1 != 9 && l <= r)
{
res += (r - 1)%9 + 1;
r--;
}
if (l > r)
{
cout << res << endl;
continue;
}
cout << res + (r - l + 1)*5 << endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |