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

boost勉強会 in IPL

今日から開始です。若干緊張していますw https://sites.google.com/site/boostmianqianghuiinipl/

project euler 26~30

26. 少数の循環小数で最長の長さを持つ値を出す あまりと商が同じときにreturn で返すようにしました また桁数に応じて10^x 倍しています int kai(int a,int b){ int now = 1,amari = 0,cnt=0; if(b == 1) now *=10; if(b == 2) now *=100; if(b == 3) now *…

project euler 21~25

21. d(n)をnの真の約数の和と定義する。(真の約数とはn以外の約数のことである。) もし、d(a) = b かつ d(b) = a (a ≠ b)を満たすとき、aとbは友愛数(親和数)であるという。 それでは10000未満の友愛数の合計を求めよ。 #define smax 10000 int a[smax…

topcoder SRM400 div2

250: class Chessboard { public: string changeNotation( string cell ) { string table = "abcdefgh"; bool flag = false; rep(i,cell.size()){ if(isdigit(cell[i])) continue; else flag = true; } string res; if(!flag){ //only digit int s = atoi(ce…

php勉強会(研究室内) 初めてのPHP

今回緊急で研究室のweb勉強会に参加しました。(一人抜けたため) で、自分が出来るスクリプト言語はphpなのでphpをやることに決まりました。 スライド http://sdrv.ms/LfBff0完成品 http://iplab.u-aizu.ac.jp/about/twitter_info.php勉強会templateはこちら …

4年授業webプログラミングのphp問題

project euler 16~20

16. 2^1000の値をすべて足すといくつになるか ex. 2^4 = 16 -> 1+6 = 7 boostに頼りました。bigIntegerと文字列処理 #include<boost/multiprecision/cpp_int.hpp> #include<boost/lexical_cast.hpp> using namespace boost::multiprecision; using namespace boost; int main(void){ mp_uint1024_t a = 2; rep(i,999) a </boost/lexical_cast.hpp></boost/multiprecision/cpp_int.hpp>…

project euler 6~10

6.1から100の和を2乗したものと1から100までの値各々を2乗した値をすべて足した値との差を出す int main(void){ int a=0,b=0; for(int i=1;i<101;i++){ a += i*i; b += i; } cout << b*b-a<<endl; return 0; } 7.素数の10001番目を出す。エラトステネスの篩を使いました #define smax 400000 int a[smax]; vector<int> num; void furui(){ fill(a,a+smax,1); a[0] = a[1] = 0; REP(i,2,</endl;>…

project euler 1~5

1. 3の倍数と5の倍数をたす(1000未満) int main(void){ int sum(0); REP(i,1,1000) if(i % 3 == 0 || i % 5 == 0) sum+=i; cout << sum << endl; return 0; } 2. フィボナッチ数列で偶数の値のものをたす(4000000以下まで) #define smax 10000000 int dp[sma…

topcoder SRM144 div2

最近始めたので過去問を解いて行きます。200: 秒が与えられるのでそれを時間:分:秒に変換する。sstreamを使った。 class Time { public: string whatTime( int seconds ) { stringstream ss; ss << seconds/3600<<":"<<seconds/60%60<<":"<<seconds%60; string str; ss >> str; return str; } };</seconds/60%60<<":"<<seconds%60;>

project euler 11~15

11. 縦横斜め4つの数字の積の最大を出力する 実質、下、右、斜め下右、左だけでいいです。 #define smax 20 int table[smax][smax]; int main(void){ rep(i,smax) rep(j,smax) cin >> table[i][j]; int res=-1; rep(i,smax){ int a[4]={}; rep(j,smax){ if(j…

AOJ_bot(通称あおいちゃん☆)について

2012/6/7更新前回からの変更点 1.掲示板に新着があったらつぶやくようにしました。 2012/5/31更新前回からの変更点 1.ゾンビ化からの脱出しました。 2.cputime(実行時間)とsize(ソースコードのサイズ)で各問に対して上位10位に入っていた場合つぶやくように…

UVA 929

UVA

問題 http://uva.onlinejudge.org/external/9/929.html久しぶりに師匠と一緒に解いた問題(ICPC練習回) #include<iostream> #include<vector> #include<map> #include<algorithm> #include<string> #include<queue> #include<deque> #include<climits> #include<numeric> #include<functional> #define ALL(g) (g).begin(),(g).end() #define REP(…</functional></numeric></climits></deque></queue></string></algorithm></map></vector></iostream>

WUPC2012

1番 http://wupc2012.contest.atcoder.jp/tasks/wupc2012_1