ํฐ์คํ ๋ฆฌ ๋ทฐ
๋ฐ์ํ
package test;
import java.util.Scanner;
public class Test2 {
public static void main(String[] args) {
Test2 test = new Test2();
Scanner in = new Scanner(System.in);
int n = in.nextInt();
System.out.println(test.d(n));;
}
public int d(int n){
int count = 0;
for(int i = 1 ; i <= n ; i++){
if(1<= i && i < 100){
count ++;
}else{
if(i==1000)break;
int v = i;
int temp = 0;
int[] arr = new int[3];
while(true){
if(temp==3)break;
arr[temp] = v%10;
v = v/10;
temp++;
}
if((arr[0] - arr[1]) == (arr[1] - arr[2]) ){
count++;
}
}
}
return count;
}
}
๋ฐ์ํ
'โ Algorithm ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ ๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ 1924๋ฒ] 2007๋ (0) | 2019.11.01 |
---|---|
[ ๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ 1152๋ฒ ] ๋จ์ด์ ๊ฐ์ (0) | 2019.10.29 |
[ ๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ 2941๋ฒ ] ํฌ๋ก์ํฐ์ ์ํ๋ฒณ (0) | 2019.10.28 |
๋๊ธ