세로읽기

 
시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB 15392 8516 7323 57.238%

문제

아직 글을 모르는 영석이가 벽에 걸린 칠판에 자석이 붙어있는 글자들을 붙이는 장난감을 가지고 놀고 있다. 

이 장난감에 있는 글자들은 영어 대문자 ‘A’부터 ‘Z’, 영어 소문자 ‘a’부터 ‘z’, 숫자 ‘0’부터 ‘9’이다. 영석이는 칠판에 글자들을 수평으로 일렬로 붙여서 단어를 만든다. 다시 그 아래쪽에 글자들을 붙여서 또 다른 단어를 만든다. 이런 식으로 다섯 개의 단어를 만든다. 아래 그림 1은 영석이가 칠판에 붙여 만든 단어들의 예이다. 

A A B C D D
a f z z 
0 9 1 2 1
a 8 E W g 6
P 5 h 3 k x

<그림 1>

한 줄의 단어는 글자들을 빈칸 없이 연속으로 나열해서 최대 15개의 글자들로 이루어진다. 또한 만들어진 다섯 개의 단어들의 글자 개수는 서로 다를 수 있다. 

심심해진 영석이는 칠판에 만들어진 다섯 개의 단어를 세로로 읽으려 한다. 세로로 읽을 때, 각 단어의 첫 번째 글자들을 위에서 아래로 세로로 읽는다. 다음에 두 번째 글자들을 세로로 읽는다. 이런 식으로 왼쪽에서 오른쪽으로 한 자리씩 이동 하면서 동일한 자리의 글자들을 세로로 읽어 나간다. 위의 그림 1의 다섯 번째 자리를 보면 두 번째 줄의 다섯 번째 자리의 글자는 없다. 이런 경우처럼 세로로 읽을 때 해당 자리의 글자가 없으면, 읽지 않고 그 다음 글자를 계속 읽는다. 그림 1의 다섯 번째 자리를 세로로 읽으면 D1gk로 읽는다. 

그림 1에서 영석이가 세로로 읽은 순서대로 글자들을 공백 없이 출력하면 다음과 같다:

Aa0aPAf985Bz1EhCz2W3D1gkD6x

칠판에 붙여진 단어들이 주어질 때, 영석이가 세로로 읽은 순서대로 글자들을 출력하는 프로그램을 작성하시오.

입력

총 다섯줄의 입력이 주어진다. 각 줄에는 최소 1개, 최대 15개의 글자들이 빈칸 없이 연속으로 주어진다. 주어지는 글자는 영어 대문자 ‘A’부터 ‘Z’, 영어 소문자 ‘a’부터 ‘z’, 숫자 ‘0’부터 ‘9’ 중 하나이다. 각 줄의 시작과 마지막에 빈칸은 없다.

출력

영석이가 세로로 읽은 순서대로 글자들을 출력한다. 이때, 글자들을 공백 없이 연속해서 출력한다. 

예제 입력 1 복사

ABCDE
abcde
01234
FGHIJ
fghij

예제 출력 1 복사

Aa0FfBb1GgCc2HhDd3IiEe4Jj

예제 입력 2 복사

AABCDD
afzz
09121
a8EWg6
P5h3kx

예제 출력 2 복사

Aa0aPAf985Bz1EhCz2W3D1gkD6x

정답

package project;

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        //TODO Auto-generated method stub
		char[][] answer = new char[5][15];
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        
		for(int i = 0; i < answer.length; i++){            
            String str = sc.nextLine().trim();       
		    for(int j = 0; j < str.length(); j++){
		        answer[i][j] = str.charAt(j);
		    }
		}
        
        for(int i = 0; i < 15; i++){
            for(int j = 0; j < 5; j++){
                if(answer[j][i] == ' ' || answer[j][i] == '\0'){
                    continue;
                }
                System.out.print(answer[j][i]);
            }
        }
    }
}

'코딩테스트 준비 > 백준' 카테고리의 다른 글

2884번 - 알람시계  (0) 2022.03.20
2490번 - 윷놀이  (0) 2022.03.20
2752번 문제 - 백준(bronze4)  (0) 2022.03.17
1964번 문제 - 백준(bronze4)  (0) 2022.02.15
백준(bronze4) - (22.01.31)  (0) 2022.01.31

세수정렬 성공

 
시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB 19463 11594 10402 61.828%

문제

동규는 세수를 하다가 정렬이 하고싶어졌다.

숫자 세 개를 생각한 뒤에, 이를 오름차순으로 정렬하고 싶어 졌다.

숫자 세 개가 주어졌을 때, 가장 작은 수, 그 다음 수, 가장 큰 수를 출력하는 프로그램을 작성하시오.

입력

숫자 세 개가 주어진다. 이 숫자는 1보다 크거나 같고, 1,000,000보다 작거나 같다. 이 숫자는 모두 다르다.

출력

제일 작은 수, 그 다음 수, 제일 큰 수를 차례대로 출력한다.

예제 입력 1 복사

3 1 2

예제 출력 1 복사

1 2 3

정답

n1, n2, n3 = map(int, input().split())

answer = [n1, n2, n3]

answer.sort()

for i in answer:
    print(i)

 

'코딩테스트 준비 > 백준' 카테고리의 다른 글

2490번 - 윷놀이  (0) 2022.03.20
10798번 - 세로읽기  (0) 2022.03.20
1964번 문제 - 백준(bronze4)  (0) 2022.02.15
백준(bronze4) - (22.01.31)  (0) 2022.01.31
2557번 문제 - 백준(bronze5)  (0) 2022.01.18

