알고리즘
[Java] 백준 2438: 별 찍기 - 1
import java.util.*; public class no2438 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); for(int i=1;i
[Java] 백준 15552: 빠른 A+B
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int n = Integer.parseInt(br.readLine()); StringTokenizer st; for(int i=0;i
[Java] 백준 25304: 영수증
import java.util.*; public class no25304 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int sum = sc.nextInt(); int var = sc.nextInt(); int total=0; for(int i=0;i
[Java] 백준 8393: 합
import java.util.*; public class no8393 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int num = 0; for(int i=1;i
[Java] 백준 10950: A+B-3
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); for(int i=0;i
[Java] 백준 2480: 주사위 세개
import java.util.*; public class no2480 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if(a!=b && b!=c && a!=c) { int max; if(a>b) { if(c>a) { //c>a>b max=c; } else { //a max=a; } } else { //b>a if(c>b) { //c>b>a max=c; } else { max=b; } } System.out.println(max*100); } else { if(a==b&&a==c) { //a=..
[Java] 백준 2525: 오븐 시계
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int H = sc.nextInt(); int M = sc.nextInt(); int C = sc.nextInt(); int min = 60 * H + M; min += C; int hour = (min / 60) % 24; int minute = min % 60; System.out.println(hour + " " + minute); } } 시간과 분을 따로 생각하고 풀었다가 조건이 너무 많아져서.. 시간과 분을 모두 분으로 환산하여 문제를 해결하는 방식으로 진행하였다. 환산한 분 ..
[Java] 백준 2884: 알람 시계
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int hour = sc.nextInt(); int minute = sc.nextInt(); if(minute-45
[Java] 백준 2753: 윤년
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int year = sc.nextInt(); if(year%4==0) { if(year%400==0) System.out.print("1"); else if(year%100==0) System.out.print("0"); else System.out.print("1"); } else { System.out.print("0"); } } } 4의 배수이면서 400의 배수일 때 100의 배수일 때 나머지(400의 배수도 아니고 100의 배수도 아닌 경우) 4의 배수가 아닐 때 위와 같은 알고리즘으로 해..
[Java] 백준 9498: 시험 성적
import java.util.*; public class no9498 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int score = sc.nextInt(); if(score89) { System.out.print("A"); } else if(score79) { System.out.print("B"); } else if(score69) { System.out.print("C"); } else if(score59) { System.out.print("D"); } else { System.out.println("F"); } } } if문과 논리연산자 and를 이용하여 문제 해결을 진행하였다.