320x100
lv.1 μκ° μ½λ μ±λ¦°μ§ μμ¦2
https://programmers.co.kr/learn/courses/30/lessons/77884?language=java
class Solution {
public int solution(int left, int right) {
int answer = 0;
for(int num = left; num <= right;num++){
answer += (this.calDivisor(num) == 0)? num : -num;
}
return answer;
}
public int calDivisor(int n){
int cnt = 0;
for(int i=1; i<=n ; i++){
if(n % i == 0){
cnt++;
}
}
return cnt % 2;
}
}
*μ°Έκ³ : μ κ³±μλ‘ λλ λ¨μ΄μ§λ©΄ μ½μ*
if( num % Math.squr(num) == 0 ){
// numμ μ½μ
}
λ°μν
'π μ½ν μ°μ΅μ₯' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[νλ‘κ·Έλλ¨Έμ€] μ«μ λ¬Έμμ΄κ³Ό μλ¨μ΄ (0) | 2022.05.09 |
---|---|
[νλ‘κ·Έλλ¨Έμ€] μμ£Όνμ§ λͺ»ν μ μ (0) | 2022.05.06 |
[νλ‘κ·Έλλ¨Έμ€] λ‘λμ μ΅κ³ μμμ μ΅μ μμ (0) | 2022.05.06 |
[νλ‘κ·Έλλ¨Έμ€] μ κ³ κ²°κ³Ό λ°κΈ° (0) | 2022.05.06 |
[CodeUp] python κΈ°μ΄ 100μ : #6027~ #6064 (0) | 2021.07.18 |