#include<bits/stdc++.h> #define int long long usingnamespace std; using ll = longlong; using arr2 = array<int, 2>; using arr3 = array<int, 3>; constint N = (int)2e5 + 9; constint M = (int)1e5 + 9; constint mod = 998244353;
voidsolve(){ int n, w; cin >> n >> w; cout << n - n / w << "\n"; }
#include<bits/stdc++.h> #define int long long usingnamespace std; using ll = longlong; using arr2 = array<int, 2>; using arr3 = array<int, 3>; constint N = (int)2e5 + 9; constint M = (int)1e5 + 9; constint mod = 998244353;
boolcmp(arr2 a, arr2 b){ return a[0] > b[0]; }
voidsolve(){ int n, x, y; cin >> n >> x >> y; vector<arr2> a(n + 5); int sum = 0; for (int i = 1; i <= n; i++) { cin >> a[i][1]; sum += a[i][1]; a[i][0] = a[i][1] % x + (a[i][1] / x * (x - y)); } sort(a.begin() + 1, a.begin() + 1 + n); for (int i = 1; i < n; i++) { sum -= a[i][0]; } cout << sum << "\n"; }
#include<bits/stdc++.h> #define int long long usingnamespace std; using ll = longlong; using arr2 = array<int, 2>; using arr3 = array<int, 3>; constint N = (int)2e5 + 9; constint M = (int)1e5 + 9; constint mod = 998244353;
voidsolve(){ int n, k; cin >> n >> k; vector<string> s(k); for (int i = 0; i < k; i++) cin >> s[i]; //预处理 vector<vector<bool>> vis(n + 5, vector<bool>(30, 0)); for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { vis[i][s[j][i] - 'a'] = 1; } } //枚举单元字符串长度 for (int len = 1; len <= n; len++) { //注意continue if (n % len) continue; string tmp = ""; bool fff = 0; //枚举前len位的字符选取 for (int i = 0; i < len; i++) { bool f = 0; //每一位都从k个字符串在i这个位置的字符中选取 for (int j = 0; j < k; j++) { //s[j][i] int xx = s[j][i] - 'a'; bool ff = 0; //每个选取出来的字符判断是否可以在后续循环出现 for (int p = i + len; p < n; p += len) { if (!vis[p][xx]) { ff = 1; break; } } if (!ff) { tmp += s[j][i]; f = 1; break; } } if (!f) { fff = 1; break; } } if (!fff) { int xxx = tmp.size(); for (int i = 0; i < n; i++) { cout << tmp[i % xxx]; } cout << "\n"; return ; } } }
#include<bits/stdc++.h> #define int long long usingnamespace std; using ll = longlong; using arr2 = array<int, 2>; using arr3 = array<int, 3>; constint N = (int)2e5 + 9; constint M = (int)1e5 + 9; constint mod = 998244353;
voidsolve(){ int n, m; cin >> n >> m; vector<vector<int>> a(n + 5, vector<int> (m + 5)); auto pre = a; int sum = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; sum += a[i][j]; pre[i][j] = pre[i - 1][j] + pre[i][j - 1] + a[i][j] - pre[i - 1][j - 1]; } } if (sum == 0) { cout << 0 << "\n"; for (int j = 1; j <= m; j++) cout << 'R'; for (int i = 1; i <= n; i++) cout << 'D'; cout << "\n"; return ; } if (sum % 2) { cout << sum / 2 * (sum / 2 + 1) << "\n"; } else cout << sum / 2 * (sum / 2) << "\n"; int cnt = 0; int i = 1; string ans = ""; while (i <= n) { cnt = pre[i][m]; if (i != 1) ans += 'D'; if (cnt > sum / 2) break; i++; } int j = 1; int tmp = cnt; while (j <= m) { cnt = tmp - (pre[i][j] - pre[i - 1][j]); ans += 'R'; if (cnt <= sum / 2) break; j++; } ans += 'D'; i++; j++; for (j; j <= m; j++) ans += 'R'; for (i; i <= n; i++) ans += 'D'; cout << ans << "\n"; }