Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int ans = -1000000000; // グローバル変数として、答えを入れる変数を用意する
- int a[10]; // こちらは、実際の営業フラグを入れる
- // 最終的な答えを出す関数
- void func(void) {
- if( a ○○○○○○) return;
- int score = ;// aだった時のスコア
- ans = max(ans,score);
- }
- // 総当たりのための関数
- void difs(int pos) {
- if( pos => 10 ) {
- // 10個以上は計算しないので、ここでおわり!
- func();
- return;
- } else {
- // ここでどんどんansを更新する
- a[pos] = 0; difs(pos+1);
- a[pos] = 1; difs(pos+1);
- }
- }
- int main(void)
- {
- //
- // 入力を済ませる
- //
- defs(0); // 0 からスタート
- cout << ans << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment