Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

코드 수정 #2

Merged
merged 4 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions bigInteger/Code_10757.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package bigInteger;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

/*
* �ۼ��� : 2018�� 07�� 15��
* �� �� : ū �� A+B
* A+B�� ����Ͻÿ�.
*/
public class Code_10757 {

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String[] arr=br.readLine().split(" ");

BigInteger a = new BigInteger(arr[0]);

BigInteger b = new BigInteger(arr[1]);

System.out.println(a.add(b));

//Scanner�� �̿��ϸ� �� �� ���� ������ �� �ִ�.
// BigInteger a = sc.nextBigInteger(); �� �Է¹޴� ���� ������ ���� �� ����.

}

}
45 changes: 45 additions & 0 deletions bigInteger/Code_10826.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package bigInteger;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

/*
* �ۼ��� : 2018�� 07�� 15��
* �� �� : �Ǻ���ġ �� 4
* n�� �־����� ��, n��° �Ǻ���ġ ���� ���ϴ� ���α׷��� �ۼ��Ͻÿ�.
* n�� 10,000���� �۰ų� ���� �ڿ��� �Ǵ� 0�̴�.
*/
public class Code_10826 {

static BigInteger[] arr = new BigInteger[10000];

public static void main(String[] args) throws NumberFormatException, IOException {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int num = Integer.parseInt(br.readLine());

System.out.println(pibonacci(num));

}

static BigInteger pibonacci(int num) {

if(arr[num]!=null) return arr[num];

else {
System.out.println(num);
BigInteger i = new BigInteger(String.valueOf(num));
if(i.equals(BigInteger.ZERO) || i.equals(BigInteger.ONE)) {
return arr[num] = i;
}
else {
BigInteger e = pibonacci(num-1).add(pibonacci(num-2));
return arr[num] = e;
}
}
}

}
30 changes: 30 additions & 0 deletions bigInteger/Code_10827.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package bigInteger;

import java.math.BigDecimal;
import java.util.Scanner;

/*
* �ۼ��� : 2018�� 07�� 15��
* �� �� : a^b
* �Ǽ� a�� ���� b�� �־����� ��, a�� b������ ��Ȯ�ϰ� ����ϴ� ���α׷��� �ۼ�.
*/

public class Code_10827 {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);

String[] arr = input.nextLine().split(" ");

BigDecimal a = new BigDecimal(arr[0]);

int b = Integer.parseInt(arr[1]);

BigDecimal c = a.pow(b);
System.out.println(c.toPlainString());
//toPlainString() : BigDecimal�� ǥ���� �� ������ ǥ�⸦ ������� ����.
//toString() : BigDecimal�� ǥ���� �� ������ ǥ�⸦ �����.
}

}
11 changes: 6 additions & 5 deletions collection/Code_1076.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@ public static void main(String[] args) {
for(int i=0; i<3; ++i) {
list.add(input.nextLine());
}

String a = "";

// long value = 0;
for(int i=0; i<list.size()-1; ++i) {
//System.out.print(map.get(list.get(i)));
a += map.get(list.get(i));
// value = map.get(list.get(i))*10 + map.get(list.get(i));
}

int x = map.get(list.get(2));
long x = map.get(list.get(2));
for(int i=0; i<x; ++i) {
//System.out.print("0");
a += "0";
a+="0";
//value *= 10;
}
System.out.println(Integer.parseInt(a));
System.out.println(Long.parseLong(a));
}
}
10 changes: 5 additions & 5 deletions collection/Code_10845.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package collection;

import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Deque;
import java.util.Scanner;

/*
Expand All @@ -14,7 +14,7 @@ public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner (System.in);

Queue<Integer> q = new ArrayDeque<Integer>();
Deque<Integer> q = new ArrayDeque<Integer>();

int num = input.nextInt();

Expand Down Expand Up @@ -52,15 +52,15 @@ else if(arr[0].equals("front")) {
System.out.println(q.peek());
}
}
/*

else if(arr[0].equals("back")) {
if(q.isEmpty()) {
System.out.println("-1");
}else {
System.out.println(q.);
System.out.println(q.peekLast());
}
}
*/

}
}

