1. 程式人生 > 資訊 >韓版三星 Galaxy Note 10 開始測試 One UI 4.0 Beta 更新

韓版三星 Galaxy Note 10 開始測試 One UI 4.0 Beta 更新

好久沒更新了。。

A

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int, int>
#define x first
#define y second
const int N = 5e5 + 10;

string a, b;
int main() {
    int T;
    cin >> T;
    while (T--) {
        int l1, l2;
        cin >> a >> l1 >> b >> l2;
        if (a.length() + l1 > b.length() + l2) {
            puts(">");
        } else if (a.length() + l1 < b.length() + l2) {
            puts("<");
        } else {
            // for(int i=0;i<min(a.length()))
            int p1 = 0, p2 = 0;
            while (p1 < a.length() && p2 < b.length()) {
                if (a[p1] > b[p1]) {
                    puts(">");
                    break;
                } else if (a[p1] < b[p1]) {
                    puts("<");
                    break;
                }
                p1++, p2++;
            }
            // cout << p1 << " " << p2 << endl;
            if (p1 < a.length() && p2 == b.length()) {
                bool f = 0;
                while (p1 < a.length()) {
                    if (a[p1++] != '0') {
                        puts(">");
                        f = 1;
                        break;
                    }
                }
                if (!f)
                    puts("=");
            } else if (p1 == a.length() && p2 < b.length()) {
                 bool f = 0;
                while (p2 < b.length()) {
                    if (b[p2++] != '0') {
                        puts("<");
                        f = 1;
                        break;
                    }
                }
                if (!f)
                    puts("=");
            } else if (p1 == a.length() && p2 == b.length())
                puts("=");
        }
    }
}

B

不難發現可以用最小的數去模
麻了,一直RE,感覺自己是個傻子

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int, int>
#define x first
#define y second
const int N = 1e6 + 10;
int a[N], n;
bool pos[N << 1], vis[N << 1];
int main() {
    int T;
    cin >> T;
    while (T--) {
        cin >> n;
        int mn = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            mn = max(mn, a[i]);
            pos[a[i]] = 1;
        }
        sort(a, a + n);

        int need = n / 2;
        for (int k = 1; k < n && need--; k++) {
            // for (int i = 0; i +k < n && need; i++) {
            //     // cout<<"cjeck: "<<a[i+k]<<" "<<a[i]<<endl;
            //     if (!pos[a[i + k] % a[i]]) {
            //         // if(!need) break;
            //         cout << a[i + k] << " " << a[i] << endl;
            //         need--;
            //     }
            // }
            cout<<a[k]<<" "<<a[0]<<endl;
        }
        for (int i = 0; i <= mn; i++)
            pos[i] = 0;
    }
}

C

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
int a[N], n;
ll need;
bool judge(ll k) {
    ll len = 0;
    int pre = 0;
    for (int i = 0; i < n - 1; i++) {
        len += min(k,1ll*a[i+1] - a[i]);
        // pre = a[i];
    }
    len += k;
    // cout<<k<<": "<<len<<endl;
    if (len >= need)
        return true;
    return false;
}
int main() {
    int T;
    cin >> T;
    while (T--) {
        cin >> n >> need;
        for(int i=0;i<n;i++) cin>>a[i];
        // judge(4);
        ll l = 0, r = 1e18 + 1, mid, ans;

        while (l <= r) {
            mid = (l + r) >> 1;
            if (judge(mid)) {
                r = mid - 1;
                ans = mid;
            } else {
                l = mid + 1;
            }
        }
        cout<<ans<<endl;
    }
}

D

計數。。還不錯的題

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5 + 10;
const int mod = 998244353;
ll dp[N], dp2[N], a[N];
int main() {
    int n, T;
    cin >> T;
    while (T--) {
        cin >> n;
        for (int i = 0; i <= n; i++) dp[i] = dp2[i] = 0;
        dp[0] = 1;
        int x;
        for (int i = 0; i < n; i++) {
            cin >> x;
            dp[x + 1] = (dp[x + 1]+ dp[x + 1]+dp[x])%mod;
            if (x > 0) dp2[x - 1] = (dp2[x - 1]+ dp2[x - 1]+dp[x-1])%mod;
            dp2[x + 1] = (dp2[x + 1] + dp2[x + 1]) % mod;
        }
        int ans = 0;
        for (int i = 0; i <= n; i++) ans = (ans + dp[i]) % mod;
        for (int i = 0; i <= n; i++) ans = (ans + dp2[i]) % mod;
        cout << (ans + mod -1 )%mod<< endl;
    }
}

E

bfs水題,這咋放到E的。。

#include <bits/stdc++.h>
#define P pair<int, int>
#define x first
#define y second
#define endl '\n'
using namespace std;
const int N = 1e6;
vector<vector<int>> mp, vis;
int n, m, sx, sy;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
bool check(int x, int y) {
    return (1 <= x && x <= n && 1 <= y && y <= m && mp[x][y] && !vis[x][y]);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin >> T;
    while (T--) {
        cin >> n >> m;
        mp.resize(n + 1);
        vis.resize(n + 1);
        char tmp;
        for (int i = 1; i <= n; i++) {
            mp[i].resize(m + 1);
            vis[i].resize(m + 1);
            for (int j = 1; j <= m; j++) {
                cin >> tmp;
                if (tmp == 'L') {
                    sx = i, sy = j;
                }
                mp[i][j] = tmp == '.' || tmp == 'L' ? 1 : 0;
                vis[i][j] = 0;
            }
        }
        queue<P> q;
        q.push(P(sx, sy));
        vis[sx][sy] = 1;

        while (q.size()) {
            P now = q.front();
            q.pop();
            vector<P> ans;
            for (int i = 0; i < 4; i++) {
                int nx = now.x + dx[i], ny = now.y + dy[i];
                if (check(nx, ny)) {
                    ans.push_back(P(nx, ny));
                }
            }
            // cout << "walk: " << now.x << " " << now.y << " " << ans.size()
            //      << endl;
            if (ans.size() <= 1 || (now.x == sx && now.y == sy)) {
                vis[now.x][now.y] = true;
                for (auto p : ans) {
                    if (!vis[p.x][p.y]) q.push(P(p.x, p.y));
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (i == sx && j == sy) {
                    cout << 'L';
                    continue;
                }
                cout << (vis[i][j] ? '+' : (mp[i][j] ? '.' : '#'));
            }
            cout << endl;
        }
    }
}