QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#704094#7897. Largest Digityeah14AC ✓0ms17868kbC++173.7kb2024-11-02 19:16:352024-11-02 19:16:36

Judging History

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

  • [2024-11-02 19:16:36]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:17868kb
  • [2024-11-02 19:16:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull long long
#define PII  pair<int ,int>
const int INF = 1145141919810;
const int mod = 1e9 + 7;
const int N = 1e5+5;
int fp(int a, int x, int mod) {
    int ans = 1;
    while (x) {
        if (x & 1)ans *= a;
        ans %= mod;
        a *= a;
        a %= mod;
        x >>= 1;
    }
    return ans;
}
bool check1(int n) {
    for (int i = 2; i <= n / 2; i++) {
        if (n % i == 0)return 0;
    }
    return 1;
}
struct tree {
    int sum, pre, suf;
    int tag = -1;
};
tree tr[4 * N];
int ls(int p) { return p << 1; }
int rs(int p) { return (p << 1) + 1; }
int history[N], tot = 0;
void add_tag(int p, int d, int pl, int pr) {
    tr[p].tag += d;
    tr[p].sum += d*(pr-pl+1);
}
void push_down(int p, int len) {
    if (tr[p].tag != -1) {
        tr[ls(p)].tag = tr[rs(p)].tag = tr[p].tag;
        tr[ls(p)].pre = tr[ls(p)].sum = (tr[p].tag == 0) ? 0 : (len - (len >> 1));
        tr[rs(p)].pre = tr[rs(p)].sum = (tr[p].tag == 0) ? 0 : (len >> 1);
        tr[p].tag = -1;
    }
}
void push_up(int p, int len) {
    tr[p].pre = tr[ls(p)].pre;
    tr[p].suf = tr[rs(p)].suf;
    if (tr[ls(p)].pre == (len - (len >> 1))) {
        tr[p].pre = tr[ls(p)].pre + tr[rs(p)].pre;
    }
    if (tr[rs(p)].suf == (len >> 1)) {
        tr[p].suf = tr[rs(p)].suf + tr[ls(p)].suf;
    }
}
void build(int pl, int pr, int p) {
    tr[p].tag = -1;
    if (pl == pr) {
        tr[p].sum = tr[p].pre = tr[p].suf = 1;
        return;
    }
    int mid = (pl + pr) >> 1;
    build(pl, mid, ls(p));
    build(mid + 1, pr, rs(p));
    push_up(p, pr - pl + 1);
}

void update(int L,int R, int c, int p, int pl, int pr) {
    if (L <= pl && R >= pr) {
        tr[p].pre=tr[p].suf=tr[p].sum = (c == 0) ? 0 : pr - pl + 1;
        tr[p].tag = c;
        return;
   }
    int mid = (pl + pr) >> 1;
    if (L <= mid)update(L, R, c, ls(p), pl, mid);
    if (R > mid)update(L, R, c, rs(p), mid + 1, pr);
    //else update(x, c, rs(p), mid + 1, pr);
    push_up(p, pr - pl + 1);
}

int query(int len, int p, int pl, int pr) {
    if (pl == pr)return pl;
    int mid = (pl + pr) >> 1;
    if (len <= tr[ls(p)].sum) {
        if (len <= tr[p].pre)return pl;
        else return query(len, ls(p), pl, mid);
    }
    else if (len <= tr[rs(p)].pre + tr[ls(p)].suf) {
        return mid - tr[ls(p)].suf + 1;
    }
    else if (len <= tr[rs(p)].sum) {
        if (len <= tr[rs(p)].pre)return pl;
        else return query(len, rs(p), mid+1, pr);
    }

}


struct print{
    int s, x;
    bool operator<(const print a)const {
        if (a.s != s)return a.s > s;
       else return a.x< x;
    }
};
print a[N];
int b[N];
int c[N];
map<int, int>q;
void solve() {
    int la, ra, lb, rb;
    cin >> la >> ra >> lb >> rb;
    if (ra - la + rb - lb >= 19)cout << 9 << endl;
    else {
        int ans = 0;
        for (int a = la; a <= ra; a++) {
            for (int b = lb; b <= rb; b++) {
                int x = a + b;
                while (x) {
                    ans = max(ans, x % 10);
                    x /= 10;
                    if (ans >= 9) {
                        cout << 9 << endl;
                        return;
                    }
                }
            }
        }
        cout << ans << endl;
    }
}

//&&(((sum[n]+k)%mid==0)||(sum[n]/mid!=(sum[n]+k)/mid)||(mid-(sum[n]%mid)>=k))
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    //while (t--) {
    //    //if (k == 100000)cout << k - t + 1 << " ";
    //    solve();
    //}
}

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

详细

Test #1:

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

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: 17832kb

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