結果
問題 |
No.3259 C++ → Rust → Python
|
ユーザー |
|
提出日時 | 2025-08-07 09:47:50 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,222 bytes |
コンパイル時間 | 3,460 ms |
コンパイル使用メモリ | 274,680 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-07 09:47:55 |
合計ジャッジ時間 | 4,805 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> #define MAX_R 999 // solve() 関数で使用する csum_count を、コンパイル時に計算する関数 static inline constexpr std::array<uint_fast32_t, MAX_R + 1> prepare() noexcept { std::array<uint_fast32_t, MAX_R + 1> csum_count = { 0, }; // 変更回数の累積和( = 第 0 回目から第 i 回目までの間に何回使用言語を変更したか) csum_count[296] = 1, csum_count[417] = 1; // imos 法の発想で、局所的な言語変更の回数を指定 for (uint_fast32_t i = 0; i != MAX_R; ++i) csum_count[i + 1] += csum_count[i]; // imos 法の復元 return csum_count; } // 答えを計算する関数 static inline constexpr uint_fast32_t solve(const uint_fast32_t L, const uint_fast32_t R) noexcept { constexpr std::array<uint_fast32_t, MAX_R + 1> csum_count = prepare(); // 大昔から各時点までに使用言語を変更した回数 ( = 累積和) return csum_count[R] - csum_count[L]; // 累積和さえあれば、区間和が答え } // プログラムの制御を行う関数 int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t L, R; std::cin >> L >> R; std::cout << solve(L, R) << '\n'; return 0; }