結果
| 問題 |
No.3259 C++ → Rust → Python
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-06 13:21:32 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 13,414 bytes |
| コンパイル時間 | 3,731 ms |
| コンパイル使用メモリ | 281,968 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-06 13:21:53 |
| 合計ジャッジ時間 | 4,439 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
// https://atcoder.jp/contests/adt_easy_20240807_1/tasks/abc237_a
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
// ====================
// デバッグユーティリティ
// ====================
#ifdef DEBUG
#define COLOR_RESET "\033[0m"
#define COLOR_YELLOW "\033[33m"
#define COLOR_CYAN "\033[36m"
#define COLOR_MAGENTA "\033[35m"
#define COLOR_BLACK "\033[30m"
#define COLOR_RED "\033[31m"
#define COLOR_GREEN "\033[32m"
#define COLOR_BLUE "\033[34m"
#define COLOR_WHITE "\033[37m"
// ====================
// 型情報出力
// ====================
// 型情報出力(AtCoder用)
template<typename T>
string format_int_with_exp(T x);
string format_float_with_exp(long double x);
template<typename T>
void debug_typeinfo(const string& name) {
cout << COLOR_CYAN << "Type info for " << name << " ----------" << COLOR_RESET << "\n";
cout << COLOR_YELLOW << " sizeof : " << COLOR_WHITE << sizeof(T) << " bytes\n";
if constexpr (std::numeric_limits<T>::is_specialized) {
if constexpr (std::is_integral_v<T>) {
cout << COLOR_YELLOW << " min : "
<< COLOR_GREEN << format_int_with_exp(numeric_limits<T>::min())
<< COLOR_RESET << "\n";
cout << COLOR_YELLOW << " max : "
<< COLOR_GREEN << format_int_with_exp(numeric_limits<T>::max())
<< COLOR_RESET << "\n";
} else if constexpr (std::is_floating_point_v<T>) {
cout << COLOR_YELLOW << " min : "
<< COLOR_GREEN << format_float_with_exp(numeric_limits<T>::min())
<< COLOR_RESET << "\n";
cout << COLOR_YELLOW << " max : "
<< COLOR_GREEN << format_float_with_exp(numeric_limits<T>::max())
<< COLOR_RESET << "\n";
}
} else {
cout << " min : (not available)\n";
cout << " max : (not available)\n";
}
cout << "----------------------------------\n";
}
// よく使う型リスト
void debug_type_list() {
debug_typeinfo<int>("int");
debug_typeinfo<long long>("long long");
debug_typeinfo<unsigned long long>("unsigned long long");
debug_typeinfo<__int128>("__int128");
debug_typeinfo<unsigned __int128>("unsigned __int128");
debug_typeinfo<float>("float");
debug_typeinfo<double>("double");
debug_typeinfo<long double>("long double");
debug_typeinfo<char>("char");
debug_typeinfo<bool>("bool");
debug_typeinfo<string>("string");
}
string trim(const string& s) {
size_t first = s.find_first_not_of(" \t");
size_t last = s.find_last_not_of(" \t");
if (first == string::npos) return "";
return s.substr(first, (last - first + 1));
}
// pair
template<typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
return os << "(" << p.first << ", " << p.second << ")";
}
// tuple
template<typename Tuple, size_t... Is>
void tuple_out_impl(ostream& os, const Tuple& t, index_sequence<Is...>) {
((os << (Is == 0 ? "" : ", ") << get<Is>(t)), ...);
}
template<typename... Args>
ostream& operator<<(ostream& os, const tuple<Args...>& t) {
os << "(";
tuple_out_impl(os, t, index_sequence_for<Args...>{});
os << ")";
return os;
}
// vector
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
os << "[ ";
for (size_t i = 0; i < v.size(); i++) {
os << v[i];
if (i + 1 < v.size()) os << ", ";
}
os << " ]";
return os;
}
// set
template<typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
os << "{ ";
size_t i = 0;
for (auto& x : s) {
os << x;
if (++i < s.size()) os << ", ";
}
os << " }";
return os;
}
template<typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& s) {
os << "{ ";
size_t i = 0;
for (auto& x : s) {
os << x;
if (++i < s.size()) os << ", ";
}
os << " }";
return os;
}
// map
template<typename K, typename V>
ostream& operator<<(ostream& os, const map<K,V>& m) {
os << "{ ";
size_t i = 0;
for (auto& [k,v] : m) {
os << k << ": " << v;
if (++i < m.size()) os << ", ";
}
os << " }";
return os;
}
template<typename K, typename V>
ostream& operator<<(ostream& os, const unordered_map<K,V>& m) {
os << "{ ";
size_t i = 0;
for (auto& [k,v] : m) {
os << k << ": " << v;
if (++i < m.size()) os << ", ";
}
os << " }";
return os;
}
// 通常変数
template<typename T>
void debug_dispatch(const char* name, const T& x) {
cerr << COLOR_YELLOW << name << COLOR_WHITE << " : "
<< x << COLOR_RESET << "\n";
}
// 複数変数
template<typename T>
void debug_single(const char* name, const T& x) {
debug_dispatch(name, x);
}
template<typename... Args>
void debug_multi(const char* names, Args&&... args) {
stringstream ss(names); string name;
((getline(ss, name, ','), debug_single(trim(name).c_str(), args)), ...);
}
// メインマクロ
#define debug(...) \
do { \
cerr << COLOR_CYAN << "debug ----------<< start" << COLOR_RESET << "\n"; \
debug_multi(#__VA_ARGS__, __VA_ARGS__); \
} while (0)
// queue
#define debug_queue(q) \
do { \
auto temp = q; int idx = 0; \
cerr << COLOR_MAGENTA << #q << " ----------" << COLOR_RESET << "\n"; \
while (!temp.empty()) { \
cerr << COLOR_CYAN << idx++ << COLOR_WHITE << " : " \
<< temp.front() << COLOR_RESET << "\n"; \
temp.pop(); \
} \
} while (0)
// stack
#define debug_stack(s) \
do { \
auto temp = s; int idx = 0; \
cerr << COLOR_MAGENTA << #s << " ----------" << COLOR_RESET << "\n"; \
while (!temp.empty()) { \
cerr << COLOR_CYAN << idx++ << COLOR_WHITE << " : " \
<< temp.top() << COLOR_RESET << "\n"; \
temp.pop(); \
} \
} while (0)
// priority_queue
#define debug_pq(pq) \
do { \
auto temp = pq; int idx = 0; \
cerr << COLOR_MAGENTA << #pq << " ----------" << COLOR_RESET << "\n"; \
while (!temp.empty()) { \
cerr << COLOR_CYAN << idx++ << COLOR_WHITE << " : " \
<< temp.top() << COLOR_RESET << "\n"; \
temp.pop(); \
} \
} while (0)
#else
#define debug(...)
#define debug_queue(q)
#define debug_stack(s)
#define debug_pq(pq)
#endif
// 整数をカンマ区切りに
string format_with_commas(unsigned __int128 x) {
if (x == 0) return "0";
string s;
while (x > 0) {
s.push_back('0' + (x % 10));
x /= 10;
}
reverse(s.begin(), s.end());
string out;
int n = s.size(), cnt = 0;
for (int i = n-1; i >= 0; --i) {
out.push_back(s[i]);
if (++cnt % 3 == 0 && i != 0) out.push_back(',');
}
reverse(out.begin(), out.end());
return out;
}
// 整数型 min/max をカンマ区切り+10^n 表記 プロトタイプ宣言★
template<typename T>
string format_int_with_exp(T x) {
using U = unsigned __int128;
// --- bool 特別処理 ---
if constexpr (std::is_same_v<T, bool>) {
return string(x ? "1 (true)" : "0 (false)");
}
// --- 符号あり整数 ---
else if constexpr (std::is_signed_v<T>) {
// __int128 の最小値対策
if (x == std::numeric_limits<T>::min()) {
// 最小値は直接文字列化
string base = "-" + format_with_commas((U)( (unsigned __int128)std::numeric_limits<T>::max() ) + 1);
int exp = base.size() - 2; // "-"があるので-1補正
// 先頭3桁だけ科学的表記
string digits = base.substr(1, 3); // "-"抜き
ostringstream oss;
oss << base << " (≈ " << digits[0] << "." << digits.substr(1) << " × 10^" << exp << ")";
return oss.str();
}
bool neg = (x < 0);
U val = neg ? U(-( __int128)x) : U(x);
string base = format_with_commas(val);
int exp = base.size() - 1;
// 先頭3桁を抽出して科学的表記
string digits = base.substr(0, min(3, (int)base.size()));
ostringstream oss;
oss << base << " (≈ " << digits[0] << "." << digits.substr(1) << " × 10^" << exp << ")";
return (neg ? "-" : "") + oss.str();
}
// --- 符号なし整数 ---
else {
U val = U(x);
string base = format_with_commas(val);
int exp = base.size() - 1;
string digits = base.substr(0, min(3, (int)base.size()));
ostringstream oss;
oss << base << " (≈ " << digits[0] << "." << digits.substr(1) << " × 10^" << exp << ")";
return oss.str();
}
}
// 浮動小数型 → 科学的記法 プロトタイプ宣言★
string format_float_with_exp(long double x) {
if (x == 0.0L) return "0";
int exp = floor(log10(fabsl(x)));
long double base = x / powl(10.0L, exp);
ostringstream oss;
oss << fixed << setprecision(5) << base;
return oss.str() + " × 10^" + to_string(exp);
}
// // 型情報出力
// #include <boost/type_index.hpp>
// template<typename T>
// void debug_typeinfo(const string& name) {
// using boost::typeindex::type_id_with_cvr;
// cout << COLOR_CYAN << "Type info for " << name << " ----------" << COLOR_RESET << "\n";
// // cout << " type : " << type_id_with_cvr<T>().pretty_name() << "\n";
// // cout << " sizeof : " << sizeof(T) << " bytes\n";
// cout << COLOR_YELLOW << " type : " << COLOR_WHITE << type_id_with_cvr<T>().pretty_name() << "\n";
// cout << COLOR_YELLOW << " sizeof : " << COLOR_WHITE << sizeof(T) << " bytes\n";
// if constexpr (std::numeric_limits<T>::is_specialized) {
// if constexpr (std::is_integral_v<T>) {
// cout << COLOR_YELLOW << " min : " << COLOR_GREEN << format_int_with_exp(numeric_limits<T>::min()) << COLOR_RESET << "\n";
// cout << COLOR_YELLOW << " max : " << COLOR_GREEN << format_int_with_exp(numeric_limits<T>::max()) << COLOR_RESET << "\n";
// // cout << " min : " << format_int_with_exp(numeric_limits<T>::min()) << "\n";
// // cout << " max : " << format_int_with_exp(numeric_limits<T>::max()) << "\n";
// } else if constexpr (std::is_floating_point_v<T>) {
// cout << COLOR_YELLOW << " min : " << COLOR_GREEN << format_float_with_exp(numeric_limits<T>::min()) << COLOR_RESET << "\n";
// cout << COLOR_YELLOW << " max : " << COLOR_GREEN << format_float_with_exp(numeric_limits<T>::max()) << COLOR_RESET << "\n";
// // cout << " min : " << format_float_with_exp(numeric_limits<T>::min()) << "\n";
// // cout << " max : " << format_float_with_exp(numeric_limits<T>::max()) << "\n";
// }
// } else {
// cout << " min : (not available)\n";
// cout << " max : (not available)\n";
// }
// cout << "----------------------------------\n";
// }
using ll = long long;
[[maybe_unused]] const int INF = 1e9; // 非常に大きい値(= 到達不能な値)
[[maybe_unused]] const long long LINF = 1e18; // long long 用の無限
[[maybe_unused]] const int NINF = -INF; // 非常に小さい値(最小化の比較など)
// #include <limits>
// const int INF = std::numeric_limits<int>::max()/2; // +∞ 代用
// const int NEG = std::numeric_limits<int>::min()/2; // −∞ 代用
// const ll LINF = std::numeric_limits<long long>::max()/4; // 64bit 版
// /2 /4 しておくと 加算してもオーバーフローしない
// https://atcoder.jp/contests/tessoku-book/tasks/tessoku_book_ai
// ====================
// main 部分
// ====================
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int L, R;
cin >> L >> R;
int ansL = 0, ansR = 0;
if(L < 296)ansL = 1;
else if(L < 417)ansL = 2;
else ansL = 3;
debug(ansL);
if(417 <= R)ansR = 3;
else if(296 <= R)ansR = 2;
else ansR = 1;
debug(ansR);
int ans = ansR - ansL;
cout << ans << endl;
// --- 型情報の確認 ---
// debug_type_list();
// debug_typeinfo<int>("int");
return 0;
}
// // --- 基本型のデバッグ ---
// debug(x, y, d, s); // int, long long, double, string
// // --- コンテナのデバッグ ---
// debug(v, st, mp); // vector, set, map
// debug_queue(q);
// debug_stack(stc);
// debug_pq(pq);
// // --- 型情報の確認 ---
// debug_typeinfo<int>("int");
// debug_typeinfo<double>("double");
// debug_type_list();
/* ----------------------------------------------
x が増えれば y も増えるとき,その関数は単調増加と言う
広義単調増加 x1 < x2 ならば f(x1) <= f(x2)
狭義単調増加 x1 < x2 ならば f(x1) < f(x2)
*/
/* 区間表記 ---------------------------------------
[l, r] l 以上 r 以下(両端を含む) l <= x && x <= r
[l, r) l 以上 r 未満(左端含む、右端含まない) l <= x && x < r
(l, r] l より大きい r 以下(左端含まない、右端含む) l < x && x <= r
(l, r) l より大きい r 未満(両端を含まない) l < x && x < r
*/
//dbg-
//ord-
// ./a << in1.txt