QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#397193 | #7897. Largest Digit | w4p3r | WA | 1ms | 3620kb | C++20 | 680b | 2024-04-23 19:26:51 | 2024-04-23 19:26:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define N 10010
#define inf 1e18
int calc(int x)
{
int ans = 0;
while (x) {ans = max(ans, x % 10); x /= 10;}
return ans;
}
void sol()
{
int la, ra, lb, rb;
cin >> la >> ra >> lb >> rb;
if ((ra + rb) - (la + lb) >= 10) {cout << 9 << '\n'; return ;}
int ans = -1;
for (int i = la; i <= lb; i ++)
{
for (int j = ra; j <= rb; j ++)
{
ans = max(ans, calc(i + j));
}
}
cout << ans << '\n';
}
int main()
{
int T; cin >> T;
while(T --)sol();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3620kb
input:
2 178 182 83 85 2 5 3 6
output:
-1 9
result:
wrong answer 1st lines differ - expected: '7', found: '-1'