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

AOJ_2332

AOJ

最短距離を、ループを回しどんどん更新して求めていく。 更新されなくなったら、最短距離が確定する。 #include <cstdio> #include <algorithm> using namespace std; const int INF = 1 << 21; const int MAX_N = 100000; //d[i] := i番目のマスからゴールにつくまで最小の、サ</algorithm></cstdio>…

AOJ_2330

3をかけていくだけの簡単なお仕事です。 #include <cstdio> using namespace std; const int MAX_N = 20; long long table[MAX_N + 1]; int main(){ int n; table[1] = 3; for(int i = 2; i <= MAX_N; i++) table[i] = table[i-1]*3; scanf("%d", &n); for(int i = 1</cstdio>…