ArithmeticSequenceDiv1
By 불타는 아잍(IT)스크림 | 2019년 12월 20일 |
Code public class ArithmeticSequenceDiv1 { public int findMinCost(int[] x) { int n = x.length; int min = 10000; int maxGap = 0; for (int i = 0; i < n-1; i++) if(Math.abs(x[i+1]-x[i]) > maxGap) maxGap = Math.abs(x[i+1]-x[i]); for (int d = -maxGap; d <= maxGap; d++) { for (int a = -200; a <= 200; a++) { int sum
TreasureHunt
By 불타는 아잍(IT)스크림 | 2019년 12월 20일 |
Code public class TreasureHunt{ int xLen,yLen; char[][] land; String[] inst; boolean instCheck(int x, int y) { int[] dx = {0,-1,1,0}; int[] dy = {-1,0,0,1}; for (int k = inst.length-1; k >= 0; k--) { char d = inst[k].charAt(0); int p = inst[k].charAt(2)-'0'; if (d == 'W') { while(p-->0)
RectangularGrid
By 불타는 아잍(IT)스크림 | 2020년 3월 14일 |
Code public class RectangularGrid{ public long countRectangles(int width, int height) { long res = 0; for(int i = 0; i < height; i++) { for(int j = 0; j < width; j++) { if(i == j) continue; res += (height-i) * (width-j); } } return res; }} Problem 격자 무늬에서 직사각형의 개수를 구하라. (정사각형 제외) 예) 3x3 격자에서 1