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

贵阳品牌网站建设公司哪个网站是免费的

贵阳品牌网站建设公司,哪个网站是免费的,网站开发可能性分析,免费建立微信网站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.hkea.cn/news/7096/

相关文章:

  • 中小学图书馆网站建设成都网站seo诊断
  • 网站 地区加关键词青岛百度seo
  • 网站代理服务器设置江东怎样优化seo
  • 红河州做网站中国十大企业培训机构排名
  • 枣庄网站建设价格广告推广平台哪个好
  • 国外设计网站网址电商网站怎样优化
  • 南宁推广软件宁波优化推广找哪家
  • play商店天津百度优化
  • 东莞网站建设-南城石佳济南网站优化排名
  • 注册网站入口深圳网站优化培训
  • 足球比赛直播在线观看seo咨询解决方案
  • 网站 建设 函宁波seo关键词
  • 做网站的论坛快速建站工具
  • 做网站销售的技巧热门职业培训班
  • 专业做网站的公司有哪些比百度好用的搜索引擎
  • 做网站有什么好处吗保定seo推广
  • wordpress数据库主机名seo自然搜索优化排名
  • 歌词插件wordpress杭州百度seo
  • 高中信息技术网站建设怎么在百度发布个人简介
  • 电子商务官网首页优化大师优化项目有哪些
  • 给朋友网站做宣传怎么写重庆seo推广
  • 如何查找网站备案软件开发网站
  • 基于b s结构做的网站游戏推广公司靠谱吗
  • 网站建设服务器维护内容旺道seo推广效果怎么样
  • WordPress加速优化方案seo推广优化的方法
  • 家具网站建设方案关键词优化推广策略
  • 高端大气企业网站2345网址导航下载
  • 酒店网站制作公司西安关键词seo公司
  • 网站后台根据前端做吗百度流量推广项目
  • 做健身类小程序的网站关键词搜索排名查询