LoginSignup
0
0

More than 3 years have passed since last update.

blueqatで量子ゲート その3

Last updated at Posted at 2019-05-14

概要

blueqatで量子ゲートやってみた。
半加算器作ってみた。三日、掛かった。

半加算器

a b carry c
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0

han.jpg

サンプルコード

c0 = Circuit(4).h[ : 2].cx[1, 3].cx[0, 3].ccx[0, 1, 2].m[:].run(shots = 100)
for cnt in c0:
    print("{} + {} = {}".format(int(cnt[0], 2), int(cnt[1], 2), int(cnt[2 : 4], 2)))

結果

1 + 1 = 2
0 + 1 = 1
1 + 0 = 1
0 + 0 = 0

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0