반응형
SMALL

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BOJ2108
{
internal class Program
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(Console.OpenStandardInput());
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
int n = Convert.ToInt32(sr.ReadLine());
int a = Convert.ToInt32(sr.ReadLine());
int b = Convert.ToInt32(sr.ReadLine());
List<int> list = new List<int>();
int i = 0;
while(true)
{
i++;
if (i % n == 0 && i.ToString().All(x => x == '1'))
{
list.Add(i);
break;
}
}
i = 0;
while (true)
{
i++;
if (i % a == 0 && i.ToString().All(x => x =='1'))
{
list.Add(i);
break;
}
}
i = 0;
while (true)
{
i++;
if (i % b == 0 && i.ToString().All(x => x == '1'))
{
list.Add(i);
break;
}
}
i = 0;
foreach (int num in list) {
sw.WriteLine(num.ToString().Length);
}
sr.Close();
sw.Flush();
sw.Close();
}
}
}
굉장히 단순한 문제인데 시간초과가 뜨는 문제가 있다.
일단 다른 문제 풀어보고 생각나면 수정 예정
반응형
LIST
'Algorithm > BOJ' 카테고리의 다른 글
| [BOJ] 19532번 수학은 비대면 강의 입니다. 파이썬 사용 풀이 (0) | 2023.03.26 |
|---|---|
| [BOJ] 11382번 꼬마정민 파이썬 사용 풀이 (1) | 2023.03.24 |
| [BOJ] 2108번 통계학 C# 사용 풀이 (1) | 2023.03.22 |
| [BOJ] 1260번 DFS와 BFS (0) | 2023.03.05 |
| [BOJ] 1940번 주몽 C# 사용 풀이 (두포인터 알고리즘 ) (0) | 2023.02.20 |