Last active
May 9, 2019 15:02
-
-
Save aximov/ce6131dc26d8448db94ffffebd9b8d31 to your computer and use it in GitHub Desktop.
a 個の数から b 個の数を重複ありで選び a^b = c 通りの組をつくるときのための処理。辞書順にはならない。出典: https://beta.atcoder.jp/contests/abc100/submissions/2670489
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int a = 2, b = 3, c = 8; //何通りか事前に計算しておく。 e.g. 2^3=8 | |
for (int i = 0; i < c; i++) { | |
for (int j = 0; j < b; j++) { | |
if((i/(1 << j))%a == 0) cout << "0"; | |
else cout << "1"; //if分岐はaの値に応じて増える | |
} | |
cout << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment