백준 1773 폭죽쇼
Console Programming/C# Console 2019. 10. 28. 17:36using System;
using System.Collections.Generic;
namespace _1773
{
class Program
{
static void Main(string[] args)
{
string str = Console.ReadLine();
string[] str2 = str.Split(' ');
int numberOfStudent = int.Parse(str2[0]+"");
int timeWhenShowIsOver = int.Parse(str2[1]+"");
Dictionary<int,int> observatedTime = new Dictionary<int,int>();
int[] period = new int[numberOfStudent];
int minPeriod = timeWhenShowIsOver;
for(int i=0; i < numberOfStudent; i++)
{
period[i] = int.Parse(Console.ReadLine());
minPeriod = Math.Min(minPeriod, period[i]);
}
for(int j=0; j<numberOfStudent; j++)
{
for (int i = 1; i < (timeWhenShowIsOver / minPeriod) + 1; i++)
{
if (period[j]*i<=timeWhenShowIsOver && observatedTime.ContainsKey(period[j] * i) == false)
{
observatedTime.Add(period[j] * i, 1);
}
}
}
Console.WriteLine(observatedTime.Count);
}
}
}
'Console Programming > C# Console' 카테고리의 다른 글
2019-10-30 System.InvalidOperationException: 컬렉션이 수정되었습니다. 열거 작업이 실행되지 않을 수도 있습니다. (0) | 2019.10.30 |
---|---|
백준 1003 피보나치함수 (0) | 2019.10.30 |
백준 1159 농구경기 (0) | 2019.10.25 |
2019-10-24 구조체 테스트 (0) | 2019.10.24 |
2019-10-24 24일차 벡터 (0) | 2019.10.24 |