へんてこのブログ

日々気づいたことや、最近やっていることを書いています

2012-01-01から1年間の記事一覧

javascriptによる文書書き換え

javascriptによる文書書き換えです。任意のHPで、ブラウザのURL欄に以下の文字を入れエンターを押すと、HPの文字を任意に書き換えられます。javascript:document.body.contentEditable='true';void 0; 面白いですね。参考:http://d.hatena.ne.jp/hatenatech/…

AOJ Volume11-1141

ICPC過去問 Problem A:ディリクレの算術級数定理 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1141&lang=jp解法:全ての値を素数かチェックしていき、n番目の素数を出力する check内のi*iが重要 #include<iostream> #include<vector> using namespace std; bool </vector></iostream>…

Titanium Studioによるアプリ名変更及び言語設定変更[iPad]

忘れないようにメモTitanium mobileでアプリを申請する時、アプリ名とかを別途変更したいときがあります。 その時のやり方が分からなくて1日ハマりましたが分かりました。以下参照 http://keygx.blogspot.jp/2011/04/titanium-mobileiphone2.htmlTitanium mo…

AOJ Volume11-1142

ICPC過去問 Problem B: 列車の編成パートII http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1142&lang=jp解法:前列+後列、後列+前列、逆前列+後列...etc で結果をソートして個数を数え上げるincludeやテンプレは省略 テンプレ:http://henteko07…

AOJ Volume11-1135

ICPC過去問 Problem A: Ohgas' Fortune http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1135&lang=jp解放:各値ずつ、シミュレーションしていきvectorに放り込む、最後にmax_elementで抽出includeやテンプレは省略 テンプレ:http://henteko07.hat…

vectorでの検索 & vectorのイテレータから添字番号取得[自分用メモ]

メモ 参考:http://d.hatena.ne.jp/shikaku/20100519/p3 参考:http://d.hatena.ne.jp/kogecoo/20090731/1248994749 vector<int> v_list; v_list.push_back(100); v_list.push_back(200); v_list.push_back(300); vector<int>::iterator cIter = find( v_list.begin(),v_</int></int>…

競技プログラミング用テンプレ[自分用]

参考:http://d.hatena.ne.jp/peroon/20091123/1258966199 #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include </iostream></sstream></utility></numeric></functional></algorithm></bitset></stack></deque></set></map></list></vector>

ICPC用自分専用まとめ

まとめ 色々増えるかも//コンパイル $ g++ c.cpp -o c//普通の実行 $ ./c//out.txt & input.txtあり $ cat input.txt | ./c > out.txt #include<algorithm> #include<iostream> #include<vector> #include<map> #include<sstream> #include<string> //string型の数字をint型にして返すよ int s_to_int(string s) </string></sstream></map></vector></iostream></algorithm>…

AOJ Volume11-1137

Problem C: Numeral System http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1137&lang=jpICPCの過去問 解法:解析->複合 #include<iostream> #include<cmath> #include<sstream> #include<string> using namespace std; //string型の数字をint型にして返すよ int s_to_int(string s)</string></sstream></cmath></iostream>…

AOJ Volume5-0532

Time Card http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0532解法:h,mをsに直して普通に計算 #include<iostream> #include<cmath> using namespace std; int main() { double h1,h2,m1,m2,s1,s2; while (cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2) { double r1 </cmath></iostream>…

AOJ Volume0-0064

Secret Number http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0064解法:全部読み込んでから解析 cin > sじゃダメだった、getline(sin,s)じゃないとダメ #include<iostream> #include<string> #include <sstream> using namespace std; bool hoge(char s) { for (int i=0; i </sstream></string></iostream>…

AOJ Volume0-0060

Card Game http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0060解法:普通にそのまま #include<iostream> #include<string> #include<map> using namespace std; int main() { int c1,c2,c3; while (cin >> c1 >> c2 >> c3) { int result = 0; for (int i=1; i <= 10; i+</map></string></iostream>…

AOJ Volume0-0088

The Code A Doctor Loved http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0088解法:やるだけ今回、mapのinsert分をいくつも書くのがダルかったので、C++でコピペ出来るように作成。test_input.txtでこんなん用意してから、 101 ' 000000 , 00001…

C++でPHPの配列形式のテキストを生成

ただのテキストデータをPHPの配列形式にしたかったので、C++で作成しました。 実行後、コピペでPHPが動作します。こんなinput.txtとかを用意して、 hogehoge hoge fuga fugafuga henteko henteko07このC++を実行すると、 #include<iostream> #include <fstream> #include<string> using </string></fstream></iostream>…

アプリリリース時の証明書問題[開発]

iPadアプリ(Titanium mobile使用)リリース時の署名につまり、2,3日あーだこーだしてたのが解決したので、書き溜めておきます。まず環境↓ Mac OS X(10.7.2) Xcode Version 4.2.1 Titanium mobile SDK2.0.2今までMacBook(白)でアプリをリリースしてきたのだが…

AOJ Volume20-2006

