#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++; cout << Count; }
# include < iostream > # include < vector > using namespace std ; int Num_of_Divisor ( int n ) { int Count = 0 ; for ( int i = 1 ; i < = n ; i + + ) if ( n % i = = 0 ) Count + + ; return Count ; } int main ( ) { int Testcase ; cin > > Testcase ; while ( Testcase - - ) { int Rooms ; cin > > Rooms ; vector < int > Prisons ; for ( int i = 0 ; i < Rooms ; i + + ) Prisons . push_back ( 0 ) ; for ( int i = 1 ; i < Prisons . size ( ) + 1 ; i + + ) { if ( ( Num_of_Divisor ( i ) % 2 ) = = 0 ) Prisons [ i - 1 ] = 0 ; else Prisons [ i - 1 ] = 1 ; } int Fleer = 0 ; for ( int i = 0 ; i < Prisons . size ( ) ; i + + ) if ( Prisons ...
댓글
댓글 쓰기