Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
的项目a是_1或1。
a
_1
1
a =: 1 _1 _1 1 _1
有 3 个符号变化a:
1, -1, -1, 1, -1 Λ Λ Λ here and here
我如何无循环地计算它们?
您将它们与 配对2 v\,检查它们是否不同~:/并求和+/:
2 v\
~:/
+/
+/ 2 ~:/\ a 3 2 ~:/\ 1 1 1 _1 _1 _1 1 _1 1 0 0 1 0 0 1 1 1 +/2 ~:/\ 1 1 1 _1 _1 _1 1 _1 1 4
编辑
或者,您可以排列削减}:和斩首并比较它们}.,a但这显然效率较低。
}:
}.
+/(}: ~: }.) a
如果数字可以不是 1 和 _1,
2 ~:&*/\ _2 4 3 _1 _3 1 1 0 1 0 1