벌써 반이나 이수했다... 과제도 남긴 했지만 기한이 넉넉해서 완벽하게 완성하고 제출할 예정~

메일함을 확인하던 중 이런 메일이 도착해 있었는데 본문내용은 이렇다.

Hello,

I have to share bad news with you.

Approximately a few months ago, I gained access to your devices, which you use for internet browsing.
After that, I have started tracking your internet activities.

Here is the sequence of events:
Some time ago, I purchased access to email accounts from Russian hackers (nowadays, it is quite simple to buy it online). I have easily managed to log in to your email account -대충 내 이메일-.
One week later, I have already installed the Cobalt Strike Agent "Beacon" on the Operating Systems of all the devices you use to access your internet. It was not hard at all (Automatic Web Drive-by Exploit).
All ingenious is simple. :)

This software provides me with Initial Access to all your devices. I have downloaded all your information, data, files, document, backups, photos, videos, and web browsing history to my servers. I have access to all your messengers, social networks, emails, chat history, call history, and contacts list.
My Cobalt Strike Artifact is Fileless Malware and hence remains invisible for antivirus software.
Likewise, I guess by now you understand why I have stayed undetected until this letter.

While gathering information about you, I have discovered that you are a big fan of adult websites.
You love visiting porn websites and watching exciting videos while enduring an enormous amount of pleasure. Well, I have managed to record a number of your dirty scenes and montaged a few videos, which show how you masturbate and reach orgasms.
If you have doubts, I can make a few clicks of my mouse, and all your videos will be shared with your friends, colleagues, coworkers, and relatives. Considering the specificity of the videos you like to watch (you perfectly know what I mean), it will cause a real catastrophe for you.
I also have no issue at all with making them available for public access (leaked and exposed all data).
General Data Protection Regulation (GDPR): Under the rules of the law, you face a heavy fine or arrest.
I guess you don't want that to happen.

Let's settle it this way:
You transfer 1 Bitcoin (BTC) to me and once the transfer is received, I will delete all this dirty stuff right away.
After that, we will forget about each other. I also promise to deactivate and delete all the harmful software from your devices. Trust me. I keep my word.
That is a fair deal, and the price is relatively low, considering that I have been checking out your profile and traffic for some time by now. If you don't know how to purchase and transfer Bitcoin - you can use any modern search engine.
You need to send that amount here Bitcoin wallet address:
비트코인지갑
(It is cAsE seNsiTivE, to get a valid bitcoin address you must remove space in the wallet address).
You have 5 days in order to make the payment from the moment you opened this email.

Do not try to find and destroy my virus! (All your data is already uploaded to a remote server).
Do not try to contact me. Various security services will not help you; formatting a disk or destroying a device will not help either, since your data is already on a remote server.

This is an APT Hacking Group. Don't be mad at me, everyone has their own work.
I will monitor your every move until I get paid. If you keep your end of the agreement, you won't hear from me ever again.
Everything will be done in a fair manner!
One more thing. Don't get caught in similar kinds of situations anymore in the future!
My advice: keep updating your antivirus software frequently.

우리는 너의 인터넷 기록을 꾸준하게 추적했다.

대충 불법사이트에 접속해서 너의 컴퓨터에 Cobalt Strike Artiface?를 심어놨다.

너의 해피타임(?)을 즐기는 비디오를 내가 가지고 있으니 저 비트코인 지갑으로 1비트코인을 쏴라

나에게 메일을 보낼 생각을 하지도말고 찾지도 말아라 우리는 APT Hacking Group이다

라는데 접속한적이 없는데? 뭔 메일이냐 싶어 앞에 2줄을 따로 검색해봤다.

 

https://www.pcrisk.com/removal-guides/20203-i-have-to-share-bad-news-with-you-email-scam

 

뭐.... 낚이는 사람이 있을라나?...

혹시라도 쫄린다면 인터넷선 뽑고(중요) 백신프로그램돌리고 포맷해버리도록 하자

오각형, 오각형, 오각형…

 
시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB 8264 3762 3220 46.218%

문제

오각형의 각 변에 아래 그림과 같이 점을 찍어 나간다. N단계에서 점의 개수는 모두 몇 개일까?

입력

첫째 줄에 N(1 ≤ N ≤ 10,000,000)이 주어진다.

출력

첫째 줄에 N단계에서 점의 개수를 45678로 나눈 나머지를 출력한다.

예제 입력 1 복사

3

예제 출력 1 복사

22

예제 입력 2 복사

1

예제 출력 2 복사

5

예제 입력 3 복사

19

예제 출력 3 복사

590

정답

import java.util.*;

public class Main {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int first = 1;
        int sum = 1;
        int mod = 45678;
        
        for(int i = 0; i < num; i++){
            first += 3;
            sum += first;
            sum %= mod;
        }
        System.out.print(sum);
    }
}

 

1 → 4 → 7 → 10 → 13 → 16 순

계속해서 더해주고 마지막에 조건대로 45678로 나눈 나머지를 출력

'코딩테스트 준비 > 백준' 카테고리의 다른 글

10798번 - 세로읽기  (0) 2022.03.20
2752번 문제 - 백준(bronze4)  (0) 2022.03.17
백준(bronze4) - (22.01.31)  (0) 2022.01.31
2557번 문제 - 백준(bronze5)  (0) 2022.01.18
2475번 문제 - 백준(bronze5)  (0) 2022.01.18

+ Recent posts