ログイン
編集不可のページディスカッション情報添付ファイル
iz/競技プログラミング/Project Euler 024 Lexicographic permutations

MMA

http://projecteuler.net/problem=24

"0123456789"の順列の1000,000番目を求める。

next_permutationまわすだけ。

   1 #include <iostream>
   2 #include <algorithm>
   3 
   4 using namespace std;
   5 
   6 int main() {
   7     string s = "0123456789";
   8     int counter = 0;
   9     do {
  10         counter++;
  11         if (counter == 1000000) break;
  12     } while (next_permutation(s.begin(), s.end()));
  13     cout << s << endl;
  14     return 0;
  15 }

iz/競技プログラミング/Project Euler 024 Lexicographic permutations (最終更新日時 2012-12-22 01:43:49 更新者 iz)