当前位置: 首页 > news >正文

买域名的网站周年庆网站要怎么做6

买域名的网站,周年庆网站要怎么做6,wordpress下载模板怎么用,网站建设东莞CF1790E Vlad and a Pair of Numbers 题解题目链接字面描述题面翻译题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1思路代码实现题目 链接 https://www.luogu.com.cn/problem/CF1790E 字面描述 题面翻译 共有 ttt 组数据。 每组数据你会得到一个正整数 xxx&…

CF1790E Vlad and a Pair of Numbers 题解

  • 题目
    • 链接
    • 字面描述
      • 题面翻译
      • 题目描述
      • 输入格式
      • 输出格式
      • 样例 #1
        • 样例输入 #1
        • 样例输出 #1
  • 思路
  • 代码实现

题目

链接

https://www.luogu.com.cn/problem/CF1790E

字面描述

题面翻译

共有 ttt 组数据。

每组数据你会得到一个正整数 xxx,你需要构造一组正整数 aaabbb,满足:

  • a+b=x×2a + b = x \times 2a+b=x×2

  • axor⁡b=xa \operatorname{xor} b = xaxorb=x,其中 xor⁡\operatorname{xor}xor 指异或。

输出你构造的 aaabbb。如有多解,任意输出一解即可。如无解,输出 −1-11

1≤t≤1041 \leq t \leq 10^41t1041≤x≤2291 \leq x \leq 2^{29}1x229。同时,你需要保证你构造的 aaabbb 满足 1≤a,b≤2301 \leq a,b \leq 2^{30}1a,b230

题目描述

Vlad found two positive numbers $ a $ and $ b $ ( $ a,b>0 $ ). He discovered that $ a \oplus b = \frac{a + b}{2} $ , where $ \oplus $ means the bitwise exclusive OR , and division is performed without rounding…

Since it is easier to remember one number than two, Vlad remembered only $ a\oplus b $ , let’s denote this number as $ x $ . Help him find any suitable $ a $ and $ b $ or tell him that they do not exist.

输入格式

The first line of the input data contains the single integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases in the test.

Each test case is described by a single integer $ x $ ( $ 1 \le x \le 2^{29} $ ) — the number that Vlad remembered.

输出格式

Output $ t $ lines, each of which is the answer to the corresponding test case. As the answer, output $ a $ and $ b $ ( $ 0 < a,b \le 2^{32} $ ), such that $ x = a \oplus b = \frac{a + b}{2} $ . If there are several answers, output any of them. If there are no matching pairs, output -1.

样例 #1

样例输入 #1

6
2
5
10
6
18
36

样例输出 #1

3 1
-1
13 7
-1
25 11
50 22

思路

根据题目 a+b=2x和aa+b=2x和aa+b=2xa xorxorxor b=xb=xb=x

我们能发现一个非常高重要的突破点a异或b流失了xa异或b流失了xa异或b流失了x
a按位与b=x/2a按位与b=x/2a按位与b=x/2
∵题目可输出任意解
a=x/2,b=x+x/2a=x/2,b=x+x/2a=x/2,b=x+x/2

但我们还要考虑一个无解的情况:
当x是奇数时,无法被2整除,无解
(x/2)按位与x!=0(x/2)按位与x!=0(x/2)按位与x!=0,有误,无解

OK,过程理完,上代码

代码实现

#include<bits/stdc++.h>
using namespace std;int t,n; 
int main(){scanf("%d",&t);while(t--){scanf("%d",&n);if(n%2==1){printf("-1\n");continue;}if(((n/2)&n)!=0){printf("-1\n");continue;}printf("%d %d\n",n/2,n/2+n);}return 0;
} 
http://www.yayakq.cn/news/791547/

相关文章:

  • app充值网站开发专业的网站制作公司哪家好
  • 网站搜索优化价格设计网站有哪些
  • 做宴会有哪些素材网站自己做动漫头像的网站
  • 哪个网站可以做空比特币肯德基网站建设的目标
  • 用户登录网站开发做爰全过程网站免费的视频教程
  • 漳州企业网站建设网站搭建 虚拟空间
  • 营销型网站建设运营软文拟发布的平台与板块
  • 如何建立自已的购物网站户外网站模板
  • 成都市网站建设费用及企业敬请期待图片高清大图
  • 网站内容建设培训通知网站模板哪个好用
  • 下列软件属于网站开发工具的是做网站网页需要什么
  • 企业网站建设浩森宇特无极电影网在线观看完整版
  • hao爱做网站wordpress建站需要多大内存
  • c2c网站建设要多少钱wordpress文章链接
  • 好三网网站做卡盟网站赚钱吗
  • 淘宝网站代理怎么做的小红书3000粉丝推广报价多少
  • 花20亿做网站如何在自己建设的网站上发表文章
  • 电子商务网站的建设 论文一般网站的费用
  • 自己的网站什么做优化中国新闻最新消息大事件
  • 网站跟app区别江西省建设网站
  • 建站的网站浙江建设继续教育学院网站
  • 商务网站建设用的是什么软件网站重建
  • 网站自动生成系统开发者应用
  • 自助下单网站手机便宜电商网站建设
  • 装修网站合作莱芜一中官网
  • 自己做的网站如何管理郴州网站建设哪家公司好
  • 北京网站定制报价好的界面建筑网站
  • 网站响应式图片切换代码爱客是什么牌子档次
  • 农村自建房设计网站南沙做网站
  • 淳安千岛湖建设集团网站常见的网站空间有哪些