Happy Coding

This blog is for my memorandum about programming and English.

Happy Coding

This blog is for my memorandum

Entries from 2016-12-01 to 1 month

div2 srm 704 hard ModEquationEasy

Problem Statement You are given the s n, K, and v. Consider the following modular equation with n variables: (x[0] * x[1] * x[2] * ... * x[n-1]) mod K = v. How many solutions does it have? Formally, we want to find the number of sequences …

srm704 middium ConnectedComponentConstruction

Problem Statement Any undirected graph can be decomposed into connected components. Two vertices u and v belong to the same connected component if we can travel from u to v by following a sequence of zero or more consecutive edges. The siz…

segment Treeを使用してRMQをとく。

RMQとは 数列a_0,a_1,...a_nがあるとき次の二つの処理をO(log n)で行う。 s, tが与えられたとき、a_s, a_s+1, .... , a_tの最小値を求める i, xが与えられたとき、a_iの値をxに変更する SegmentTreeとは プログラミングコンテストでのデータ構造 from Takuya…

いもす法を二回する AtCoder Regular Contest 045 B - ドキドキデート大作戦高橋君

問題 arc045.contest.atcoder.jp note まず累積和を使って、担当が1人しかいない掃除場所を探し出す。 その後、担当が1人しかいない場所を1、それよりも多い掃除場所を0として累積和をとればO(1)で任意の掃除の区間をサボれるかわかる code

ハッシュテーブルをbitで管理 AtCoder Regular Contest 053 B - 回文分割

問題 arc053.contest.atcoder.jp note 回文になる文字列は出現回数が奇数の文字が1回以下の場合。 したがってアルファベット26文字が偶数か奇数かを管理すればよい。

Double Sweep AtCoder Beginner Contest 019 D - 高橋くんと木の直径

問題 abc019.contest.atcoder.jp note 木の直径を求める際には、まず適当なノードを選んで、そこから最も遠いノードを求める。 次にそのノードから最も遠いノードを求めると、その2頂点の長さが木の直径になる。

Union Find Tree SRM 703 Middium GCDGraph

Problem Statement You are given four s: n, k, x, and y. The s n and k describe a simple undirected graph. The graph has n nodes, numbered 1 through n. Two distinct vertices i and j are connected by an edge if and only if gcd(i, j) > k. Her…