1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include<cstdio> int main(void) { int x,i,cnt=0,temp,r; int arr[4]; scanf("%d", &x); if (x<100) printf("%d", x); else { for (int j=100; j<=x; j++) { temp=j; if (temp==1000) break; for (i=1; temp>0; i++) { arr[i]=temp%10; temp/=10; } if (arr[3]-arr[2] == arr[2]-arr[1]) cnt++; } r=99+cnt; printf("%d", r); } return 0; } | cs |
- JAVA
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class Main{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int num = Integer.parseInt(br.readLine()); int[] arr = new int[1002]; int temp=0, r=0, cnt=0; if(num<=99) System.out.print(num); else { for (int j=100; j<=num; j++) { temp=j; if (temp==1000) break; for (int i=1; temp>0; i++) { arr[i]=temp%10; temp/=10; } if (arr[3]-arr[2] == arr[2]-arr[1]) cnt++; } r=99+cnt; System.out.println(r); } } } | cs |
'백준 1 > 수학' 카테고리의 다른 글
| [백준 10867] 중복 빼고 정렬하기 (0) | 2020.12.05 |
|---|---|
| [백준 11004] k번째 수 (0) | 2020.12.05 |
| [백준 11816] 8진수, 10진수, 16진수 (0) | 2020.12.05 |
| [백준 15552] 빠른 A+B (0) | 2020.12.05 |
| [백준 1003] 피보나치 함수 (0) | 2020.12.05 |