
풀이
- 문제에서 1000보다 작은수라 했으니 3자리의 각자리를 구해서 뒷수 - 앞수 ( 공차 ) 두개를 비교해서 같다면 같은 공차로된 수열
- 이제 12월말🙄 열심히 달려보자
package problem_solving.math;
import java.util.Scanner;
public class BaekJoon_1065 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.next());
int cnt = 0 ;
if( n < 100 ) {
cnt = n ;
System.out.println(cnt);
return ;
}
cnt = 99 ;
for(int i= 100 ; i <= n ; i++) {
int a = i / 100 ;
int b = (i / 10) % 10 ;
int c = i % 10 ;
if( (c-b) == (b-a)) {
cnt++;
}
}
System.out.println(cnt);
}
}