일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Git
- 임베디드타입
- JPA프록시
- 에이치투데이터베이스
- 데이터베이트h2
- JPAmapping
- JPAproxy
- gitinitial
- JDBC connection pool
- jpa
- 제이피큐엘쿼리
- springboot기본설정
- javageneric
- MySqlType
- dockercmd
- Open EntityManager
- 자바제너릭
- springbootH2
- sql
- spring
- OSIV
- JPA Hint & Lock
- 스프링부트기본설정
- 스프링부트
- httppie
- 이해와 원리
- springbootproxy
- embededtype
- jpqlquery
- JPA값타입
Archives
- Today
- Total
빡코
[ 과제]백준_ 11047번_동전0 본문
https://www.acmicpc.net/problem/11047
풀긴 풀엇는디 ㅋㅋㅋ 런타임 에러다 ...
런타임에러1
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
int k= sc.nextInt();
int[] coin = new int[n];
for(int i =0;i<n;i++) {
coin[i]=sc.nextInt();
}
int cnt = 0;
for(int i=9;i>=0;i--) {
if(k!=0&&k>=coin[i]) {
k-=coin[i];
i+=1;
cnt+=1;
}
}
System.out.println(cnt);
sc.close();
}
}
런타임 에러2
package algorithmStudy;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
int k= sc.nextInt();
int[] coin = new int[n];
for(int i =0;i<n;i++) {
coin[i]=sc.nextInt();
}
int cnt = 0;
for(int i=9;i>=0;i--) {
if(k>=coin[i]&&k!=0) {
cnt+=k/coin[i];
k=k%coin[i];
}
}
System.out.println(cnt);
sc.close();
}
}
'Algorithm' 카테고리의 다른 글
[과제]프로그래머스_두 정수 사이의 합 (0) | 2020.01.02 |
---|---|
[과제] 설명 준비해오기1 (0) | 2020.01.02 |
[과제]백준_ 10872번 _팩토리얼 (0) | 2020.01.02 |
[스터디] 프로그래머스_레벨1_2016년 ( 요일맞추기) (0) | 2020.01.02 |
알고리즘에 대하여 (0) | 2020.01.02 |