11653번: 소인수분해
첫째 줄에 정수 N (1 ≤ N ≤ 10,000,000)이 주어진다.
www.acmicpc.net
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int i = 2;
while(i != 1){
if(n-i == 0){
System.out.println(n);
break;
}
if (n % i == 0){
System.out.println(i);
n /= i;
}
else{
i+=1;
}
}
}
}
1712번: 손익분기점
월드전자는 노트북을 제조하고 판매하는 회사이다. 노트북 판매 대수에 상관없이 매년 임대료, 재산세, 보험료, 급여 등 A만원의 고정 비용이 들며, 한 대의 노트북을 생산하는 데에는 재료비와
www.acmicpc.net
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int count = 1;
if (c>b){
c -= b;
while(a >= c){
count++;
a-=c;
}
System.out.println(count);
}
else{
System.out.print(-1);
}
}
}
'JAVA' 카테고리의 다른 글
ep 08-1. 제너릭 (0) | 2023.01.01 |
---|---|
ep 07. 기본 클래스 (0) | 2022.12.19 |
ep 06-2.문제 풀이 (0) | 2022.12.11 |
ep 06-1. Interface (0) | 2022.12.11 |
ep 05-2. 문제 풀이 (0) | 2022.12.02 |