'SRM'에 해당되는 글 14건

  1. 2009.09.15 SRM 150 DIV 2 (250)
  2. 2009.09.15 SRM 149 DIV 2 (250)
  3. 2009.07.04 SRM 307 DIV 2 (250)
  4. 2009.05.30 SRM 191 DIV 2 (250)
  5. 2009.05.27 SRM 148 DIV 2 (250)
  6. 2009.05.27 SRM 146 DIV 2 (250)
  7. 2009.05.27 SRM 147 DIV 2 (250)
  8. 2009.05.26 SRM 370 DIV 2 (500)
  9. 2009.05.26 SRM 370 DIV 2 (250)
  10. 2009.05.26 SRM 205 DIV 2 (250)

SRM 150 DIV 2 (250)

Programming/SRM Practice 2009. 9. 15. 23:11
SRM 150 DIV 2 (250)
문제 요약 : 지갑을 고치는 데 몇 일을 소비할까?

using System;

 

public class WidgetRepairs

{

    public int days(int[] arrivals, int numPerDay)

    {

        int days = 0;

        int remains = 0;

 

        for (int i = 0; i < arrivals.Length - 1; i++)

        {

            arrivals[i] += remains;

            remains = 0;

 

            if (arrivals[i] == 0) continue;

 

            if (arrivals[i] - numPerDay > 0)

            {

                int temp = arrivals[i] - numPerDay;

 

                if (temp > numPerDay)  remains = temp;

                else arrivals[i + 1] += temp;

            }

            days++;

        }

        days += (arrivals[arrivals.Length - 1] + remains) / numPerDay;

        if ((arrivals[arrivals.Length - 1] + remains) % numPerDay != 0) days++;

        return days;

    }

}


'Programming > SRM Practice' 카테고리의 다른 글

SRM 149 DIV 2 (250)  (0) 2009.09.15
SRM 307 DIV 2 (250)  (0) 2009.07.04
SRM 191 DIV 2 (250)  (0) 2009.05.30
SRM 148 DIV 2 (250)  (0) 2009.05.27
SRM 146 DIV 2 (250)  (0) 2009.05.27
:

SRM 149 DIV 2 (250)

Programming/SRM Practice 2009. 9. 15. 23:04
SRM 149 DIV 2 (250)
문제 요약 : dollars, cents 표기법에 맞게 출력하기

using System;

 

public class FormatAmt

{

    public string amount(int dollars, int cents)

    {

        string res = "", temp = dollars.ToString();

        for (int i = temp.Length - 1; i >= 0; i--)

        {

            res = temp[i] + res;

            if ((temp.Length - i) % 3 == 0 && i != 0) res = "," + res;

        }

        if (cents.ToString().Length > 1) res += "." + cents.ToString();

        else res += ".0" + cents.ToString();

        return "$" + res;

    }

}


'Programming > SRM Practice' 카테고리의 다른 글

SRM 150 DIV 2 (250)  (0) 2009.09.15
SRM 307 DIV 2 (250)  (0) 2009.07.04
SRM 191 DIV 2 (250)  (0) 2009.05.30
SRM 148 DIV 2 (250)  (0) 2009.05.27
SRM 146 DIV 2 (250)  (0) 2009.05.27
:

SRM 307 DIV 2 (250)

Programming/SRM Practice 2009. 7. 4. 06:53
SRM 307 DIV 2 (250)
문제 요약 : 짝이 맞지 않아서 교환해야하는 신발은 총 몇 켤레인가? 

#include <iostream>

#include <vector>

using namespace std;

 

class BootsExchange

{

public:

        int leastAmount(vector <int> left, vector <int> right);

};

 

int BootsExchange::leastAmount(vector <int> left, vector <int> right)

{

        int cnt = 0;

       

        for(int i = 0; i < left.size() ; i++)

        {

               for(int j = 0; j < right.size() ; j++)

               {

                       if(left[i] == right[j])

                       {

                              right[j] = 0;

                              break;

                       }

                       else

                       {

                              if(j == right.size() - 1) cnt++;

                       }

               }

        }

        return cnt;

}

 

'Programming > SRM Practice' 카테고리의 다른 글

SRM 150 DIV 2 (250)  (0) 2009.09.15
SRM 149 DIV 2 (250)  (0) 2009.09.15
SRM 191 DIV 2 (250)  (0) 2009.05.30
SRM 148 DIV 2 (250)  (0) 2009.05.27
SRM 146 DIV 2 (250)  (0) 2009.05.27
:

