洛谷笔记0001
今日(和昨日)过招
- P1000 超级玛丽游戏
- P1001 A+B Problem
- P1003 三连击
- P1307 数字反转
- P1035 级数求和
- P1046 陶陶摘苹果
- P1047 校门外的树
- P1085 校门外的树
- P1089 津津的储蓄计划
- P1151 子数整数
难题
难题是 P1089 津津的储蓄计划;题目根本理不清头绪,点进“题目反馈”发现一个修正,这个版本好多了。
原始代码:
1 |
|
经过自(迪)我(普)找(西)错(克),我找出了错误:
- bro的按张保存的制度太™复杂了
- bro忘记输出负数月份了(没看题)
可能还有忘记了的错误,反正bro重写了一遍,如下: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
30
31
32
33
using namespace std;
int main() {
int budget[12];
for (int i = 0; i < 12; i++) {
cin >> budget[i];
}
int hand = 0;
int mom = 0;
for (int i = 0; i < 12; i++) {
hand += 300;
if (hand < budget[i]) {
cout << "-" << i + 1 << endl;
return 0;
}
int left = hand - budget[i];
if (left >= 100) {
int save = (left / 100) * 100;
mom += save;
hand = left - save;
} else {
hand = left;
}
}
int total = mom * 1.2 + hand;
cout << total << endl;
return 0;
}
得到的经验
- 永远不要给一个题目乱换单位
- 别™整太复杂
- int除一下再乘回来可以向下取整
