feat(codeforces): more div 3s
This commit is contained in:
parent
7db2259486
commit
1ed20bd3a2
17 changed files with 656 additions and 16 deletions
17
codeforces/1027/.clang-format
Normal file
17
codeforces/1027/.clang-format
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortLambdasOnASingleLine: None
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortCaseExpressionOnASingleLine: false
|
||||||
|
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
ColumnLimit: 100
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
73
codeforces/1027/a.cc
Normal file
73
codeforces/1027/a.cc
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma GCC optimize("O2,unroll-loops")
|
||||||
|
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
using i16 = int16_t;
|
||||||
|
using u16 = uint16_t;
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u32 n;
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
u32 root = sqrt(n);
|
||||||
|
while (root * root < n) {
|
||||||
|
++root;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root * root == n) {
|
||||||
|
println("{} 0", root);
|
||||||
|
} else {
|
||||||
|
println("-1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
std::cin.exceptions(std::cin.failbit);
|
||||||
|
#ifdef LOCAL
|
||||||
|
std::cerr.rdbuf(std::cout.rdbuf());
|
||||||
|
std::cout.setf(std::ios::unitbuf);
|
||||||
|
std::cerr.setf(std::ios::unitbuf);
|
||||||
|
#else
|
||||||
|
std::cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
#endif
|
||||||
|
u32 tc = 1;
|
||||||
|
std::cin >> tc;
|
||||||
|
for (u32 t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
17
codeforces/17/.clang-format
Normal file
17
codeforces/17/.clang-format
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortLambdasOnASingleLine: None
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortCaseExpressionOnASingleLine: false
|
||||||
|
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
ColumnLimit: 100
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
|
@ -39,16 +39,14 @@ constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
void solve() {
|
void solve() {
|
||||||
u32 n;
|
u32 n, a;
|
||||||
cin >> n;
|
cin >> n;
|
||||||
u32 a;
|
i32 total = 0;
|
||||||
for (u32 i = 0; i < n; ++i) {
|
for (u32 i = 0; i < n; ++i) {
|
||||||
cin >> a;
|
cin >> a;
|
||||||
if (a % 2 == 0) {
|
total += (i & 1) ? -a : a;
|
||||||
--a;
|
|
||||||
}
|
|
||||||
print("{}{}", a, " \n"[i==n-1]);
|
|
||||||
}
|
}
|
||||||
|
println("{}", total);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() { // {{{
|
int main() { // {{{
|
||||||
|
|
@ -61,7 +59,7 @@ int main() { // {{{
|
||||||
std::cin.tie(nullptr)->sync_with_stdio(false);
|
std::cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
#endif
|
#endif
|
||||||
u32 tc = 1;
|
u32 tc = 1;
|
||||||
// std::cin >> tc;
|
std::cin >> tc;
|
||||||
for (u32 t = 0; t < tc; ++t) {
|
for (u32 t = 0; t < tc; ++t) {
|
||||||
solve();
|
solve();
|
||||||
}
|
}
|
||||||
17
codeforces/498/.clang-format
Normal file
17
codeforces/498/.clang-format
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortLambdasOnASingleLine: None
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortCaseExpressionOnASingleLine: false
|
||||||
|
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
ColumnLimit: 100
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
68
codeforces/498/a.cc
Normal file
68
codeforces/498/a.cc
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma GCC optimize("O2,unroll-loops")
|
||||||
|
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
using i16 = int16_t;
|
||||||
|
using u16 = uint16_t;
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
template <typename T> constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T> constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u32 n;
|
||||||
|
cin >> n;
|
||||||
|
u32 a;
|
||||||
|
for (u32 i = 0; i < n; ++i) {
|
||||||
|
cin >> a;
|
||||||
|
if (a % 2 == 0) {
|
||||||
|
--a;
|
||||||
|
}
|
||||||
|
print("{}{}", a, " \n"[i == n - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
std::cin.exceptions(std::cin.failbit);
|
||||||
|
#ifdef LOCAL
|
||||||
|
std::cerr.rdbuf(std::cout.rdbuf());
|
||||||
|
std::cout.setf(std::ios::unitbuf);
|
||||||
|
std::cerr.setf(std::ios::unitbuf);
|
||||||
|
#else
|
||||||
|
std::cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
#endif
|
||||||
|
u32 tc = 1;
|
||||||
|
// std::cin >> tc;
|
||||||
|
for (u32 t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include <bits/stdc++.h> // {{{
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
#include <version>
|
#include <version>
|
||||||
#ifdef __cpp_lib_ranges_enumerate
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
|
@ -22,11 +22,9 @@ using f64 = double;
|
||||||
using f128 = long double;
|
using f128 = long double;
|
||||||
|
|
||||||
#if __cplusplus >= 202002L
|
#if __cplusplus >= 202002L
|
||||||
template <typename T>
|
template <typename T> constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
constexpr T MIN = std::numeric_limits<T>::min();
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
constexpr T MAX = std::numeric_limits<T>::max();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LOCAL
|
#ifdef LOCAL
|
||||||
|
|
@ -42,7 +40,7 @@ void solve() {
|
||||||
u32 n, m;
|
u32 n, m;
|
||||||
cin >> n >> m;
|
cin >> n >> m;
|
||||||
vector<pair<u32, u32>> a(n);
|
vector<pair<u32, u32>> a(n);
|
||||||
for (auto& e : a) {
|
for (auto &e : a) {
|
||||||
cin >> e.first >> e.second;
|
cin >> e.first >> e.second;
|
||||||
}
|
}
|
||||||
sort(begin(a), end(a));
|
sort(begin(a), end(a));
|
||||||
|
|
@ -56,11 +54,13 @@ void solve() {
|
||||||
ans.push_back(i);
|
ans.push_back(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println("{}", ans.size();
|
println("{}", ans.size());
|
||||||
for (auto& e : ans) print("{} ", e); println();
|
for (auto &e : ans)
|
||||||
|
print("{} ", e);
|
||||||
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() { // {{{
|
int main() { // {{{
|
||||||
std::cin.exceptions(std::cin.failbit);
|
std::cin.exceptions(std::cin.failbit);
|
||||||
#ifdef LOCAL
|
#ifdef LOCAL
|
||||||
std::cerr.rdbuf(std::cout.rdbuf());
|
std::cerr.rdbuf(std::cout.rdbuf());
|
||||||
|
|
|
||||||
17
codeforces/570/.clang-format
Normal file
17
codeforces/570/.clang-format
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortLambdasOnASingleLine: None
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortCaseExpressionOnASingleLine: false
|
||||||
|
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
ColumnLimit: 100
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
77
codeforces/570/a.cc
Normal file
77
codeforces/570/a.cc
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma GCC optimize("O2,unroll-loops")
|
||||||
|
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
using i16 = int16_t;
|
||||||
|
using u16 = uint16_t;
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u32 n;
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
auto dsum = [](u32 N) {
|
||||||
|
u32 dsum = 0;
|
||||||
|
while (N > 0) {
|
||||||
|
dsum += N % 10;
|
||||||
|
N /= 10;
|
||||||
|
}
|
||||||
|
return dsum;
|
||||||
|
};
|
||||||
|
|
||||||
|
while (dsum(n) % 4 != 0) {
|
||||||
|
++n;
|
||||||
|
}
|
||||||
|
|
||||||
|
println("{}", n);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
std::cin.exceptions(std::cin.failbit);
|
||||||
|
#ifdef LOCAL
|
||||||
|
std::cerr.rdbuf(std::cout.rdbuf());
|
||||||
|
std::cout.setf(std::ios::unitbuf);
|
||||||
|
std::cerr.setf(std::ios::unitbuf);
|
||||||
|
#else
|
||||||
|
std::cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
#endif
|
||||||
|
u32 tc = 1;
|
||||||
|
// std::cin >> tc;
|
||||||
|
for (u32 t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
17
codeforces/575/.clang-format
Normal file
17
codeforces/575/.clang-format
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortLambdasOnASingleLine: None
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortCaseExpressionOnASingleLine: false
|
||||||
|
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
ColumnLimit: 100
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
71
codeforces/575/a.cc
Normal file
71
codeforces/575/a.cc
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma GCC optimize("O2,unroll-loops")
|
||||||
|
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
using i16 = int16_t;
|
||||||
|
using u16 = uint16_t;
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
vector<u64> a(3);
|
||||||
|
for (auto& e : a) cin >> e;
|
||||||
|
|
||||||
|
sort(begin(a), end(a));
|
||||||
|
|
||||||
|
u64 diff = min(a[2], a[1] - a[0]);
|
||||||
|
a[0] += diff;
|
||||||
|
a[2] -= diff;
|
||||||
|
a[0] += a[2] / 2;
|
||||||
|
|
||||||
|
println("{}", a[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
std::cin.exceptions(std::cin.failbit);
|
||||||
|
#ifdef LOCAL
|
||||||
|
std::cerr.rdbuf(std::cout.rdbuf());
|
||||||
|
std::cout.setf(std::ios::unitbuf);
|
||||||
|
std::cerr.setf(std::ios::unitbuf);
|
||||||
|
#else
|
||||||
|
std::cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
#endif
|
||||||
|
u32 tc = 1;
|
||||||
|
std::cin >> tc;
|
||||||
|
for (u32 t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
17
codeforces/943/.clang-format
Normal file
17
codeforces/943/.clang-format
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortLambdasOnASingleLine: None
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortCaseExpressionOnASingleLine: false
|
||||||
|
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
ColumnLimit: 100
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
68
codeforces/943/a.cc
Normal file
68
codeforces/943/a.cc
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma GCC optimize("O2,unroll-loops")
|
||||||
|
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
using i16 = int16_t;
|
||||||
|
using u16 = uint16_t;
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u32 x;
|
||||||
|
cin >> x;
|
||||||
|
array ans{0, 0};
|
||||||
|
for (u32 y = 1; y < x; ++y) {
|
||||||
|
ans = max(ans, {gcd(x, y) + y, y});
|
||||||
|
}
|
||||||
|
|
||||||
|
println("{}", ans[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
std::cin.exceptions(std::cin.failbit);
|
||||||
|
#ifdef LOCAL
|
||||||
|
std::cerr.rdbuf(std::cout.rdbuf());
|
||||||
|
std::cout.setf(std::ios::unitbuf);
|
||||||
|
std::cerr.setf(std::ios::unitbuf);
|
||||||
|
#else
|
||||||
|
std::cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
#endif
|
||||||
|
u32 tc = 1;
|
||||||
|
std::cin >> tc;
|
||||||
|
for (u32 t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
17
codeforces/950/.clang-format
Normal file
17
codeforces/950/.clang-format
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortLambdasOnASingleLine: None
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortCaseExpressionOnASingleLine: false
|
||||||
|
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
ColumnLimit: 100
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
77
codeforces/950/a.cc
Normal file
77
codeforces/950/a.cc
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma GCC optimize("O2,unroll-loops")
|
||||||
|
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
using i16 = int16_t;
|
||||||
|
using u16 = uint16_t;
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
vector<u32> f('G' - 'A' + 1);
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u32 n, m;
|
||||||
|
cin >> n >> m;
|
||||||
|
f.assign(f.size(), 0);
|
||||||
|
char c;
|
||||||
|
for (u32 i = 0; i < n; ++i) {
|
||||||
|
cin >> c;
|
||||||
|
++f[c - 'A'];
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 ans = 0;
|
||||||
|
for (auto freq : f) {
|
||||||
|
ans += m - min(m, freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
println("{}", ans);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
std::cin.exceptions(std::cin.failbit);
|
||||||
|
#ifdef LOCAL
|
||||||
|
std::cerr.rdbuf(std::cout.rdbuf());
|
||||||
|
std::cout.setf(std::ios::unitbuf);
|
||||||
|
std::cerr.setf(std::ios::unitbuf);
|
||||||
|
#else
|
||||||
|
std::cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
#endif
|
||||||
|
u32 tc = 1;
|
||||||
|
std::cin >> tc;
|
||||||
|
for (u32 t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
17
codeforces/954/.clang-format
Normal file
17
codeforces/954/.clang-format
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortLambdasOnASingleLine: None
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortCaseExpressionOnASingleLine: false
|
||||||
|
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
ColumnLimit: 100
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
72
codeforces/954/a.cc
Normal file
72
codeforces/954/a.cc
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma GCC optimize("O2,unroll-loops")
|
||||||
|
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
using i16 = int16_t;
|
||||||
|
using u16 = uint16_t;
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
vector<i32> a(3);
|
||||||
|
for (auto& e : a) cin >> e;
|
||||||
|
sort(begin(a), end(a));
|
||||||
|
|
||||||
|
u32 ans = 1e9;
|
||||||
|
for (i32 c = 1; c <= 10; ++c) {
|
||||||
|
u32 diff = 0;
|
||||||
|
for (auto e : a) diff += abs(c - e);
|
||||||
|
ans = min(ans, diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
println("{}", ans);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
std::cin.exceptions(std::cin.failbit);
|
||||||
|
#ifdef LOCAL
|
||||||
|
std::cerr.rdbuf(std::cout.rdbuf());
|
||||||
|
std::cout.setf(std::ios::unitbuf);
|
||||||
|
std::cerr.setf(std::ios::unitbuf);
|
||||||
|
#else
|
||||||
|
std::cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
#endif
|
||||||
|
u32 tc = 1;
|
||||||
|
std::cin >> tc;
|
||||||
|
for (u32 t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue