/* * @Author: Tifa * @Description: From <https://github.com/Tiphereth-A/CP-archives> * !!! ATTENEION: All the context below is licensed under a * GNU Affero General Public License, Version 3. * See <https://www.gnu.org/licenses/agpl-3.0.txt>. */ #include<bits/stdc++.h> usingnamespace std; intmain(){ int kase; cin >> kase; while (kase--) { unsignedlonglong n, k; cin >> n >> k; if (n % 2) for (int i = 3; i <= n; ++i) if (n % i == 0) { n += i; --k; break; } cout << n + k * 2 << endl; } return0; }
/* * @Author: Tifa * @Description: From <https://github.com/Tiphereth-A/CP-archives> * !!! ATTENEION: All the context below is licensed under a * GNU Affero General Public License, Version 3. * See <https://www.gnu.org/licenses/agpl-3.0.txt>. */ #include<bits/stdc++.h> usingnamespace std; #define _for(i, l, r) for (auto i = (l); i <= (r); ++i) #define _fd(i, r, l) for (auto i = (r); i >= (l); --i) constint N = 1e5 + 5; int s[N], f[N]; intmain(){ int kase; cin >> kase; while (kase--) { int n, ans = 1; cin >> n; _for(i, 1, n) f[i] = 1; _for(i, 1, n) cin >> s[i]; _fd(i, n / 2, 1) for (int j = i; j <= n; j += i) if (s[j] > s[i]) ans = max(ans, f[i] = max(f[i], f[j] + 1)); cout << ans << endl; } return0; }
/* * @Author: Tifa * @Description: From <https://github.com/Tiphereth-A/CP-archives> * !!! ATTENEION: All the context below is licensed under a * GNU Affero General Public License, Version 3. * See <https://www.gnu.org/licenses/agpl-3.0.txt>. */ #include<bits/stdc++.h> usingnamespace std; constint N = 1e5 + 5; longlonggcd(longlong a, longlong b){ return b == 0 ? a : gcd(b, a % b); } longlonglcm(longlong a, longlong b){ return a / gcd(a, b) * b; } int a[N], pre[N], suf[N]; intmain(){ int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; pre[1] = a[1]; suf[n] = a[n]; for (int i = 2; i <= n; ++i) pre[i] = gcd(pre[i - 1], a[i]); for (int i = n - 1; i; --i) suf[i] = gcd(suf[i + 1], a[i]); longlong ans = lcm(suf[2], pre[n - 1]); for (int i = 2; i < n; ++i) ans = lcm(ans, gcd(pre[i - 1], suf[i + 1])); cout << ans; return0; }
/* * @Author: Tifa * @Description: From <https://github.com/Tiphereth-A/CP-archives> * !!! ATTENEION: All the context below is licensed under a * GNU Affero General Public License, Version 3. * See <https://www.gnu.org/licenses/agpl-3.0.txt>. */ #include<bits/stdc++.h> usingnamespace std; constint N = 1e5 + 5; int s[N]; intmain(){ int kase; cin >> kase; while (kase--) { int n, k; cin >> n >> k; bool flag = 0; for (int i = 1; i <= n; ++i) { cin >> s[i]; flag |= s[i] == k; } if (!flag) { cout << "no\n"; continue; } if (n == 1) { cout << "yes\n"; continue; } flag = 0; for (int i = 1; i < n; ++i) if (s[i] >= k && s[i + 1] >= k) { flag = 1; break; } if (!flag) for (int i = 1; i < n - 1; ++i) if (s[i] >= k && s[i + 2] >= k) { flag = 1; break; } if (flag) cout << "yes\n"; else cout << "no\n"; } return0; }