코테
할 수 있으면 자바스크립트, CSS헷갈렸던부분 복습
class Solution {
public int solution(int left, int right) {
int answer = 0;
int sum = 0;
int sum2 = 0;
for(int i = left; i <= right; i++) {
sum += i;
}
for(int i = 1; i <= 32; i++) {
if(i*i >= left && i*i <= right) {
sum2 += i*i;
}
}
answer = sum-sum2*2;
return answer;
}
}
+2점
class Solution {
public long solution(int price, int money, int count) {
long answer = 0;
long total = 0;
for(int i = 1; i <= count; i++) {
total += (long)(price*i);
}
if(money <= total) {
answer = (long)(total - money);
}else {
answer = 0;
}
return answer;
}
}
+8점
import java.util.Scanner;
class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
for(int j = 1; j <= b; j++){
for(int i = 1; i <= a; i++){
System.out.print("*");
}
System.out.println();
}
}
}
+1점
import java.util.*;
class Solution {
public int[] solution(int n, int m) {
int[] answer = new int[2];
int b = 0;
ArrayList<Integer> a = new ArrayList<Integer>();
if(n < m){
for(int i = 1; i <= m; i++){
if(m % i == 0 && n % i == 0){
a.add(i);
}
}
}else{
for(int i = 1; i <= n; i++){
if(m % i == 0 && n % i == 0){
a.add(i);
}
}
}
int c = a.get(a.size()-1);
System.out.println(c);
answer[0] = c;
answer[1] = m*n/c;
return answer;
}
}
+5점