2013-03-05から1日間の記事一覧

AOJ 2272 - Cicada

aoj

5分かかった.北,西に移動しないので{ある地点までの最小の虫} = min({その西までの最小の虫}, {その北までの最小の虫}) + {その地点にいる虫の数}で求まります. あとは再帰的に計算するだけです. #include<iostream> int memo[50][50]; int main(){ int H, W, map[</iostream>…

AOJ 1135 - Ohgas' Fortune

aoj

10分かかった.単利・複利は苦手です. #include<iostream> int first, year, n, type, every; double rate; int calculate(){ int a = first, b = 0; if(type == 0){ for(int i=0;i<year;i++){ b += a * rate; a -= every; } return a + b; } for(int i=0;i<year;i++){ a += a * rate - every; } return a; } int main(){ int m; std::cin >…</year;i++){></iostream>

AOJ 1153 - Equal Total Score

aoj

7分かかりました. #include<iostream> #include<vector> #include<algorithm> int main(){ int n, m; while(std::cin >> n >> m, n){ int s1 = 0, s2 = 0; std::vector<int> v1, v2; for(int i=0;i<n;i++){ int j; std::cin >> j; v1.push_back(j); s1 += j; } for(int i=0;i<m;i++){ int j; std::cin >> j; v2.push_back(j); s2 +…</m;i++){></n;i++){></int></algorithm></vector></iostream>

AOJ 1147 - ICPC Score Totalizer Software

aoj

4分かかりました. #include<iostream> #include<vector> #include<algorithm> int main(){ int n; while(std::cin >> n, n){ std::vector<int> v; for(int i=0;i<n;i++){ int j; std::cin >> j; v.push_back(j); } std::sort(v.begin(), v.end()); int ave = 0; for(int i=1;i</n;i++){></int></algorithm></vector></iostream>