個人用ブログテーマ設定
公式テーマにあまり心惹かれるものがなかったので、cssを書き換える感じで現在のテーマに改変してみた。
最終更新日時: 2018/11/08
/* <system section="theme" selected="life"> */ @import url("/css/theme/life/life.css"); /* </system> */ @media (min-width: 1020px) #container, #footer { width: 960px; } .entry-content, .entry-footer { max-width: 800px; } .categories a { border: none; background-color: #F5F7FA; font-size: 80% !important; } pre.code { font-size: 80% !important; } h1 a, h2 a, h3 a, h4 a, h5 a { border-bottom: none !important; } .embed-card{ max-width: 100% !important; }
INSTALL HASKELL for OSX Yosemite
環境は OSX Yosemite 10.10.1 です。
※brewのインストールなどは済んでいるものとして進める。
How to install
少し前までは
$ brew install haskell-platform
でインストール可能だったが、現在はできない。
$ brew install haskell-platform Error: No available formula for haskell-platform We no longer package haskell-platform. Consider installing ghc and cabal-install instead: brew install ghc cabal-install A binary installer is available: https://www.haskell.org/platform/mac.html
なので以下の手順でインストール
$ brew install ghc ~~ $ brew install cabal-install ~~ $ cabal update ~~ $ cabal install cabal-install ~~
何をインストールしているのか、どんな構造でHaskellを管理しているのかについては以下の記事が参考になる。
Haskellのパッケージ管理について調べてみた - りんごがでている
How to use
まずはインタラクティブなインターフェイスとコンパイルのコマンドから。
$ ghci GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> 1 + 1 2 Prelude> 2 ^ 3 8 Prelude>:q Leaving GHCi.
このようにしてHaskellに対してインタラクティブなインターフェイスを実行可能。
続いてコンパイル。以下のようなファイルを用意。
helloworld.hs
main = putStrLn "Hello World!"
以下ようにしてコンパイル
$ ghc helloworld.hs [1 of 1] Compiling Main ( helloworld.hs, helloworld.o ) Linking helloworld ...
実行ファイル他、ファイルが吐きだされるので実行
$ ./helloworld Hello World!
とりあえず、こんな感じです。
codeforces Round #176
1/22(木) TPC練習会
A問題
めっちゃ汚い
#include<iostream> #include<string> using namespace std; int main() { string in[4]; for(int i=0;i<4;i++){ cin >> in[i]; } for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ int cnt = 0, cnt2 = 0; if(in[i][j] == '#')cnt++; if(in[i+1][j] == '#')cnt++; if(in[i][j+1] == '#')cnt++; if(in[i+1][j+1] == '#')cnt++; if(in[i][j] == '.')cnt2++; if(in[i+1][j] == '.')cnt2++; if(in[i][j+1] == '.')cnt2++; if(in[i+1][j+1] == '.')cnt2++; if(cnt >= 3 || cnt2 >= 3){ cout << "YES" << endl; return 0; } } } cout << "NO" << endl; return 0; }
B問題
二分探索
#include<iostream> #include<vector> #include<algorithm> typedef long long ll; using namespace std; int main() { ll n, k; cin >> n >> k; ll l=0,r=k-1,mid,ans=-1; while (l<=r) { mid = (l + r)>>1; if ((2*k-mid-1)*mid>=2*n-2)r=(ans=mid)-1; else l=mid+1; } cout << ans << endl; return 0; }
C問題
n=4,5,6とかその辺を手元シミュレートでパターンが得られる。
#include<iostream> #include<vector> #include<algorithm> #include<map> #define mp make_pair using namespace std; int main() { int n; cin >> n; if(n%4>1){ cout << -1 << endl; return 0; } int rem = n%4; for(int i=0; i<n/4; i++){ cout << n-2*i-1 << ' ' << 1+2*i << ' '; } if(rem == 1){ cout << n/2+1 << ' '; } for(int i=n/4-1; i>= 0; i--){ cout << n-2*i << ' ' << 2+2*i << ' '; } cout << endl; return 0; }
DEはいつか挑戦する。