結果
| 問題 | No.3557 KCPC or KUPC 2 |
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2026-05-29 20:22:53 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 3,291 bytes |
| 記録 | |
| コンパイル時間 | 3,311 ms |
| コンパイル使用メモリ | 336,616 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-05-29 20:23:02 |
| 合計ジャッジ時間 | 4,549 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge4_1 |
| 純コード判定待ち |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点1 | 10 % | AC * 30 |
| 部分点2 | 40 % | AC * 30 |
| 部分点3 | 50 % | AC * 30 |
| 合計 | 100 点 |
ソースコード
#if __INCLUDE_LEVEL__ == 0
#include __BASE_FILE__
using i128 = __int128_t;
i128 Go(i128 a, i128 b, i128 c, i128 t) {
if (a > 0)
return a * t + Go(0, b, c, t);
if (t % b)
return Go(0, b, c, t / b * b) + t % b * (t / b) * c;
return t / b * (t / b - 1) / 2 * b * c;
}
int64_t Solve(int64_t n, int64_t a, int64_t b, int64_t c) {
int64_t ng = 0;
int64_t ok = DivCeil(n, a);
while (ng + 1 < ok) {
int64_t mid = midpoint(ng, ok);
(Go(a, b, c, mid) >= n ? ok : ng) = mid;
}
return ok;
}
void Solve() {
int64_t n;
IN(n);
int64_t a, b, c;
IN(a, b, c);
int64_t d, e, f;
IN(d, e, f);
int64_t x = Solve(n, a, b, c);
int64_t y = Solve(n, d, e, f);
OUT(x < y ? "KCPC" : x > y ? "KUPC"
: "Same");
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
Solve();
}
#elif __INCLUDE_LEVEL__ == 1
#include <bits/stdc++.h>
template <class T>
concept MyRange =
std::ranges::range<T> &&
!std::convertible_to<T, std::string_view> &&
!std::convertible_to<T, std::filesystem::path>;
template <class T>
concept MyTuple = std::__is_tuple_like<T>::value && !MyRange<T>;
namespace std {
istream& operator>>(istream& is, MyRange auto&& r) {
for (auto&& e : r) {
is >> e;
}
return is;
}
istream& operator>>(istream& is, MyTuple auto&& t) {
apply([&](auto&... xs) { (is >> ... >> xs); }, t);
return is;
}
ostream& operator<<(ostream& os, MyRange auto&& r) {
auto sep = "";
for (auto&& e : r) {
os << exchange(sep, " ") << forward<decltype(e)>(e);
}
return os;
}
ostream& operator<<(ostream& os, MyTuple auto&& t) {
auto sep = "";
apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t);
return os;
}
} // namespace std
template <class T>
class OneBased {
public:
explicit OneBased(T&& x) : ref_(std::forward<T>(x)) {}
template <class... Ts>
requires(sizeof...(Ts) > 1)
OneBased(Ts&&... xs) : ref_(std::forward_as_tuple(std::forward<Ts>(xs)...)) {}
friend std::istream& operator>>(std::istream& is, OneBased x) {
if constexpr (MyRange<T>) {
for (auto&& e : x.ref_) {
is >> ::OneBased(e);
}
} else if constexpr (MyTuple<T>) {
std::apply([&](auto&... xs) { (is >> ... >> ::OneBased(xs)); }, x.ref_);
} else {
is >> x.ref_;
--x.ref_;
}
return is;
}
friend std::ostream& operator<<(std::ostream& os, OneBased x) {
if constexpr (MyRange<T>) {
auto f = [](auto&& e) { return ::OneBased(std::forward<decltype(e)>(e)); };
os << (x.ref_ | std::views::transform(f));
} else if constexpr (MyTuple<T>) {
std::apply([&](auto&... xs) { os << std::tuple(::OneBased(xs)...); }, x.ref_);
} else {
os << ++x.ref_;
--x.ref_;
}
return os;
}
private:
T ref_;
};
template <class T>
OneBased(T&&) -> OneBased<T>;
template <class... Ts>
OneBased(Ts&&...) -> OneBased<std::tuple<Ts...>>;
using namespace std;
#define LAMBDA2(x, y, ...) ([&](auto&& x, auto&& y) -> decltype(auto) { return __VA_ARGS__; })
#define DivCeil(...) LAMBDA2(x, y, x / y + ((x ^ y) >= 0 && x % y))(__VA_ARGS__)
#define IN(...) (cin >> forward_as_tuple(__VA_ARGS__))
#define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n')
#endif // __INCLUDE_LEVEL__ == 1
risujiroh