Skip to content

Instantly share code, notes, and snippets.

View dalcon10028's full-sized avatar
🐟

dalcon dalcon10028

🐟
View GitHub Profile
import java.math.BigInteger;
import java.util.*;
class Solution {
public static int gcd(int a, int b){
BigInteger b1 = BigInteger.valueOf(a);
BigInteger b2 = BigInteger.valueOf(b);
return b1.gcd(b2).intValue();
}
public long solution(int w,int h) {
import java.util.*;
class Solution {
public int solution(int bridge_length, int weight, int[] truck_weights) {
int answer = 1; // κ²½κ³Όμ‹œκ°„ 1λΆ€ν„°
ArrayList<Integer> truck = new ArrayList<>(); // λŒ€κΈ° 트럭
ArrayList<int[]> onBridge = new ArrayList<>(); // 닀리λ₯Ό κ±΄λ„ˆλŠ” 트럭, νŠΈλŸ­λ‹Ή κ±Έλ¦¬λŠ” μ‹œκ°„
for (int i : truck_weights) truck.add(i); // 트럭 무게λ₯Ό λŒ€κΈ° 트럭 λ¦¬μŠ€νŠΈμ— λ„£κΈ°
onBridge.add(new int[]{truck.get(0), bridge_length}); truck.remove(0); // 첫 번째 트럭이 닀리에 λ“€μ–΄μ„œκ³  μ‹œμž‘
while(!onBridge.isEmpty()){ // λ‹€λ¦¬μœ„μ— 트럭이 없을 λ•ŒκΉŒμ§€
if(onBridge.get(0)[1]==1) // 닀리에 μžˆλŠ” κ°€μž₯ λ¨Όμ € λ“€μ–΄κ°„ 트럭이 남은 거리가 1이면
import java.util.*;
/**
* Solution
*/
public class Solution {
public static void main(String[] args) {
int bridge_length = 2;
int weight = 10;
int[] truck_weights = {7, 4, 5, 6};
System.out.print(solution(bridge_length, weight, truck_weights));
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
sc.close();
int i=2;
while (N!=1) {
if(N%i==0){
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
BigInteger a = new BigInteger(sc.next());
BigInteger b = new BigInteger(sc.next());
sc.close();
System.out.println(a.gcd(b));
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
BigInteger firstRing = new BigInteger(sc.next()); // 첫 번째 링
BigInteger[] num = new BigInteger[N-1];
for (int i=0; i<N-1; i++) // λ‚˜λ¨Έμ§€ 링
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
sc.close();
int i=0;
int newNum = N;
if(N<10){ // N이 10보닀 μž‘λ‹€λ©΄
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] realDivisor = new int[N];
for(int i=0; i<N; i++)
realDivisor[i] = sc.nextInt();
sc.close(); Arrays.sort(realDivisor);
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
double []num = new double[N];
for(int i=0; i<N; i++) num[i]=sc.nextDouble();
sc.close();
#include <stdio.h>
#include <string.h>
int queue[2000001];
int front=0;
int rear=-1;
void clean(char arr[]); // μ΄ˆκΈ°ν™”μš© ν•¨μˆ˜
void push(int x);
void pop(void);