QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#612641#7897. Largest Digitwzxtsl#WA 2ms3652kbC++232.2kb2024-10-05 12:24:242024-10-05 12:24:26

Judging History

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

  • [2024-10-05 12:24:26]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3652kb
  • [2024-10-05 12:24:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
int n,m;
int la,lb,ra,rb;
const int N=2e6+7;
const int mod=998244353;
int a[N];
void solve(){
    cin>>la>>ra>>lb>>rb;
    if(la+10<=ra||lb+10<=rb) 
    {
        cout<<9;return;
    }
    la%=10,lb%=10,ra%=10,rb%=10;
    int maxn=0;
    if(la<=ra&&lb<=rb) 
    {
        for(int i=la;i<=ra;i++)
        {
            for(int j=lb;j<=rb;j++)
            {
                maxn=max(maxn,(i+j)%10);
            }
        }
    }
    else if(la>ra&&lb<=rb)
    { 
        for(int i=la;i<=9;i++)
        {
            for(int j=lb;j<=rb;j++)
            {
                maxn=max(maxn,(i+j)%10);//cout<<i<<"@"<<j<<"@@"<<maxn<<"!"; 
            }
        }    
        for(int i=0;i<=ra;i++)
        {
            for(int j=lb;j<=rb;j++)
            {
                maxn=max(maxn,(i+j)%10);
            }
        }            
        
    }
    else if(la>ra&&lb>rb)
    {
        for(int i=la;i<=9;i++)
        {
            for(int j=lb;j<=9;j++)
            {
                maxn=max(maxn,(i+j)%10);
            }
        }   
        for(int i=la;i<=9;i++)
        {
            for(int j=0;j<=rb;j++)
            {
                maxn=max(maxn,(i+j)%10);
            }
        }          
        for(int i=0;i<=ra;i++)
        {
            for(int j=lb;j<=9;j++)
            {
                maxn=max(maxn,(i+j)%10);
            }
        }    
        for(int i=0;i<=ra;i++)
        {
            for(int j=0;j<=rb;j++)
            {
                maxn=max(maxn,(i+j)%10);
            }
        }                    
    }    
    else if(lb>rb&&la<=ra)
    {
        for(int i=lb;i<=9;i++)
        {
            for(int j=la;j<=ra;j++)
            {
                maxn=max(maxn,(i+j)%10);
            }
        }    
        for(int i=0;i<=rb;i++)
        {
            for(int j=la;j<=ra;j++)
            {
                maxn=max(maxn,(i+j)%10);
            }
        }              
    }
    cout<<maxn<<endl;
}
signed main(){
    fast;
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3564kb

input:

2
178 182 83 85
2 5 3 6

output:

7
9

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3652kb

input:

1000
158260522 877914575 24979445 602436426
1 5 1101111 1101112
2 5 33333 33335
1 5 10111 10111
138996221 797829355 353195922 501899080
212 215 10302 10302
101100 101101 1 2
111 114 1101000 1101001
265804420 569328197 234828607 807497925
1110110 1110112 11100 11103
323 327 23 27
1 1 1 5
316412581 80...

output:

97
9
6
97
3
5
95
9
6
99
9
9
99
9
9
95
9
6
99
7
8
99
9
9
99
3
7
97
7
9
96
5
9
96
9
6
99
9
5
94
6
5
97
8
8
99
9
6
98
9
5
97
9
7
99
6
5
91
3
6
95
8
6
99
2
4
99
9
9
99
5
2
94
5
9
99
8
6
95
7
9
95
9
5
97
8
5
99
9
7
99
3
3
99
5
7
99
6
6
97
7
9
97
9
8
95
8
6
97
9
3
95
8
8
97
2
8
99
6
8
99
9
9
99
8
9
97
7
6...

result:

wrong answer 1st lines differ - expected: '9', found: '97'