ICPCの過去問 Keitai Message http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006考え方: 2次元配列に所定のデータを格納しておき、hoge[{押された番号}][{押した回数} % {押された番号の要素数} - 1]でアクセスして、それを結果に格納する。 {…

ssh接続でGUIを起動

macからsshで、借りているさくらのVPSのdebianにアクセスして、gedaを使いたかったのでやってみました。普通だと、CUI環境でしか動かないので、 (gschem:5038): Gtk-WARNING **: cannot open display: とか言って起こられますが、これを回避する為、ssh conf…

実験報告書の為のLaTexテンプレを書いてみた

今期から実験が始まりました。 手書きでもいいのですが、今後の為も考え、Texで書いてみたいなと思い、とりあえずテンプレを作成しました。 環境はMacOSXでTexShopなど使ってます。多分Macでは一般的なTex環境だと思います。以下が報告書のテンプレです。 \d…

SRM537 Div2 250 550

SRM537に参加しました。 250、550ともにサンプルは通せましたが細かなバグが残っておりシステムに落とされました。 かなり悔しいので次のSRM538はHardを力技でも通します。 250解法 && src 母音(a,i,u,e,o)を準備し、それに該当するものをnameから探す。 母…

tablesorter Ver2.1.2の使用方法

Webサイトでhtmlのtableを使用する際にカラムでのソートを行いたかったので、tablesorterを使用させていただきました。 http://mottie.github.com/tablesorter/docs/ tablesorterの最新Verは2.1.2(2012/3/15現在)なのですが、使い方を書いているサイトさんが…

SRM529 Div2 250 && 500

250 int savedPawnCount(vector <int> start) { int result; for(int i=start.size() - 1;i > 0;i--) { start[i-1] += start[i] / 2; } result = start[0]; return result; } 500 vector<string> split(string str, string delim) { vector<string> result; int cutAt; while( (cu</string></string></int>…

ABC2012S LT発表します

今月24日に東京大学本郷キャンパスである、 Android Bazaar and Conference 2012 Spring(ABC2012S)のLT枠にて発表をすることとなりました。題名は、「仮面ライダー変身アプリの簡単(?)な作り方」です。 http://www.android-group.jp/conference/abc2012s/con…

SRMまとめ

はてなダイアリーの方にも書いていますが、よく見るのでBlogの方にも書いておきます。stringからintへ変換 int num = (int) string_hoge - '0'; 上記じゃ出来ない場合あり #include<sstream> #include<string> int main() { string str = "666"; stringstream ss; int n; ss <</string></sstream>…

GCJ C++ まとめ

GCJ用に、C++でよく使う物をまとめようかと思います。ファイル入出力 #include<fstream> してから、 ifstream cin("A-large-practice.in"); ofstream cout("large_data.txt"); int n; cin >> n; cout << n << endl; 普通にcinとかcoutと同じ感じに使える!!すごい!!</fstream>

GCJJ練習 問題A. 数珠繋ぎ

GCJ2012が本日の未明より登録開始ということで、練習でもしようかなとGCJJ2011の練習問題から解いてみました。 GCJJ2011はjavaで参戦しましたが、今回はC++で参戦します。 C++のファイル入出力はjavaよりも簡単ですね。問題文:http://code.google.com/codeja…

SRM536 Div2

レーティングが-102された。 けど気にしないもん……250 (int h = tmp % 2;忘れて50分くらいかかった) int hoge(int n,int count,int d) { if(d == 0) { return 1; } if(d-1 == count) { return n;} return n * hoge(n,count+1,d); } int countRoots(vector <int> a</int>…

SICP(計算機プログラムの構造と解釈)を買ったのでMac10.6.8にGaucheをインストール

SICP(計算機プログラムの構造と解釈)を買ったのでMac10.6.8にGaucheをインストールしました。 amazon(http://www.amazon.co.jp/exec/obidos/ASIN/489471163X/)始めはmakeとかでコンパイルしようかと思いましたが、何やらsqrtが使えない状況になったのでmacpo…

Black and White boardが総インストール1万超えました!!

Android専用アプリとしてマーケットにて公開中の、 Black and White boardの総インストール数が1万超えました!!インストールしてくださった皆様、ありがとうございます。 これからも開発の方を進めていきたいと思っております。https://market.android.com/d…

SRM532 Div2 600

本番で解けなかった600問題を解いた。 #line 5 "DengklekMakingChains.cpp" #include <string> #include <vector> #include <sstream> #include <iostream> #include <algorithm> using namespace std; class DengklekMakingChains { public: int maxBeauty(vector <string> chains) { int full_max = 0,single_max </string></algorithm></iostream></sstream></vector></string>…

SRMの為にメモ

今回、SRM532に挑戦してみた結果、文字列を整数に直したり逆をするのに手こずりました。 ですのでそれをまとめて置きたいと思います。 ちなみに、まだXcode3を使っているので次回までにXcode4にしたいと思います。stringからintへ変換 int num = (int) strin…