zoukankan      html  css  js  c++  java
  • A. Ivan the Fool and the Probability Theory

    https://codeforces.com/contest/1239/problem/A

    discription

    given a (n*m) field in which every grid can be painted black and white. count the number of different situation, where every grid has at most one adjacent grid that shares the same color.

    breakthrough

    no idea. hard limitation causes headache.

    but it turns out that we should utilize the harsh contraint wisely.
    classial and direct solutions are excluded due to scope of (n,m). and once you take up looking for a pattern you will succeed

    then you will find that if you have controlled the first row you will have controlled the whole universe unless what you have in the first row is:

    • something like WBWBWBWBWBW... then the next row is either WBWBWBWBW...(totally similar) or BWBWBWBWB..(total opposite). the third row presents the same pattern but with some limitations on columns and so does the followings. so in this situations the number of ways of where the first row altermates depends on the number of ways of all situation of the first column

    apart from that, the partial answer is the number of ways of all situation of the first row except the situation mentioned above.

    add them up and you will get the answer

  • 相关阅读:
    对于git的认识
    第一篇博客
    结对编程
    对git的认识
    李叔同先生的《梦》
    51nod 1449 砝码称重
    LeetCode 21-29题解
    LeetCode 11-20题解
    LeetCode 6-10 题解
    LeetCode刷题重启博客
  • 原文地址:https://www.cnblogs.com/reshuffle/p/12543085.html
Copyright © 2011-2022 走看看