首页 > 其他分享 >CF1699A The Third Three Number Problem

CF1699A The Third Three Number Problem

时间:2023-04-26 22:33:23浏览次数:41  
标签:题意 Third 符号 CF1699A Three 异或 Problem

题意简述

构造出一个三元组a,b,c使得(a ⊕ b)+(a ⊕ c)+(b ⊕ c) = n,若无解输出-1。
符号 ⊕ 的意思为异或

个人分析

首先要了解异或符号的性质:
1,x⊕0=x
2,x⊕x=x
根据异或符号的性质可以得到一下构造:
a=b=0,c=n/2
c=0,a=b=n/2

通过上述可以发现答案都是偶数
所以若n为奇则无解

AC代码

void solved()
{
    int n;
    cin >> n;
    
    if(n&1)
        cout << -1 << endl;
    else
        cout << n/2 << ' ' << 0 << ' ' << 0 << endl;
}

题后分析

这道题主要了解符号 ⊕ 的性质并通过题意和样例要清楚这道题的构造

标签:题意,Third,符号,CF1699A,Three,异或,Problem
From: https://www.cnblogs.com/200312202218s/p/17357126.html

相关文章

  • 「CF1188E」Problem from Red Panda
    题目点这里看题目。给定一个长度为\(k\)的非负整数序列\(a\)。你可以对于\(a\)做如下操作任意次:选定\(1\lej\lek\),满足除了\(a_j\)外\(a\)中其它数都为正。而后,令\(a_j\)加上\(k-1\),令除了\(a_j\)外\(a\)中其它数减去\(-1\)。(这样一次操作被称为“操......
  • FZU Problem 1894 志愿者选拔 单调队列
    题目:http://acm.fzu.edu.cn/problem.php?pid=1894题意:ProblemDescription世博会马上就要开幕了,福州大学组织了一次志愿者选拔活动。参加志愿者选拔的同学们排队接受面试官们的面试。参加面试的同学们按照先来先面试并且先结束的原则接受面试官们的考查。面试......
  • Three.js教程:顶点索引复用顶点数据
    推荐:将NSDT场景编辑器加入你3D工具链其他工具系列:NSDT简石数字孪生顶点索引复用顶点数据通过几何体BufferGeometry的顶点索引属性BufferGeometry.index可以设置几何体顶点索引数据,如果你有WebGL基础很容易理解顶点索引的概念,如果没有也没有关系,下面会通过一个简单的例子形象说......
  • Three.js教程:Face3对象定义Geometry的三角形面
    推荐:将NSDT场景编辑器加入你的3D工具链其他系列工具:NSDT简石数字孪生Face3对象定义Geometry的三角形面几何体Geometry的三角面属性geometry.faces和缓冲类型几何体BufferGeometry顶点索引属性BufferGeometry.index类似都是顶点位置数据的索引值,用来组织网格模型三角形的绘制。......
  • 2014 Pacific Northwest Region Programming Contest—Division 2 Problem U — lim
    Incollegefootball,manydifferentsourcescreatealistoftheTop25teamsinthecountry.Sinceit’ssubjective,theselistsoftendiffer,butthey’reusuallyverysimilar.Yourjobistocomparetwooftheselists,anddeterminewheretheyaresimi......
  • XI Samara Regional Intercollegiate Programming Contest Problem J. Parallelogram
    Therearensticks,thei-thofwhichhaslengthai.Alexwantstoassemblefromthemasmanyparallelogramsaspossiblesimultaneously,witheachstickusedatmostinoneparallelogram.Whatmaximalnumberofparallelogramsisitpossibletoassembl......
  • ECNA 2017 Problem J: Workout for a Dumbbell 模拟
    JimRatthasjustjoinedalocalfitnesscenter.He’sespeciallyexcitedaboutasequenceof10machinesthathecyclesthroughthreetimesforhisworkout.Hehasafixedtimewhichhespendsoneachmachine,aswellasafixedrecoverytimeafterusin......
  • XI Samara Regional Intercollegiate Programming Contest Problem E. Substring Re
    Twostringssandtofthesamelengtharegiven.Determinewhetheritispossibletomaketfromsusingexactlyonereverseofsomeitssubstring.InputThefirstlinecontainsthestrings,andthesecond—thestringt.Bothstringshavethesamel......
  • XI Samara Regional Intercollegiate Programming Contest Problem L. Queries on a
    Astringsisgiven.Alsothereisastringp,andinitiallyitisempty.Youneedtoperformqoperationsofkind«addalettertotheendofthestringp»and«removealetterfromtheendofthestringp»,andafterperformingeachoperationyoumu......
  • XI Samara Regional Intercollegiate Programming Contest Problem K. Video Reviews
    Thestudio«LodkaGaming»isengagedinadvertisingoftheirnewgame«.C.O.N.T.E.S.T:UnexpectedBehaviour».Thestudio’smarketerisplanningtocommunicatewithnvideobloggersonebyone(inthepredeterminedorder,startingfromthe1-standend......