fork download
  1. import java.util.*;
  2.  
  3. class Main{
  4.  
  5. public static void main(String[] args){
  6.  
  7. Scanner sc = new Scanner(System.in);
  8.  
  9. int N = sc.nextInt();
  10.  
  11. final M = N;
  12.  
  13. int power = 0;
  14.  
  15. while(N>=10){
  16.  
  17. power++;
  18.  
  19. N /= 10;
  20.  
  21. }
  22.  
  23. int ans = 0;
  24.  
  25. for(int i=1; i<=power; i++){
  26.  
  27. if(i%2 == 1){
  28.  
  29. ans += 9*Math.pow(10,i-1);
  30.  
  31. }
  32. }
  33.  
  34. if(power%2 == 1){
  35.  
  36. System.out.println(ans);
  37.  
  38. }
  39.  
  40. else{
  41.  
  42. System.out.println(ans+(M+1-1*Math.pow(N,power)));
  43.  
  44. }
  45.  
  46.  
  47. }
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:11: error: <identifier> expected
	final M = N;
	       ^
1 error
stdout
Standard output is empty