자바 백준 1075번 나누기
풀이: 뒷자리 두자리를 00으로 초기화 해준다음 1씩 더하면서 나누어 떨어지는 수를 찾으면 된다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
Scanner sc = new Scanner(System.in); | |
int a = sc.nextInt(); | |
int b = sc.nextInt(); | |
if(a>=100) { | |
while(true) { | |
if(a%100==0) { | |
break; | |
} | |
a=a-1; | |
} | |
while(true) { | |
if(a%b==0) { | |
break; | |
} | |
a=a+1; | |
} | |
} | |
if(a%100<10) { | |
System.out.print("0"); | |
System.out.println(a%100); | |
}else { | |
System.out.println(a%100); | |
} | |
sc.close(); | |
} | |
} |
'백준 알고리즘 > JAVA' 카테고리의 다른 글
자바 백준 1652번 누울 자리를 찾아라 (0) | 2018.08.07 |
---|---|
자바 백준 2869번 달팽이는 올라가고 싶다 (0) | 2018.08.05 |
자바 백준 1057번 토너먼트 (0) | 2018.08.05 |
자바 백준 1076번 저항 (0) | 2018.08.04 |
자바 백준 2010번 플러그 (0) | 2018.08.03 |