https://www.acmicpc.net/problem/9933
9933번: 민균이의 비밀번호
문제 창영이는 민균이의 컴퓨터를 해킹해 텍스트 파일 하나를 자신의 메일로 전송했다. 파일에는 단어가 한 줄에 하나씩 적혀있었고, 이 중 하나는 민균이가 온라인 저지에서 사용하는 비밀번��
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _9933
{
class Program
{
public static string Reverse(string input)
{
string rtnString = "";
for (int i = input.Length - 1; i >= 0; i--)
rtnString += input.Substring(i, 1);
return rtnString;
}
static void Main(string[] args)
{
int count = int.Parse(Console.ReadLine());
var wordList = new List<string>();
for(int i = 0; i < count; i++)
wordList.Add(Console.ReadLine());
foreach (string word in wordList)
{
if(wordList.Find(x => x == Program.Reverse(word)) != null)
{
Console.Write(word.Length + " " + word[word.Length / 2]);
break;
}
}
}
}
}
|
cs |
모든 스트링에 대해 Reverse해보고 비교해보면 되겠습니다.
백준# 2870 - 수학숙제 (0) | 2020.05.22 |
---|---|
백준# 9996 - 한국이 그리울 땐 서버에 접속하지 (0) | 2020.05.16 |
백준# 7569 - 덩치 (0) | 2020.05.13 |
백준# 4811 - 알약 (0) | 2020.05.13 |
백준# 2961 - 도영이가 만든 맛있는 음식 (0) | 2020.05.13 |