#include<bits/stdc++.h> usingnamespace std; using ll = longlong; constint M = 1234567890; voidTotoro() { int n, d; cin >> n >> d; ll x = M + d; int temp = n; int cnt = 0; while (temp) { temp /= 10; cnt++; } x = pow(10, cnt) * x; x += n; x -= x % n; cout << x / n << '\n'; } intmain() { int t; cin >> t; while (t--) { Totoro(); } }
#include<bits/stdc++.h> usingnamespace std; #define int long long using ll = longlong; constint M = 1234567890; constint mod = 998244353; intqpow(int x, int n) { int ans = 1; while (n) { if (n & 1) ans = ans * x % mod; x = x * x % mod; n >>= 1; } return ans; } intinv(int x) { returnqpow(x, mod - 2); } int ope[400005]; voidTotoro() { int n; cin >> n; int sz = 0; map<int, int> mp; int mx = -1; int ans = 1; for (int i = 1; i <= 2 * n; i++) cin >> ope[i]; for (int i = 1; i <= 2 * n; i++) { int num = ope[i]; if (num != -1) { if (mx > num) { cout << 0 << '\n'; return; } mp[num]++; sz++; } else { ans = ans * (*mp.begin()).second % mod; ans = ans * inv(sz) % mod; sz--; mx = max(mx, (*mp.begin()).first); (*mp.begin()).second--; if ((*mp.begin()).second == 0) mp.erase(mp.begin()); } } cout << ans << '\n'; } signedmain() { int t = 1; while (t--) { Totoro(); } }
#include<bits/stdc++.h> usingnamespace std; using ll = longlong; constint M = 1234567890; constint maxn=2e5+5; int n,m; ll a[maxn],dp[maxn]; voidTotoro() { cin >> n >> m; for (int i = 1; i <= m; i++) cin >> a[i]; for (int i = 1; i <= m; i++) dp[i] = 1e18; for (int i = 1; i <= m; i++) { for (int j = i - 1; j >= max(0, i - 50); j--) { dp[i] = min(dp[i], dp[j] + a[i] + 1ll * (i - j) * (i - j) * (i - j) * (i - j)); } } cout << dp[m]; } intmain() { int t = 1; while (t--) { Totoro(); } }
#include<bits/stdc++.h> usingnamespace std; using ll = longlong; constint M = 1234567890; boolcheck(ll x, int n, vector<ll> a, vector<ll> b) { ll l = -1e18; ll r = 1e18; for (int i = 1; i <= n; i++) { ll d = x * b[i]; l = max(l, a[i] - d); r = min(r, d + a[i]); } return l <= r; } voidTotoro() { int n; cin >> n; vector<ll> a(n + 1); vector<ll> b(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { cin >> b[i]; } ll l = 0; ll r = 1e9; while (l < r) { ll mid = (l + r) >> 1; if (check(mid, n, a, b)) { r = mid; } else { l = mid + 1; } } cout << l << '\n'; } intmain() { int t = 1; cin >> t; while (t--) { Totoro(); } }