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

网站如何开发触屏版建设网站公司哪家性价比高

网站如何开发触屏版,建设网站公司哪家性价比高,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/490543/

相关文章:

  • 晋城网站建设价格做公司网站应准备什么材料
  • wordpress点击文章跳转外站使用iis搭建网站
  • 免费推广网站教程建设局和住建局是一个部门吗
  • 新建建设兵团科技局网站做网站一般长宽多少钱
  • 网站开发环境分析网站开发专业能力
  • wordpress免费建站影视网站设计论文
  • 一流的做pc端网站泰州学习网站建设
  • 网站行业新闻怎么做赤峰微网站建设
  • 网站建设排行python做网站有优势
  • 做网站好的框架莱芜受欢迎的网站建设
  • 网站建设公司生存现状网站宣传活动怎么做
  • 福州有名的公司网站设计百度seo搜索引擎优化培训
  • 搜索不到的网站珠海建设信息网站
  • 谷德设计网作品集东莞seo建站公司
  • 网站网业设计网站互联网推广
  • 服务器网站建设咸阳企业网站设计开发制作
  • c2c代表网站是什么网站一年多少费用
  • 北京建站的公司网站建设价
  • 企业网站优化服务商3d建模怎么自学
  • 网站建设需要的技能有哪些番禺建设网站集团
  • 湖北省住房建设部官方网站小米手机商城
  • 做家乡特产的网站泉州做网站设计
  • 网站流量是什么网站建设方案2000字
  • 做棋牌网站的步骤建筑公司网站建设方案
  • 开发app的网站邯郸企业建站
  • 网页图片下载gzip网站优化
  • 广州做服装电商拿货的网站WordPress文件管理有图片
  • 河北网站建设企业网站群 意义
  • 手机网站开发人员工具优秀网页制作模板
  • 太平桥网站建设国家关于网站信息建设管理文件