SRM 191 DIV 2 (250)

Programming/SRM Practice 2009. 5. 30. 23:09
SRM 191 DIV 2 (250)
문제 요약 : 내기에서 이긴 사람이 받을 수 있는 돈을 Cents 단위로 반환하라. 

#include <iostream>

#include <vector>

using namespace std;

 

class BettingMoney

{

public:

           int moneyMade(vector <int> amounts, vector <int> centsPerDollar, int finalResult);

};

 

int BettingMoney::moneyMade(vector <int> amounts, vector <int> centsPerDollar, int finalResult)

{

           int sum = 0;

          

           for(int i = 0 ; i < amounts.size() ; i++)

                     if(i != finalResult) sum += amounts[i];

                    

           return (sum*100) - (centsPerDollar[finalResult]*amounts[finalResult]);

}

using system;

 

public class BettingMoney

{

    public int moneyMade(int[] amounts, int[] centsPerDollar, int finalResult)

    {

        int sum = 0;

 

        for (int i = 0; i < amounts.Length; i++)

            if (i != finalResult) sum += amounts[i];

 

        return (sum * 100) - (amounts[finalResult] * centsPerDollar[finalResult]);

    }

}



'Programming > SRM Practice' 카테고리의 다른 글

SRM 149 DIV 2 (250)  (0) 2009.09.15
SRM 307 DIV 2 (250)  (0) 2009.07.04
SRM 148 DIV 2 (250)  (0) 2009.05.27
SRM 146 DIV 2 (250)  (0) 2009.05.27
SRM 147 DIV 2 (250)  (0) 2009.05.27
:

SRM 148 DIV 2 (250)

Programming/SRM Practice 2009. 5. 27. 17:19
SRM 148 DIV 2 (250)
문제 요약 : 주어진 숫자를 그 숫자의 각 자리수로 나눌 수 있다면, 
그 횟수를 반환하라. 

#include <iostream>

using namespace std;

 

class DivisorDigits

{

public:

  int howMany(int number);

};

 

int DivisorDigits::howMany(int number)

{

  int temp = number;

  int cnt = 0;

  int n;

 

  while(temp >= 1)

  {

    n = temp % 10;

    temp /= 10;

    if(n != 0 && number % n == 0) cnt++;

  }

  return cnt;

}

'Programming > SRM Practice' 카테고리의 다른 글

SRM 307 DIV 2 (250)  (0) 2009.07.04
SRM 191 DIV 2 (250)  (0) 2009.05.30
SRM 146 DIV 2 (250)  (0) 2009.05.27
SRM 147 DIV 2 (250)  (0) 2009.05.27
SRM 370 DIV 2 (500)  (0) 2009.05.26
:

SRM 146 DIV 2 (250)

Programming/SRM Practice 2009. 5. 27. 15:51
SRM 146 DIV 2 (250)
문제 요약 : 주사위를 5번 던진 값이 주어지면,
그 중에서 같은 값의 경우는 그 값을 전부 더한다. 이 때 나올 수 있는 최대값을 구하라.

#include <iostream>

#include <vector>

using namespace std;

 

class YahtzeeScore

{

public:

  int maxPoints(vector <int> toss);

};

 

int YahtzeeScore::maxPoints(vector <int> toss)

{

  int sum = 0, max = 0;

 

  for(int i = 1 ; i < 7 ; i++)

  {

    for(int j = 0 ; j < toss.size() ; j++)

    {

      if(i == toss[j]) sum += toss[j];

    }

    if(sum > max) max = sum;

    sum = 0;

  }

 

  return max;
}

'Programming > SRM Practice' 카테고리의 다른 글

SRM 191 DIV 2 (250)  (0) 2009.05.30
SRM 148 DIV 2 (250)  (0) 2009.05.27
SRM 147 DIV 2 (250)  (0) 2009.05.27
SRM 370 DIV 2 (500)  (0) 2009.05.26
SRM 370 DIV 2 (250)  (0) 2009.05.26
:

SRM 147 DIV 2 (250)

Programming/SRM Practice 2009. 5. 27. 00:48
SRM 147 DIV 2 (250)
문제 요약 : 주어진 문장을 주어진 수만큼 shift한 후
결과 값을 반환하라.

#include <iostream>

using namespace std;

class CCipher

{

public:

  string decode(string cipherText, int shift);

};

 

