Minimum number of bombs | CPP program to find number of bombings required to kill all aliens . ; function to print where to shoot ; no . of bombs required ; bomb all the even positions ; bomb all the odd positions ; bomb all the even positions again ; driver program
#include <bits/stdc++.h> NEW_LINE using namespace std ; void print ( int n ) { cout << n + n / 2 << endl ; for ( int i = 2 ; i <= n ; i += 2 ) cout << i << " ▁ " ; for ( int i = 1 ; i <= n ; i += 2 ) cout << i << " ▁ " ; for ( int i = 2 ; i <= n ; i += 2 ) cout << i << " ▁ " ; } int main ( ) { int n = 3 ; print ( n ) ; return 0 ; }