QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397193#7897. Largest Digitw4p3rWA 1ms3620kbC++20680b2024-04-23 19:26:512024-04-23 19:26:52

Judging History

你现在查看的是最新测评结果

  • [2024-04-23 19:26:52]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3620kb
  • [2024-04-23 19:26:51]
  • 提交

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'