string CCipher::decode(string cipherText, int shift)

{

  string res = "";


  
for(int i = 0 ; cipherText[i] ; i++)

    if(cipherText[i] - shift < 'A')  res += cipherText[i] + 26 - shift;

    else  res += cipherText[i] - shift;


  
return res;
}

'Programming > SRM Practice' 카테고리의 다른 글

SRM 148 DIV 2 (250)  (0) 2009.05.27
SRM 146 DIV 2 (250)  (0) 2009.05.27
SRM 370 DIV 2 (500)  (0) 2009.05.26
SRM 370 DIV 2 (250)  (0) 2009.05.26
SRM 205 DIV 2 (250)  (0) 2009.05.26
:

SRM 370 DIV 2 (500)

Programming/SRM Practice 2009. 5. 26. 17:47
SRM 370 DIV 2 (500)
문제 요약 : 색깔이 중복될 것으로 예상되는 마블의 수를 구하라.

#include <iostream>

#include <vector>

using namespace std;

 

class DrawingMarbles

{

public:

  double sameColor(vector<int> colors, int n);

};

 

double DrawingMarbles::sameColor(vector<int> colors, int n)

{

  int i = 0, j = 0;

  int total = 0;

  double res = 0;

  double sum = 1;

 

  if(colors.size() != 1)

  {

     for(i = 0 ; i < colors.size() ; i++)

         total += colors[i];

     for(i = 0 ; i < colors.size() ; i++)

     {

        for(j = 0 ; j < n ; j++)

          sum *= ((double)colors[i] - (double)j)
                             / ((
double)total - (double)j);

         

        res += sum;

        sum = 1;

     }

  }

  else res = 1.0;

  return res;

}
 

'Programming > SRM Practice' 카테고리의 다른 글

SRM 146 DIV 2 (250)  (0) 2009.05.27
SRM 147 DIV 2 (250)  (0) 2009.05.27
SRM 370 DIV 2 (250)  (0) 2009.05.26
SRM 205 DIV 2 (250)  (0) 2009.05.26
SRM 200 DIV 2 (250)  (0) 2009.05.26
:

SRM 370 DIV 2 (250)

Programming/SRM Practice 2009. 5. 26. 17:43
SRM 370 DIV 2 (250)
문제 요약 : 낭비된 Container의 공간을 구하라.

#include<iostream>

#include<vector>

using namespace std;

 

class Containers

{

public:

  int wastedSpace(vector <int> containers, vector <int> packages);

};

 

int Containers::wastedSpace(vector <int> containers, vector <int> packages)

{

  int sum = 0;

 

  for(int i = 0 ; i < containers.size() ; i++)

     sum += containers[i];

 

  for(int i = 0 ; i < packages.size() ; i++)

     sum -= packages[i];

     return
sum;
}

'Programming > SRM Practice' 카테고리의 다른 글

SRM 147 DIV 2 (250)  (0) 2009.05.27
SRM 370 DIV 2 (500)  (0) 2009.05.26
SRM 205 DIV 2 (250)  (0) 2009.05.26
SRM 200 DIV 2 (250)  (0) 2009.05.26
SRM 197 DIV 2 (250)  (0) 2009.05.26
:

SRM 205 DIV 2 (250)

Programming/SRM Practice 2009. 5. 26. 17:20
SRM 205 DIV 2 (250)
문제 요약 : 평균값에 못 미치는 인원 수를 구하라.

#include <iostream>

#include <vector>
using
namespace std;

 

class Average

{

public:

  int belowAvg(vector <int> math, vector <int> verbal);

};

 

int Average::belowAvg(vector<int>math, vector<int>verbal)

{

  int i, cnt=0;

  double avg = 0;

 

  for(i = 0 ; i < math.size() ; i++)

    avg = avg + math[i] + verbal[i];

 

  avg = (avg / math.size());

  

  for(i = 0 ; i < math.size() ; i++)

    if(avg > math[i] + verbal[i]) cnt++;

 

  return cnt;
}

'Programming > SRM Practice' 카테고리의 다른 글

SRM 370 DIV 2 (500)  (0) 2009.05.26
SRM 370 DIV 2 (250)  (0) 2009.05.26
SRM 200 DIV 2 (250)  (0) 2009.05.26
SRM 197 DIV 2 (250)  (0) 2009.05.26
SRM 145 DIV 2 (250)  (0) 2009.05.26
: