ベスパリブ

プログラミングを主とした日記・備忘録です。ベスパ持ってないです。

2019-09-01から1ヶ月間の記事一覧

ABC 142: D問題の解説 (Python3)

問題:AtCoder Beginner Contest 142: D - Disjoint Set of Common Divisors 公式解説PDF:https://img.atcoder.jp/abc142/editorial.pdf 公式解説動画:AtCoder Beginner Contest 142 - YouTube 解説 要約すると、(gcd(A, B)を素因数分解したときの素因数…

「優れた発想はなぜゴミ箱に捨てられるのか?」読書メモ

優れた発想はなぜゴミ箱に捨てられるのか? - Amazon キーワード E4V (Eyes for Value) Step1: 価値を創る Step2: 価値を伝える Step3: 実現への道のりを創る TOC Theory Of Constraints: 制約理論 ✕:現場のカイゼンを一つ一つ積み上げることが、企業全体の…

AttributeError: module 'pip' has no attribute 'get_installed_distributions' のエラー対応

Google Colabでインストールされているパッケージを確認しようとしました。以下はPythonのコードです。 installed_packages = pip.get_installed_distributions() すると以下のようなエラーが発生しました。 AttributeError: module 'pip' has no attribute …

競技プログラミング解説記事まとめ

最後に編集した日:2023/01/18 ABC C問題 AtCoder Beginner Contest 030: C - 飛行機乗り AtCoder Beginner Contest 031: C - 数列ゲーム AtCoder Beginner Contest 032: C - 列 AtCoder Beginner Contest 140: C - Maximal Value ABC D問題 AtCoder Beginne…

ABC 115: D問題の解説 (Python3)

問題:AtCoder Beginner Contest 115: D - Christmas 公式解説PDF:https://img.atcoder.jp/abc115/editorial.pdf 公式解説動画:なし 有志解説動画:【競技プログラミング】AtCoder Beginner Contest 115 D問題をJuliaで解く - YouTube 解説 考察問題であり…

「テスト駆動Python」写経 CHAPTER1

www.amazon.co.jp 1 はじめてのpytest pytestを使ったテスト駆動開発についての本です。 pytestを実行する test_one.py def test_passing(): assert (1, 2, 3) == (1, 2, 3) テストを実行します。 $ pytest test_one.py ===================================…

よく使うcondaコマンド

Conda Cheat Sheet Conda Cheat Sheet condaコマンド 仮想環境の作成 # conda create -n [仮想環境名] > conda create -n py3x # pythonのバージョンを指定したい場合は conda create -n [仮想環境名] python=3.6 など > conda create -n py36 python=3.6 仮…

ABC 030: C問題の解説 (Python3)

問題:AtCoder Beginner Contest 030: C - 飛行機乗り 公式解説PDF:https://www.slideshare.net/chokudai/abc030 公式解説動画:なし 解説 二分探索問題です。 以下の解説は公式PDFの解説まんまです。 入力例1を考えます。 初期状態は以下のように、高橋く…

Python3.7のeval()関数は長すぎる文字列を処理させようとするとエラーを吐かずに落ちることがある

TL;DR Python3.7系だと、エラーを吐かずに終了することがあります。 現象 a = "1*"*100000 ans = eval(a[:-1]) print(ans) print("end.") 自宅のPC(Windows10, 64bit, Python3.6.5)でこれを実行してみると、 >python hoge.py Traceback (most recent call la…

ABC 133: D問題の解説 (Python3)

問題:AtCoder Beginner Contest 133: D - Rain Flows into Dams 公式解説PDF:https://img.atcoder.jp/abc133/editorial.pdf 公式解説動画:https://youtu.be/8uowVvQ_-Mo?t=3228 解説 考察問題です。数式を変換してXに対する漸化式を導きます。 以下の解説…

ABC 131: D問題の解説 (Python3)

問題:AtCoder Beginner Contest 131: D - Megalomania 公式解説PDF:https://img.atcoder.jp/abc131/editorial.pdf 公式解説動画:https://youtu.be/XI8exXVxZ-Q?t=4046 解説 締切が早い仕事から順に終わらせていく貪欲法です。割と直感で思いつく解法です…

ABC 136: D問題の解説 (Python3)

問題:AtCoder Beginner Contest 136: D - Gathering Children 公式解説PDF:https://img.atcoder.jp/abc136/editorial.pdf 公式解説動画:https://youtu.be/lyHk98daDJo?t=3172 解説 発想としてはランレングス法です。 S=RRRL という例を考えます。 i=0の人…

ABC 031: C問題の解説 (Python3)

問題:AtCoder Beginner Contest 031: C - 数列ゲーム 公式解説PDF:https://www.slideshare.net/chokudai/abc031 公式解説動画:なし 解説1:力技 Nは高々50なので、 くらいまでいけそうだとあたりをつけます。 全探索で、問題をシミュレートして高橋のとり…

ABC 140: D問題の解説 (Python3)

問題:AtCoder Beginner Contest 140: D - Face Produces Unhappiness 公式解説PDF:https://img.atcoder.jp/abc140/editorial.pdf 公式解説動画:https://youtu.be/VSeggcnxwrc?t=3564 ABC140のD問題のPython3による解説です。 初見では全くわからず、解説…

pywintypes.com_error: (-2147352561, 'パラメーターはオプションではありません。', None, None) エラーの意味

File "test/test_main.py", line 225, in hoge wp = wps.AddByPoint() File "C:\Users\XXXX\AppData\Local\Temp\gen_py\3.7\D98A091D-3A0F-4C3E-B36E-61F62068D488x0x1x0.py", line 125299, in AddByPoint , Construction) pywintypes.com_error: (-21473525…

ABC 129: D問題の解説 (Python3)

問題:AtCoder Beginner Contest 129: D - Lamp 公式解説PDF:https://img.atcoder.jp/abc129/editorial.pdf 公式解説動画:https://youtu.be/L8grWxBlIZ4?t=4363 ABC129のD問題のPython3による解説です。 解説 DP問題です。 これは公式の解説動画がとてもわ…

ABC 130: D問題の解説 (Python3)

問題:AtCoder Beginner Contest 130: D - Enough Array 公式解説PDF:https://img.atcoder.jp/abc130/editorial.pdf 公式解説動画:https://youtu.be/ERZuLAxZffQ?t=2473 解説 ABC130のD問題の解説です。しゃくとり法の問題です。 8 10 6 1 2 7 10 1 2 1 と…

ABC140: C問題の解説 (Python3)

問題:AtCoder Beginner Contest 140: C - Maximal Value 公式解説PDF:https://img.atcoder.jp/abc140/editorial.pdf 公式解説動画:https://youtu.be/VSeggcnxwrc?t=2461 解説 ABC140のC問題の解説です。貪欲法(?)問題です。 数列 を リストAsに、数列 …

重複組み合わせの考え方

mathtrain.jp 例題1 青,赤,黒の三種類の玉がたくさんある。この中から4つ玉を選ぶときに得られる色のパターンが何通りあるか求めよ。 重複組合せを考えるときは、仕切りを引く方法に置き換えるとわかりやすい。 ○ ○ ○ ○ | | ○ ○ ○ | ○ | ○ ○ ○ | | ○ ... |…

ABC032: C問題の解説 (Python3)

問題:AtCoder Beginner Contest 032: C - 列 公式解説:https://www.slideshare.net/chokudai/abc032 しゃくとり法の問題です。 公式解説を読むと、「連続する1を圧縮する」という重要なテクニックが書かれていますが、本記事ではそうではない方法で解いて…

Python: 2進数の文字列を、float(64bitの倍精度浮動小数点数)型の数値に変換する

bin_to_double() 関数 2進数の文字列を、float(64bitの倍精度浮動小数点数)型の数値に変換する関数 double_to_bin() 関数 上の逆関数(float型の数値を、2進数の文字列に変換する関数) 詳細は以下のGistのコードを参照してください。 gist.github.com 参考 …

Python: 切り捨てはmath.floor()より//演算子を使ったほうが良いかも

環境はPython3.6.5です。 まずは以下の計算結果を見てください。 gist.github.com なぜ? float型において、有効数字が16桁以上の値を表現しようとすると誤差が生じてしまう可能性があるからです。 N//3 のような整数同士の切り捨て除算は内部処理的にint型…