',subtitle:{text:["Loading..."],hitokoto:{enable:!0,show_author:!0,api:"https://v1.hitokoto.cn"},typing_speed:100,backing_speed:80,starting_delay:500,backing_delay:1500,loop:!1,smart_backspace:!0},text_color:{light:"#434343",dark:"#d1d1b6"},text_style:{title_size:"2.8rem",subtitle_size:"1.5rem",line_height:1.2},custom_font:{enable:!1,family:null,url:null},social_links:{enable:!0,style:"default",links:{github:"https://github.com/FrederickBun",instagram:null,zhihu:"https://www.zhihu.com/people/frederick-asyou",twitter:"https://twitter.com/FrederickAsYou",email:"i@setbun.com",bilibili:"https://space.bilibili.com/689929775?from=buntalk",facebook:"https://www.facebook.com/FrederickAsYou",youtube:"https://www.youtube.com/@Fredgg0017","fa-solid fa-train-subway":"https://www.travellings.cn/go.html","fa-solid fa-bell":"https://follow.it/buntalk?leanpub"},qrs:{weixin:null,"fa-solid fa-circle-dollar-to-slot":"https://cdn.jsdelivr.net/gh/FrederickBun/upyun-rhimgcdn@img/upload/202408110944048.png"}}},plugins:{feed:{enable:!0},aplayer:{enable:!1,type:"fixed",audios:[{name:null,artist:null,url:null,cover:null,lrc:null}]},mermaid:{enable:!0,version:"9.3.0"}},version:"2.7.2",navbar:{auto_hide:!1,color:{left:"#DCE2F1",right:"#FAF9DE",transparency:35},width:{home:"1200px",pages:"1000px"},links:{Home:{path:"/",icon:"fa-solid fa-planet-ringed"},Library:{icon:"fa-solid fa-book-sparkles",submenus:{Timeline:"/archives",Categories:"/categories",Tags:"/tags"}},Services:{icon:"fa-solid fa-server",submenus:{"Uptime status":"https://status.setbun.com/","Count Service":"https://vercount.one/","Whois Search":"https://whois.api.setbun.com/"}},About:{icon:"fa-solid fa-mug-hot",submenus:{Me:"/about",Links:"/links",Essays:"/essays",Photos:"/masonry",Subscribe:"/subscribe",Porfolio:"https://frederication.work"}}},search:{enable:!0,preload:!1}},page_templates:{friends_column:2,tags_style:"blur"},home:{sidebar:{enable:!0,position:"left",first_item:"menu",announcement:'营火,噼啪作响……
',show_on_mobile:!0,links:{Timeline:{path:"/archives",icon:"fa-regular fa-timeline"},Tags:{path:"/tags",icon:"fa-regular fa-tags"},Categories:{path:"/categories",icon:"fa-regular fa-folder-closed"},Essays:{path:"/essays",icon:"fa-regular fa-comment"},Photos:{path:"/masonry",icon:"fa-regular fa-images"},Travelling:{icon:"fa-solid fa-train-subway",path:"https://www.travellings.cn/go.html"},Subscibe:{icon:"fa-solid fa-bell",path:"/subscribe"}}},article_date_format:"auto",excerpt_length:300,categories:{enable:!0,limit:10},tags:{enable:!0,limit:10}},footerStart:"2023/2/6 03:09:13"},window.lang_ago={second:"%s seconds ago",minute:"%s minutes ago",hour:"%s hours ago",day:"%s days ago",week:"%s weeks ago",month:"%s months ago",year:"%s years ago"},window.data={masonry:!0}
Problem
题目传送门
Solution
Step1. 读题&分析
对于这道题目,我们需要根据给定的整数和确定是否可以用相同的正整数组成一个长度为的序列,使得该序列所有元素的异或结果为。
具体来说,给定一个数列的所有元素都相同,记为。那么该数列的异或结果是:
其中出现了次。由于异或的一个重要性质是,因此对于一个相同的数异或次的结果为:
因此,我们可以得出结论:
- 如果是偶数,那么异或结果只能是。所以,如果时输出
Yes
,否则输出 No
。 - 如果是奇数,那么异或结果是,因此只要可以作为数列中的元素(即是正整数),则输出
Yes
,否则输出 No
。
Step2. 代码步骤
- 输入:首先读取测试用例的数量。然后,对于每个测试用例,读取两个整数和。
- 处理:根据的奇偶性判断结果:
- 如果是偶数且为,输出
Yes
。否则输出 No
。 - 如果是奇数且为正整数,输出
Yes
。否则输出 No
。
Step3. 时间复杂度计算
因为是直接使用结论做题目,所以单次计算复杂度为,对于本题目的测试点是完全没问题的(有问题就出事了)。
Code
请遵守《洛谷社区规则》 ,重视学术诚信,不要当C玩以达成刷AC率的目的!
『FLA - I』冲云霄.cpp1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| #include <bits/stdc++.h> #define int long long #define endl "\n" #define fp(_a, _b, _c, _d) for(int _a = _b; _a <= _c; _a += _d) #define fm(_a, _b, _c, _d) for(int _a = _b; _a <= _c; _a -= _d) #define fin(_a, _b) for(int ss = 1; ss <= _a; ss ++ ) cin >> _b[ss]; #define fout(_a, _b, _c) for(int ss = 1; ss <= _a; ss ++ ) cout << _b[ss] << _c ; using namespace std;
const int N = 1e7 + 10; const int M = 2e3 + 5;
int t, n, m, k, a[N];
signed main() { "toothless. #17"; cin >> t; fp(ss, 1, t, 1) { cin >> n >> m ; if(m % 2 == 0) { if(n == 0) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { if(n > 0) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } return 0; }
|
- Title: 「题解」 『FLA - I』冲云霄
- Author: 磅豆龙
- Created at : 2024-08-03 08:35:17
- Updated at : 2024-08-21 12:56:36
- Link: https://blog.setbun.com/p/20240803.html
- License: This work is licensed under CC BY-NC-SA 4.0.