aboutsummaryrefslogtreecommitdiff
path: root/other/ways_to_paint_nx3_grid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/ways_to_paint_nx3_grid.cpp')
-rw-r--r--other/ways_to_paint_nx3_grid.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/other/ways_to_paint_nx3_grid.cpp b/other/ways_to_paint_nx3_grid.cpp
new file mode 100644
index 0000000..b661af8
--- /dev/null
+++ b/other/ways_to_paint_nx3_grid.cpp
@@ -0,0 +1,20 @@
+#include "leetcode.h"
+
+class Solution {
+public:
+ int numOfWays(int n) {
+ long a = 6, b = 6, c, d, mod = 1e9 + 7;
+ for (int i = 1; i < n; ++i) {
+ c = a * 3 + b * 2;
+ d = a * 2 + b * 2;
+ a = c % mod;
+ b = d % mod;
+ }
+ return (a + b) % mod;
+ }
+};
+
+int main() {
+ Solution obj;
+ cout << obj.numOfWays(1);
+}