QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#314971 | #7897. Largest Digit | hyjsws | WA | 0ms | 3664kb | C++14 | 1.1kb | 2024-01-26 15:52:55 | 2024-01-26 15:52:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1000010;
typedef long long LL;
LL a,b,c,d,n,m,idx,ans,e[N],ne[N],h[N],l1,l2,r1,r2,x1,x2,y3,y2;
void init(int x1,int x2,int y3,int y2)
{
if(x2<x1) x2+=10;
if(y2<y3) y2+=10;
int ipx=0;
for(int i=x1;i<=x2;i++)
{
for(int j=y3;j<=y2;j++)
{
a=i%10+j%10;
ans=max(max(a%10+idx,a%10),ans);
if(a>=10) ipx=1;
}
}
idx=ipx;
}
void solve()
{
ans=0;idx=0;
cin>>l1>>r1>>l2>>r2;a=1;
for(LL i=1;i<=10;i++)
{
if(r1-l1>=10)
{
x1=0,x2=9;
}
else
{
x1=l1%10;
x2=x1+r1-l1;
}
if(r2-l2>=10)
{
y3=0,y2=9;
}
else
{
y3=l2%10;
y2=y3+r2-l2;
}
//cout<<x1<<" "<<x2<<" "<<y3<<" "<<y2<<endl;
init(x1,x2,y3,y2);
l1/=10;l2/=10;r1/=10;r2/=10;
}
cout<<ans<<endl;
}
int main()
{
LL N=1;
cin>>N;
while(N--)
{
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
input:
2 178 182 83 85 2 5 3 6
output:
7 9
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3664kb
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:
10 7 9 6 10 7 3 5 10 5 9 6 10 9 9 9 10 9 10 9 10 5 10 6 10 9 7 8 10 9 9 9 10 9 3 10 10 7 7 9 10 6 10 9 10 8 9 6 10 9 9 5 10 4 9 5 10 7 8 8 10 9 9 6 10 8 9 5 10 7 9 7 10 9 6 5 10 2 3 6 10 10 8 6 10 9 6 4 10 9 10 9 10 9 10 2 10 4 5 10 10 9 8 6 10 5 7 9 10 9 9 5 10 7 8 5 10 10 9 7 10 9 3 3 10 9 5 7 10 ...
result:
wrong answer 1st lines differ - expected: '9', found: '10'