[uva1588]Kickdown
2016-03-14 20:20
316 查看
注意事项
1.一定要注意分析的方法,不要陷入列举有什么符合,而尽量先考虑什么不行,排除就好。 2.三个错误点 1.上下不一定是上长下短。 2.可以在板子里面也可以有一部分到外面 3.可以向左伸,也可以向右伸。
心得体会
一定要反向思维,看看什么不行。直接列举实在太难想全。渣渣代码
#include <stdio.h> #include <string.h> char topLineT[1000], bottomLineT[1000]; void check(void); int main(void) { while (gets(bottomLineT)) { gets(topLineT); check(); } return 0; } void check(void) { int lenTop = strlen(topLineT), lenBottom = strlen(bottomLineT); char topLine[1000], bottomLine[1000]; if (lenTop > lenBottom) { strcpy(topLine, bottomLineT); strcpy(bottomLine, topLineT); int temp = lenTop; lenTop = lenBottom; lenBottom = temp; } else { strcpy(topLine, topLineT); strcpy(bottomLine, bottomLineT); } //不伸出去 for (int count1 = 0; count1 <= lenBottom - lenTop; count1++) { for (int count2 = 0; count2 <= lenTop; count2++) { if (bottomLine[count1 + count2] + topLine[count2] >= 2 * '2') { break; } if (count2 == lenTop) { printf("%d\n", lenBottom); return; } } } //伸出去 for (int count1 = 1; count1 < lenTop; count1++) { for (int count2 = 0; count2 + count1 <= lenTop; count2++) { if (topLine[count1 + count2] + bottomLine[count2] >= 2 * '2') { break; } if (count2 + count1 == lenTop) { printf("%d\n", count1 + lenBottom); return; } } for (int count2 = 0; count1 + count2 <= lenTop; count2++) { if (topLine[lenTop - count1 - count2] + bottomLine[lenBottom - count2] >= 2 * '2') { break; } if (count1 + count2 == lenTop) { printf("%d\n", count1 + lenBottom); return; } } } printf("%d\n", lenBottom + lenTop); return; }
相关文章推荐
- 1.10055 - Hashmat the brave warrior
- 2.10071 - Back to High School Physics
- 3.458 - The Decoder
- 4.694 - The Collatz Sequence
- 6.494 - Kindergarten Counting Game
- 7.490 - Rotating Sentences
- 8.414 - Machined Surfaces
- 9.488 - Triangle Wave
- A.457 - Linear Cellular Automata
- B.489 - Hangman Judge
- C.445 - Marvelous Mazes
- 1.10494 - If We Were a Child Again
- 2.424 - Integer Inquiry
- 3.10250 - The Other Two Trees
- 5.465 - Overflow
- 6.113 - Power of Cryptography
- 7.10161 - Ant on a Chessboard
- 8.621 - Secret Research
- 9.401 - Palindromes
- A.537 - Artificial Intelligence?