2012-04-01から1ヶ月間の記事一覧

AOJ 0200 - Traveling Alone

aoj

「友達がいないのではない.一人旅が好きなだけだ.」という弱々しい声が聞こえてきそうです. しかし,私は一人旅に憧れる.b -> aの逆順が存在することに気づいた. 蟻本にO(|E| log |V|)の解き方があったが,ごちゃごちゃしてしまったので後で理解する. …

AOJ 0197 - GCD: Euclidean Algorithm

aoj

stepを外へ #include <iostream> typedef long long int llint; llint step = 0; llint getgcd(llint a, llint b){ if(b==0)return a; step++; return getgcd(b, a%b); } int main(){ llint a, b; while(std::cin >> a >> b, a && b){ llint gcd = 0; step = 0; if(a ></iostream>…

AOJ 0196 - Baseball Championship

aoj

実装ゲー #include <iostream> #include <vector> #include <algorithm> struct team{std::string name; int win; int lose;}; bool ascendingteam(const team& lteam, const team& rteam){ if(lteam.win == rteam.win) return lteam.lose < rteam.lose; return lteam.win > rteam.win; } </algorithm></vector></iostream>…

AOJ 0176 - What Color?

aoj

再びVimで書いた. フォントサイズが小さい dkが同じ数値の場合に対応するために逆順に調べました. #include <iostream> #include <cmath> int hextodec(char h){ int res; if(h >= '0' && h <= '9') res = h - '0'; else res = h - 'a' + 10; return res; } int main(){ int</cmath></iostream>…

AOJ 0158 - Collatz's Problem

aoj

Vimで書いてみた. でも,ヤンクしてもクリップボードに反映されなかった. #include <iostream> int main(){ int n; while(std::cin >> n, n){ int t = 0; while(n != 1){ if(n % 2)n = n * 3 + 1; else n /= 2; t++; } std::cout << t << std::endl; } }</iostream>

AOJ 0116 - Rectangular Searching

aoj

この2つの記事を参考に書きました. ALGORITHM NOTE 長方形探索: 最大長方形の面積 Largest Rectangle ALGORITHM NOTE ヒストグラム中の最大の長方形の面積 3ヶ月前は理解できなかったのでうれしいです. ヒストグラムは単調増加の時はきれいに取り出せる…