当前位置:网站首页>Cf:a. the third three number problem
Cf:a. the third three number problem
2022-07-05 13:01:00 【White speed Dragon King's review】
analysis
In the course of the game, I created the XOR distribution law , Directly put yourself speechless
First of all, we should make good use of the nature of XOR
a ^ 0 = a
a ^ a = 0
if a ^ b = c be c ^ b = a
^ There is a law of association, not a law of distribution
therefore , about a Even numbers , obviously a // 2, 0, 0 It's a set of solutions , I'm dizzy
About a It is the proof that odd numbers are not tenable
About a + b and a ^ b Proof of parity
if a + b It's me , explain a and b With the odd and even , The last one is the same , therefore a ^ b And then finally 0, therefore a ^ b Even
if a + b It's strange , explain a and b The last one is different , therefore a ^ b And then finally 1, therefore a ^ b Is odd
With the help of the above lemma , It is known that (a ^ b) + (b ^ c) + (c ^ a) = n
And then there is (a ^ b) ^ (b ^ c) = a ^ c
So the initial formula can be reduced to x + y + (x ^ y) = n
obviously n It's even
speechless
ac code
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
if n % 2 == 1:
print(-1)
else:
print(n // 2, 0, 0)
summary
Bit operation fails
Math doesn't work
边栏推荐
- SAP UI5 ObjectPageLayout 控件使用方法分享
- Introduction to the principle of DNS
- 自然语言处理从小白到精通(四):用机器学习做中文邮件内容分类
- Le rapport de recherche sur l'analyse matricielle de la Force des fournisseurs de RPA dans le secteur bancaire chinois en 2022 a été officiellement lancé.
- MySQL 巨坑:update 更新慎用影响行数做判断!!!
- Alibaba cloud SLB load balancing product basic concept and purchase process
- SAP UI5 视图里的 OverflowToolbar 控件
- Introduction to sap ui5 flexiblecolumnlayout control
- RHCSA1
- HiEngine:可媲美本地的云原生内存数据库引擎
猜你喜欢
stm32和电机开发(从架构图到文档编写)
SAP SEGW 事物码里的 ABAP Editor
[Nacos cloud native] the first step of reading the source code is to start Nacos locally
Install rhel8.2 virtual machine
I met Tencent in the morning and took out 38K, which showed me the basic smallpox
Taobao order interface | order flag remarks, may be the most stable and easy-to-use interface
What is the difference between Bi software in the domestic market
SAP ui5 objectpagelayout control usage sharing
自然语言处理系列(一)入门概述
Transactions from January 14 to 19, 2022
随机推荐
HiEngine:可媲美本地的云原生内存数据库引擎
PyCharm安装第三方库图解
以VMware创新之道,重塑多云产品力
Introduction aux contrôles de la page dynamique SAP ui5
Why is your next computer a computer? Explore different remote operations
ABAP editor in SAP segw transaction code
155. 最小栈
Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
Run, open circuit
10 minute fitness method reading notes (5/5)
Taobao order interface | order flag remarks, may be the most stable and easy-to-use interface
开发者,云原生数据库是未来吗?
Four common problems of e-commerce sellers' refund and cash return, with solutions
SAP ui5 objectpagelayout control usage sharing
Halcon 模板匹配实战代码(一)
Install rhel8.2 virtual machine
How to connect the API interface of Taobao open platform (super detailed)
Taobao product details API | get baby SKU, main map, evaluation and other API interfaces
Difference between JUnit theories and parameterized tests
What is the difference between Bi software in the domestic market