package SearchAlphabat;

import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		int[] arrayI = new int[26];

		for (int i = 0; i < 26; i++) {
			arrayI[i] = -1;
		}

		Scanner scanner = new Scanner(System.in);
		String S = scanner.nextLine();

		char[] arrayChar = S.toCharArray();

		for (int i = 0; i < S.length(); i++) {
			if (arrayI[Integer.parseInt(String.valueOf(arrayChar[i] - 'a'))] == -1) {
				arrayI[Integer.parseInt(String.valueOf(arrayChar[i] - 'a'))] = i;
			}
		}

		for (int i = 0; i < 26; i++) {
			System.out.print(arrayI[i] + " ");
		}

	}

}

예제

 

package Honeycomb;

import java.util.Scanner;

public class Main {

	public static boolean isIn(int sum, int n) {
		if (sum > n) {
			return false;
		} else
			return true;
	}

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int sum = 1;
		int i;
		for (i = 1; isIn(sum, N); i++) {
			sum += (6 * i);
		}
		System.out.println(i);
	}
}

예제

package Hansu;

import java.util.Scanner;

class hansu {
	public int x;

	hansu() {
		this.x = 0;
	}

	public boolean sumDigit(int temp) {
		int i = 0, j = 0, k = 0;
		i = temp / 100;
		j = (temp - i * 100) / 10;
		k = temp % 10;
		return (i - j) == (j - k);

	}

	public int searchHansu(int temp) {
		int sum = 0;
		if (temp > 1000||temp<1) {
			System.out.println("숫자 범위 오류");
		} else if (temp >= 100) {
			for (int a = 100; a <= temp; a++) {
				if (sumDigit(a)) {
					sum++;
				}
			}
			sum += 99;
		} else
			sum = temp;
		return sum;
	}
}

public class Main {
	public static void main(String[] args) {
			Scanner scan = new Scanner(System.in);
			hansu test = new hansu();
			System.out.print("Input Num : ");
			int temp = scan.nextInt();			
			System.out.println(test.searchHansu(temp));
			scan.close();
	}
}

 

예제 1
예제 2

 

예제 3

 

package croatiaAlphabat;

import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String line = scan.nextLine();
		int minusSum = 0;

		for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == 'd' && line.charAt(i + 1) == 'z') {
				minusSum++;
			} else if (line.charAt(i) == 'l' && line.charAt(i + 1) == 'j') {
				minusSum++;
			} else if (line.charAt(i) == 'n' && line.charAt(i + 1) == 'j') {
				minusSum++;
			} else if (line.charAt(i) == '=' || line.charAt(i) == '-') {
				minusSum++;
			}
		}
		System.out.println(line.length() - minusSum);
	}
}

 

 

예제1

 

예제2

 

예제3
예제4

 

package ACMhotel;

import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int cnt = 0;
		cnt = scan.nextInt();
		int[] roomArr = new int[cnt];

		for (int i = 0; i < cnt; i++) {
			int H = 0, W = 0, N = 0;
			H = scan.nextInt();
			W = scan.nextInt();
			N = scan.nextInt();

			int room;
			room = (N - H * (N / H)) * 100 + (N / H) + 1;
			roomArr[i] = room;
		}
		for (int i = 0; i < cnt; i++) {
			System.out.println(roomArr[i]);
		}
	}
}

예제

 

 

package bfBlackjack;
import java.util.Scanner;

class blackJack
{
	public int BFblackjack(int[] tempArr,int n, int m)
	{
		int[] iArr= new int[n];
		iArr=tempArr;
		int sum = 0;
		int temp=0;
		for(int i=0;i<n;i++)
		{
			for(int j=(i+1);j<n;j++)
			{
				for(int k=(j+1);k<n;k++)
				{
					temp=(iArr[i]+iArr[j]+iArr[k]);
					if(temp<=m&&temp>sum)
					{
						sum=temp;
					}
				}
			}
		}
		return sum;
	}
}

public class Main {
	public static void main(String[] args)
	{
		
		blackJack test=new blackJack();
		Scanner scanner = new Scanner(System.in);
		int n=0;
		int m=0;
		
		n=scanner.nextInt();
		m=scanner.nextInt();
		
		int[] iArr= new int[n];
		for(int i=0;i<n;i++)
		{
			iArr[i]=scanner.nextInt();
		}
		System.out.println(test.BFblackjack(iArr,n,m));
		
		scanner.close();
	}
}

 

예제1
예제2

 

+ Recent posts