1
//
1638 C++ Accepted 0.031 121 KB URAL
2
3 // 有趣的排列书的问题--注意实际生活中书的最后一页放在最左边
4
5 #include " stdio.h "
6 #include " stdlib.h "
7 #include " string.h "
8
9 int a, b, c, d ;
10
11 int main()
12 {
13 while ( scanf( " %d %d %d %d " , & a, & b, & c, & d ) != EOF )
14 {
15 int out = 0 ;
16 if ( c < d )
17 {
18 out = (d - c - 1 ) * (a + b + b) + b * 2 ;
19 }
20 else if ( c > d )
21 {
22 out = (c - d) * (a + b + b) + a ;
23 }
24 else
25 {
26 out = a ;
27 }
28
29 printf( " %d\n " , out ) ;
30 }
31
32 return 0 ;
33 }
2
3 // 有趣的排列书的问题--注意实际生活中书的最后一页放在最左边
4
5 #include " stdio.h "
6 #include " stdlib.h "
7 #include " string.h "
8
9 int a, b, c, d ;
10
11 int main()
12 {
13 while ( scanf( " %d %d %d %d " , & a, & b, & c, & d ) != EOF )
14 {
15 int out = 0 ;
16 if ( c < d )
17 {
18 out = (d - c - 1 ) * (a + b + b) + b * 2 ;
19 }
20 else if ( c > d )
21 {
22 out = (c - d) * (a + b + b) + a ;
23 }
24 else
25 {
26 out = a ;
27 }
28
29 printf( " %d\n " , out ) ;
30 }
31
32 return 0 ;
33 }