1 #include <cstdio>
2
3 int main()
4 {
5 int s,d;
6 while ( scanf ( "%d",&s ) != EOF )
7 {
8 scanf ( "%d",&d );
9 int k = 1;
10 int s1,d1;
11 s1 = 4 * s;
12 d1 = d;
13 for ( ; k <= 5; ++k ) // 5 种情况 ssssdssssdss,sssddsssddss,ssdddssdddss,sddddsddddsd,dddddddddddd.
14 {
15 s1 = s1 - k * d1;
16 if ( s1 <= 0 )
17 break;
18 s1 = (4 - k) * s;
19 }
20 //printf ( "%d\n",s1 );
21 if ( k <= 3 )
22 s1 = ( 12 - 2 * k ) * s - 2 * k * d;
23 else if ( k == 4 )
24 s1 = ( 12 - ( 2 * k + 1 ) ) * s - ( 2 * k + 1 ) * d;
25 if ( k == 5 || s1 <= 0 )
26 printf ( "Deficit\n" );
27 else printf ( "%d\n",s1 );
28 }
29 return 0;
30 }
31
32
题意:
每个月会给出一个财务报告:赢利或者亏空 如果赢利则赢利s,如果亏空则亏空d
(12个月都一样,只有赢利s或者亏空d两种情况)
每五个月也会给出一个报告(1~5 ,2~6 。。。)一年一共有8次这样的报告,已知这8次都报告亏空
问整年情况:如果亏空则输出Deficit,如果赢利,输出整年可能赢利的最大值;
动动笔!!!