#include <iostream> using namespace std; int main() { int iTestCase; cin >> iTestCase; while (iTestCase--) { int Count_Zero[41] = { 1,0, }; int Count_One[41] = { 0,1, }; int N; cin >> N; for (int i = 2; i < 41; i++) { if (N < i) break; Count_Zero[i] = Count_Zero[i - 2] + Count_Zero[i - 1]; Count_One[i] = Count_One[i - 2] + Count_One[i - 1]; } cout << Count_Zero[N] << " " << Count_One[N] << endl; } }
# include < iostream > # include < vector > # include < string > using namespace std ; int main ( ) { string sInput ; getline ( cin , sInput , '\n' ) ; int Time = 1 ; int Count = 0 ; vector < string > Storage ; for ( int i = 0 ; i < sInput . size ( ) ; i + + ) { for ( int j = 0 ; ( j + Time - 1 ) < sInput . size ( ) ; j + + ) Storage . push_back ( sInput . substr ( j , Time ) ) ; Time + + ; } bool * Visited = new bool [ Storage . size ( ) * sizeof ( bool ) ] ; for ( int i = 0 ; i < Storage . size ( ) ; i + + ) { Visited [ i ] = true ; for ( int j = 0 ; j < Storage . size ( ) ; j + + ) { if ( i ! = j & & Storage [ i ] = = Storage [ j ] ) { Visited [ i ] = false ; Visited [ j ] = true ; break ; } } } for ( int i = 0 ; i < Storage . size ( ) ; i + + ) if ( Visited [ i ] ) Count ...
댓글
댓글 쓰기