QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#510989#7897. Largest DigitJEdwardAC ✓1ms3644kbC++171.4kb2024-08-09 14:57:142024-08-09 14:57:14

Judging History

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

  • [2024-08-09 14:57:14]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3644kb
  • [2024-08-09 14:57:14]
  • 提交

answer

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define int long long
#define endl '\n'
#define lowbit(x) (x)&(-x)
#define pii pair<int,int>
#define all(s) s.begin(), s.end()
#define ls(x) (x<<1)
#define rs(x) (x<<1|1) 
#define here system("pause")
using namespace std;
template <class T> inline void read(T& x) { x = 0; char c = getchar(); bool f = 0; for (; !isdigit(c); c = getchar()) f ^= (c == '-'); for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48); x = f ? -x : x; }
template <class T> inline void write(T x) { if (x < 0) putchar('-'), x = -x; if (x < 10) putchar(x + 48); else write(x / 10), putchar(x % 10 + 48); }

const int N = 5e5+5;
const int mod = 998244353;
const int INF = 1e15+7;
const double eps = 1e-4;
inline int pow(int a, int b, int p){ int res = 1%p; while(b){ if(b&1) res=res*a%p; a=a*a%p, b>>=1;} return res;}
inline int inv(int a, int p){ return pow(a,p-2,p)%p;}
using namespace std;

inline int work(int x, int y){
	int res = 0, sum = x+y;
	while(sum){
		res = max(res, sum%10);
		sum/=10;
	}
	return res;
}
inline void sol(){
	int l, r, x, y;
	cin >> l >> r >> x >> y;
	if(r-l>=10 || y-x>=10){
		cout << 9 << endl;
	}else{
		int mx = 0;
		for(int i=l;i<=r;i++){
			for(int j=x;j<=y;j++){
				mx = max(mx, work(i, j));
			}
		}
		cout << mx << endl;
	}
}

signed main(){
	IOS;
	int tc = 1;
	cin >> tc;
	while(tc--){
		sol();
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3644kb

input:

2
178 182 83 85
2 5 3 6

output:

7
9

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3580kb

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:

9
7
9
6
9
7
3
5
9
5
9
6
9
9
9
9
9
9
9
9
9
5
9
6
9
9
7
8
9
9
9
9
9
9
3
8
9
7
7
9
9
6
7
9
9
8
9
6
9
9
9
5
9
4
9
5
9
7
8
8
9
9
9
6
9
8
9
5
9
7
9
7
9
9
6
5
9
2
3
6
9
9
8
6
9
9
6
4
9
9
9
9
9
9
8
2
9
4
5
9
9
9
8
6
9
5
7
9
9
9
9
5
9
7
8
5
9
9
9
7
9
9
3
3
9
9
5
7
9
9
6
6
9
7
7
9
9
8
9
9
9
5
9
6
9
7
9
4
9
5
...

result:

ok 1000 lines

Extra Test:

score: 0
Extra Test Passed