QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#304640#7897. Largest DigitjiajieshiAC ✓2ms7592kbC++173.7kb2024-01-13 22:27:332024-01-13 22:27:33

Judging History

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

  • [2024-01-13 22:27:33]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:7592kb
  • [2024-01-13 22:27:33]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long 
#define pii pair<int,int>
#define pss pair<string,string>
#define fi first
#define se second
#define pb push_back
#define un unsigned
#define ull unsigned long long
#define	int_INF 0x3f3f3f3f
#define LL long long
#define ll_INF 0x3f3f3f3f3f3f3f3f
#define ld long double
#define db double
#define re return
#define pll pair<ll,ll>
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define debug(a) cout<<"debug: "<<(#a)<<" = "<<a<<'\n'
#define cer(a) cerr<<#a<<'='<<(a)<<"@ line"<<__LINE__<<endl
#define cer2(a,b) cerr<<#a<<'='<<(a)<<','<<#b<<'='<<(b)<<"@ line"<<__LINE__<<endl
#define cer3(a,b,c) cerr<<#a<<'='<<(a)<<','<<#b<<'='<<(b)<<','<<#c<<'='<<(c)<<','<<"@ line"<<__LINE__<<endl
#define pdd pair<db,db>
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define KV(x) #x << " = " << x << ";"
#define DEBUG DebugLine(__LINE__)
using namespace std;
const int maxn=2e5+100;
const ll mode=998244353;
const int mode2=1e6+5;
const ll inf=9223372036854775807;
const db eps=1e-6;
typedef pair<int,int> hashv;
mt19937 mrand(random_device{}()); 
hashv operator + (hashv a,hashv b) {
	int c1=a.fi+b.fi,c2=a.se+b.se;
	if (c1>=mode) c1-=mode;
	if (c2>=mode2) c2-=mode2;
	return mp(c1,c2);
}

hashv operator - (hashv a,hashv b) {
	int c1=a.fi-b.fi,c2=a.se-b.se;
	if (c1<0) c1+=mode;
	if (c2<0) c2+=mode2;
	return mp(c1,c2);
}

hashv operator * (hashv a,hashv b) {
	return mp(1ll*a.fi*b.fi%mode,1ll*a.se*b.se%mode2);
}
int rnd(int x) { return mrand() % x;}
struct DebugLine {
  explicit DebugLine(int lineno) { std::cerr << lineno << "L "; }
 
  ~DebugLine() { std::cerr << std::endl; }
 
  template <typename T> DebugLine &operator<<(T &&v) {
    std::cerr << std::forward<T>(v);
    return *this;
  }
};
double PI = 3.141592653;
double my_cos(double x){
    return cos(x*PI / 180.0);
}
double my_sin(double x){
    return sin(x*PI / 180.0);
}
double my_tan(double x){
    return tan(x*PI / 180.0);
}
ll n,m,a[maxn];
ll sum,ans;
string str;
vector<int>vt;
int vis[maxn]; 
ll ksm(ll a,ll b)
{
	ll res=1ll;
	while(b)
	{
		if(b&1)
		res=res*a%mode;
		b>>=1;
		a=a*a%mode;
	}
	return res;
}
struct Hash_char{
    const ll mod=998244353, base=131;
    ll p[maxn], g[maxn];
    void getp(){
        p[0]=1;
        for(int i=1; i<maxn; i++){
            p[i]=p[i-1]*base%mod;
        }
    }
    LL Hash(char s[]){
        int len=strlen(s+1);
        g[0]=0, g[1]=s[1];
        for(int i=2; i<=len; i++){
            g[i]=(g[i-1]*base+s[i])%mod;
        }
        return g[len];
    }
    LL getLR(int l, int r){//µÃµ½s[l]-s[r]µÄhashÖµ 
        if(l>r) return 0;
        LL ans=((g[r]-g[l-1]*p[r-l+1])%mod+mod)%mod;
        return ans;
    }
    
 
}T[2];
LL strfz(int pos, int l, int r){//pos:Õý·´´®,·­×ªl, r¡£ 
    LL ans=T[pos].getLR(1, l-1)*T[pos].p[n-l+1]%T[pos].mod;
    LL res=T[pos^1].getLR(n-r+1, n-r+1+r-l)*T[pos].p[n-r]%T[pos].mod;
    ans=ans+res+T[pos].getLR(r+1, n);
    return ans%T[pos].mod;
}
ll f(ll x)
{
	int res=0;
	while(x)
	{
		int t=x%10;
		res=max(res,t);
		x/=10;
	}
	return res;
}
void solve()
{
	ll la,lb,ra,rb;
    cin>>la>>ra>>lb>>rb;
    ll L=la+lb;
    ll R=ra+rb;
    ans=0;
    if(R-L<=10)
    {
      for(ll i=L;i<=R;i++)
      {
         ans=max(ans,f(i));	
	  }
	  cout<<ans;
	}else{
		cout<<9;
	}
	cout<<'\n';
	
}
int main(){
	#ifndef ONLINE_JUDGE
		freopen("C:\\Users\\JIAJIEASHI\\Desktop\\in.cpp","r",stdin);
	//	freopen("out.cpp","w",stdout);
	#endif
    ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int test_case;
	test_case=1;
	cin>>test_case;
	while(test_case--) 
    solve();
	return 0;
}



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

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 7592kb

input:

2
178 182 83 85
2 5 3 6

output:

7
9

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 5560kb

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