signedmain() { ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); #if 0 freopen("in.txt", "r", stdin); #endif int T = scanner.nextInt(); while (T --) { int n, k; $$ n, k; int ans = n - k + k / 2; println(ans); for (int i = (k + 1) / 2; i < k; ++ i) print(i, ' '); for (int i = k + 1; i <= n; ++ i) print(i, ' '); println(); } return0; }
voidmirror(constchar *s, char *t) { for (int i = 0; i < 5; ++ i) if (s[i] == ':') t[4 - i] = ':'; else t[4 - i] = trans[s[i] - '0']; t[5] = 0; }
autoturn(constchar *s) { int H = (s[0] - '0') * 10 + s[1] - '0', M = (s[3] - '0') * 10 + s[4] - '0'; returnmake_pair(H, M); }
voidmake(int H, int M, char *s) { s[0] = H / 10 % 10 + '0'; s[1] = H % 10 + '0'; s[3] = M / 10 % 10 + '0'; s[4] = M % 10 + '0'; s[2] = ':', s[5] = 0; }
signedmain() { ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); #if 0 freopen("in.txt", "r", stdin); #endif int T = scanner.nextInt(), h, m; constauto validator = [&](constchar *s) { for (int i = 0; i < 5; ++ i) if (s[i] == '-') returnfalse; auto [H, M] = turn(s); return H >= 0 && H < h && M >= 0 && M < m; }; constauto tik = [&](char *s) { auto [H, M] = turn(s); ++ M; H = (H + M / m) % h; M %= m; make(H, M, s); }; while (T --) { char s[6], t[6]; $$ h, m, s; mirror(s, t); while (!validator(t)) tik(s), mirror(s, t); println(s); } return0; }
template <int n> auto &EulerSieve() { static vector<int> prime; static array<int, n + 1> vis; for (int i = 2; i <= n; ++ i) { if (!vis[i]) prime.push_back(i), vis[i] = i; for (auto & pp : prime) { if ((longs)i * pp > n) break; vis[i * pp] = pp; if (i % pp == 0) break; } } return vis; }
constint N = 2e5 + 5; constint mod = 1e9 + 7;
longs fastPow(longs a, ulongs b) { longs ans = 1; while(b) { if (b & 1u) ans = (ans * a) % mod; a = (a * a) % mod; b >>= 1u; } return ans % mod; }
signedmain() { ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); #if 0 freopen("in.txt", "r", stdin); #endif int n, q, a; longs ans = 1; auto pp = EulerSieve<N>(); vector<unordered_map<int, int>> part; unordered_map<int, multiset<int>> maintain; constauto update = [&](int div, int last) { if (maintain[div].size() != n) return; int now = *maintain[div].begin(); ans = ans * fastPow(div, now - last) % mod; }; constauto alter = [&](int i, int x) { while (1 != x) { auto div = pp[x], cnt = 0; while (div == pp[x]) ++ cnt, x /= div; auto old = part[i][div]; part[i][div] += cnt; int last = 0; if (maintain[div].size() == n) last = *maintain[div].begin(); if (old) { auto it = maintain[div].find(old); maintain[div].erase(it); } maintain[div].insert(old + cnt); update(div, last); } }; $$ n, q, part.resize(n + 1); for (int i = 1; i <= n; ++ i) $$ a, alter(i, a); int i, x; while (q --) $$ i, x, alter(i, x), println(ans); return0; }
intask(int h, int w, int x1, int y1, int x2, int y2) { cout << "? " << h << ' ' << w << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl; int tmp; cin >> tmp; return tmp; }
template <int n> auto &sieve() { static vector<int> prime; static array<int, n + 1> vis; for (int i = 2; i <= n; ++ i) { if (!vis[i]) prime.push_back(i), vis[i] = i; for (auto & pp : prime) { if ((longs)i * pp > n) break; vis[i * pp] = pp; if (i % pp == 0) break; } } return vis; }
signedmain() { ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); #if 0 freopen("in.txt", "r", stdin); #endif int n, m; auto p = sieve<N>(); constauto askM = [&](int len, int time) -> bool { constauto h = n, w = time / 2 * len; if (time == 2) returnask(h, w, 1, 1, 1, w + 1); elsereturn ask(h, w, 1, 1, 1, w + 1) && ask(h, w, 1, 1, 1, w + len + 1); }; constauto askN = [&](int len, int time) -> bool { constauto h = time / 2 * len, w = m; if (time == 2) returnask(h, w, h + 1, 1, 1, 1); elsereturn ask(h, w, h + 1, 1, 1, 1) && ask(h, w, h + len + 1, 1, 1, 1); }; cin >> n >> m; auto [nn, mm] = make_pair(n, m); for (int i = nn; i > 1; i /= p[i]) if (askN(nn / p[i], p[i])) nn /= p[i]; for (int i = mm; i > 1; i /= p[i]) if (askM(mm / p[i], p[i])) mm /= p[i]; constauto nt = n / nn, mt = m / mm; longs np = 0, mp = 0; for (int i = 1; i <= nt; ++ i) np += !(nt % i); for (int i = 1; i <= mt; ++ i) mp += !(mt % i); cout << "! " << np * mp << endl; return0; }