Expand Down
28 changes: 13 additions & 15 deletions collection/Code_1764.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,29 @@ public static void main(String[] args) {

ArrayList<String> list = new ArrayList<String>();

int hear = Integer.parseInt(a[0]);
int see = Integer.parseInt(a[1]);
int hear = Integer.parseInt(a[0]);//�赵 ���� ����� ��
int see = Integer.parseInt(a[1]);//���� ���� ����� ��

Map<String, Integer> map = new HashMap<String,Integer>();

Map<String, String> map = new HashMap<String,String>();

for(int i=1; i<=(hear+see); ++i) {
if(i<=hear) {
map.put(input.nextLine(), "hear");
}
else if(i>=hear+2) {
String name = input.nextLine();
if(map.containsKey(name))
list.add(name);
String name = input.nextLine();


if(map.containsKey(name)) {
list.add(name);
}
else {
String n = input.nextLine();
map.put(name, 0);
}
}

System.out.println(list.size());

Collections.sort(list);
System.out.println(list.size());

for(String t : list)
System.out.println(t);
for(String ss : list)
System.out.println(ss);
}

}
2 changes: 1 addition & 1 deletion io/Code_1000.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public static void main(String[] args) {
int a = input.nextInt();
int b = input.nextInt();

System.out.println("A+B = "+(a+b));
System.out.println(a+b);
}
}
90 changes: 90 additions & 0 deletions sort/Code_11650_Comparable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package sort;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/*
* �ۼ��� : 2018�� 07�� 15��
* �� �� : ����11650 -2���� ��� ���� �� N���� �־�����.
* ��ǥ�� x��ǥ�� �����ϴ� ������, x��ǥ�� ������ y��ǥ�� �����ϴ� ������
* ������ ���� ����ϴ� ���α׷��� �ۼ��Ͻÿ�.
*/
public class Code_11650_Comparable {

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
List<Point> list = new ArrayList<Point>();

String [] arr = new String[2];

int num = Integer.parseInt(br.readLine());

for(int i=0; i<num; ++i) {
arr = br.readLine().split(" ");
Point p = new Point(Integer.parseInt(arr[0]),Integer.parseInt(arr[1]));
list.add(p);
}

Collections.sort(list);

/**
34�ٰ� ���� ���
Collections.sort(list, new Comparator<Point>() {
@Override
public int compare(Point p1, Point p2) {
return p1.compareTo(p2);
}
});
**/

for(Point p : list)
System.out.println(p.toString());
}

}

class Point implements Comparable<Point>{
int x;
int y;

public Point(int x, int y) {
this.x = x;
this.y = y;
}

public int getX() {
return x;
}

public void setX(int x) {
this.x = x;
}

public int getY() {
return y;
}

public void setY(int y) {
this.y = y;
}

@Override
public String toString() {
return x + " " + y ;
}

@Override
public int compareTo(Point p) {
int r = this.x - p.x;
if(r!=0) return r;
else return this.y - p.y;
}

}

80 changes: 80 additions & 0 deletions sort/Code_11650_Comparator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/*
* �ۼ��� : 2018�� 07�� 15��
* �� �� : ����11650 -2���� ��� ���� �� N���� �־�����.
* ��ǥ�� x��ǥ�� �����ϴ� ������, x��ǥ�� ������ y��ǥ�� �����ϴ� ������
* ������ ���� ����ϴ� ���α׷��� �ۼ��Ͻÿ�.
*/
public class Code_11650_Comparator {

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
List<Point> list = new ArrayList<Point>();

String [] arr = new String[2];

int num = Integer.parseInt(br.readLine());

for(int i=0; i<num; ++i) {
arr = br.readLine().split(" ");
Point p = new Point(Integer.parseInt(arr[0]),Integer.parseInt(arr[1]));
list.add(p);
}

Collections.sort(list, new PointComparator());

for(Point p : list)
System.out.println(p.toString());
}

}

class Point{
int x;
int y;

public Point(int x, int y) {
this.x = x;
this.y = y;
}

public int getX() {
return x;
}

public void setX(int x) {
this.x = x;
}

public int getY() {
return y;
}

public void setY(int y) {
this.y = y;
}

@Override
public String toString() {
return x + " " + y ;
}
}

class PointComparator implements Comparator<Point>{
@Override
public int compare(Point p1, Point p2) {
int r = p1.x - p2.x;
if(r!=0) return r;
else return p1.y-p2.y;
}
}
Loading