#include <iostream> #include <vector> #include <algorithm> using namespace std; class Rope { private: int Ropes[100000]; int N; public: Rope(int n); int GetAnswer(); }; Rope::Rope(int n) { this->N = n; for (int i = 0; i < this->N; i++) { int Temp; cin >> Temp; Ropes[i] = Temp; } } int Rope::GetAnswer() { int Most = 0; sort(Ropes,Ropes+N); for (int i = 0; i < this->N; i++) { Ropes[i] = Ropes[i] * (this->N - i); if (Most < Ropes[i]) Most = Ropes[i]; } return Most; } int main() { int N; cin >> N; Rope R(N); cout << R.GetAnswer(); }
# 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 ...
댓글
댓글 쓰기