@TOC
# 前言 距离蓝桥杯还剩短短俩个月的时间, 最后的号角已经吹响,没有撤退可言! 最后的时间如果要彻底的搞懂比赛所需的算法,很难,但是最后的成绩可能也不是很好,所以我们用真题+解析的形式来做最后的冲刺! 话不多说,开启我们的第四天! # 2016a 网友年龄 ```c #include using namespace std; int main() { int c = 0; for (int i = 28; i < 100; i++) { int x = i / 10; int y = i % 10; if (i - 27 == y * 10 + x) c++; } cout << c << endl; return 0; } ``` # 2016a 生日蜡烛 ```cpp #include using namespace std; int main() { for (int i = 1; i < 100; i++) { int sum = 0; for (int j = i; j < 100; j++) { sum += j; if (sum == 236) { cout << i; break; } } } return 0; } ``` # 2016a 方格填数 ```cpp //转换为全排列问题,有点像八皇后问题 //将10个格子按照顺序来放成一个一维数组,全排列,然后进行判断 #include #include using namespace std; int main() { int num[10] = { 0,1,2,3,4,5,6,7,8,9 }; int ans = 0; do { if (abs(num[0] - num[1]) == 1 || abs(num[0] - num[3]) == 1 || abs(num[0] - num[4]) == 1 || abs(num[0] - num[5]) == 1 || abs(num[1] - num[2]) == 1 || abs(num[1] - num[4]) == 1 || abs(num[1] - num[5]) == 1 || abs(num[1] - num[6]) == 1 || abs(num[2] - num[5]) == 1 || abs(num[2] - num[6]) == 1 || abs(num[3] - num[4]) == 1 || abs(num[3] - num[7]) == 1 || abs(num[3] - num[8]) == 1 || abs(num[4] - num[5]) == 1 || abs(num[4] - num[7]) == 1 || abs(num[4] - num[8]) == 1 || abs(num[4] - num[9]) == 1 || abs(num[5] - num[6]) == 1 || abs(num[5] - num[8]) == 1 || abs(num[5] - num[9]) == 1 || abs(num[6] - num[9]) == 1 || abs(num[7] - num[8]) == 1 || abs(num[8] - num[9]) == 1) continue; else ans++; } while (next_permutation(num, num + 10)); cout << ans << endl; return 0; } ``` # 最后 今天我们就刷这几个题,题不算难,但是都是真题,坚持下去,时间会给出答案!