



import math

import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute





def 		__snake_case						(    _UpperCAmelCase = 1       ,			_UpperCAmelCase = 1				):
					"""simple docstring"""






					if isinstance(_UpperCAmelCase       ,			_UpperCAmelCase				) or isinstance(_UpperCAmelCase       ,			_UpperCAmelCase				):
										raise TypeError('inputs must be integers.'				)
					if (bit_a < 0) or (bit_a < 0):
										raise ValueError('inputs must be positive.'				)
					if (math.floor(_UpperCAmelCase				) != bit_a) or (math.floor(_UpperCAmelCase				) != bit_a):
										raise ValueError('inputs must be exact integers.'				)
					if (bit_a > 1) or (bit_a > 1):
										raise ValueError('inputs must be less or equal to 1.'				)

					# build registers
					lowercase						   =       QuantumRegister(2       ,			'qr'				)
					lowercase						   =       ClassicalRegister(2       ,			'cr'				)

					lowercase						   =       QuantumCircuit(_UpperCAmelCase       ,			_UpperCAmelCase				)

					# entanglement the qubits
					quantum_circuit.h(1				)
					quantum_circuit.cx(1       ,			0				)

					# send the information
					lowercase						   =       str(_UpperCAmelCase				) + str(_UpperCAmelCase				)

					if c_information == "11":
										quantum_circuit.x(1				)
										quantum_circuit.z(1				)
					elif c_information == "10":
										quantum_circuit.z(1				)
					elif c_information == "01":
										quantum_circuit.x(1				)
					else:
										quantum_circuit.i(1				)

					# unentangled the circuit
					quantum_circuit.cx(1       ,			0				)
					quantum_circuit.h(1				)

					# measure the circuit
					quantum_circuit.measure(_UpperCAmelCase       ,			_UpperCAmelCase				)

					lowercase						   =       Aer.get_backend('aer_simulator'				)
					lowercase						   =       execute(_UpperCAmelCase       ,			_UpperCAmelCase       ,			shots=10_00				)

					return job.result().get_counts(_UpperCAmelCase				)


if __name__ == "__main__":
		print(F"""Counts for classical state send: {superdense_coding(1,1)}""")











from __future__ import annotations





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					assert (
					    c % greatest_common_divisor(_UpperCAmelCase       ,			_UpperCAmelCase				) == 0
					)  # greatest_common_divisor(a,b) function implemented below
					((lowercase)   ,      (lowercase)   ,      (lowercase))						   =       extended_gcd(_UpperCAmelCase       ,			_UpperCAmelCase				)  # extended_gcd(a,b) function implemented below
					lowercase						   =       c / d
					return (r * x, r * y)





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase = 2				):
					"""simple docstring"""






					((lowercase)   ,      (lowercase))						   =       diophantine(_UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase				)  # Initial value
					lowercase						   =       greatest_common_divisor(_UpperCAmelCase       ,			_UpperCAmelCase				)
					lowercase						   =       a // d
					lowercase						   =       b // d

					for i in range(_UpperCAmelCase				):
										lowercase						   =       xa + i * q
										lowercase						   =       ya - i * p
										print(_UpperCAmelCase       ,			_UpperCAmelCase				)





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					if a < b:
										lowercase   ,      lowercase						   =       b, a

					while a % b != 0:
										lowercase   ,      lowercase						   =       b, a % b

					return b





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					assert a >= 0 and b >= 0

					if b == 0:
										lowercase   ,      lowercase   ,      lowercase						   =       a, 1, 0
					else:
										((lowercase)   ,      (lowercase)   ,      (lowercase))						   =       extended_gcd(_UpperCAmelCase       ,			a % b				)
										lowercase						   =       q
										lowercase						   =       p - q * (a // b)

					assert a % d == 0 and b % d == 0
					assert d == a * x + b * y

					return (d, x, y)


if __name__ == "__main__":
		from doctest import testmod

		testmod(name='''diophantine''', verbose=True)
		testmod(name='''diophantine_all_soln''', verbose=True)
		testmod(name='''extended_gcd''', verbose=True)
		testmod(name='''greatest_common_divisor''', verbose=True)






