7-1
import java. util. Scanner;
public class S7_01 {
static int n, ans = 0 , tem = 1 ;
public static void main ( String[ ] args) {
Scanner sc = new Scanner ( System. in) ;
n = sc. nextInt ( ) ;
for ( int i = 1 ; i <= n; i++ ) {
tem = tem * 2 ;
ans += tem;
}
System. out. println ( "result = " + ans) ;
}
}
7-2
import java. util. Scanner;
public class S7_02 {
public static void main ( String[ ] args) {
Scanner sc = new Scanner ( System. in) ;
String str = sc. nextLine ( ) ;
System. out. println ( Long. parseLong ( str. substring ( 0 , 8 ) , 2 ) + "." + Long. parseLong ( str. substring ( 8 , 16 ) , 2 ) + "."
+ Long. parseLong ( str. substring ( 16 , 24 ) , 2 ) + "." + Long. parseLong ( str. substring ( 24 , 32 ) , 2 ) ) ;
}
}
7-3
import java. util. Scanner;
public class S7_03 {
static char [ ] rec;
public static void main ( String[ ] args) {
Scanner sc = new Scanner ( System. in) ;
rec = sc. nextLine ( ) . toCharArray ( ) ;
boolean f = true ;
for ( int i = 0 ; i < rec. length; i++ ) {
if ( isNum ( rec[ i] ) ) {
while ( i < rec. length && isNum ( rec[ i] ) ) System. out. print ( rec[ i++ ] ) ;
i-- ;
System. out. println ( ) ;
} else if ( rec[ i] == '-' || rec[ i] == '+' ) {
f = true ;
if ( i - 1 < 0 || ( ! isNum ( rec[ i - 1 ] ) && rec[ i - 1 ] != ')' ) ) {
f = false ;
}
if ( f) {
System. out. println ( rec[ i] ) ;
} else {
System. out. print ( rec[ i] ) ;
}
} else {
System. out. println ( rec[ i] ) ;
}
}
}
static boolean isNum ( char c) {
return c >= '0' && c <= '9' || c == '.' ;
}
}
7-4
import java. util. Scanner;
public class S7_04 {
static long N;
public static void main ( String[ ] args) {
Scanner sc = new Scanner ( System. in) ;
N = sc. nextLong ( ) ;
if ( N == 1 ) {
System. out. println ( N + "=1" ) ;
return ;
}
System. out. print ( N + "=" ) ;
for ( int i = 2 ; N != 1 ; i++ ) {
int ans = 0 ;
while ( N % i == 0 ) {
N /= i;
ans++ ;
}
if ( ans == 1 ) {
System. out. print ( i) ;
System. out. print ( N == 1 ? "" : "*" ) ;
} else if ( ans > 1 ) {
System. out. print ( i + "^" + ans) ;
System. out. print ( N == 1 ? "" : "*" ) ;
}
}
}
}
7-5
import java. util. Scanner;
public class S7_05 {
static long [ ] left = new long [ 93 ] ;
static long [ ] right = new long [ 93 ] ;
public static void main ( String[ ] args) {
Scanner sc = new Scanner ( System. in) ;
int n = sc. nextInt ( ) ;
left[ 1 ] = left[ 2 ] = right[ 2 ] = 1 ;
for ( int i = 3 ; i <= 92 ; i++ ) {
left[ i] = right[ i - 1 ] + right[ i - 2 ] ;
right[ i] = left[ i - 1 ] + left[ i - 2 ] ;
}
System. out. println ( left[ n] ) ;
}
}