AWaterStation(abc305a) 题目大意 给定一个数字\(x\),输出一个数字,它是最接近\(x\)的\(5\)的倍数。 解题思路 令\(y=x\%5\),如果\(y\leq2\),那答案就是\(xy\),否则就是\(x+5y\)。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); intx; cin>>x; intmod=x%5; if(m...

  vFIdz9ThwdPa   2023年11月01日   48   0   0 算法与数据结构

AEcho(abc306a) 题目大意 给定一个字符串,将每个字符输出两次。 解题思路 模拟即可。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); intn; strings; cin>>n>>s; for(auto&i:s) cout<<i<<i; cout<<'\n'; return0; } ...

  vFIdz9ThwdPa   2023年11月01日   104   0   0 算法与数据结构

在算法竞赛中,写题解是我们不可或缺的一部分。它不仅能够帮助我们整理思路、总结经验,还可以与他人分享我们的解题思路和代码实现。然而,写一篇较完备的题解往往非常繁琐,需要手动复制粘贴题目链接、题号和AC代码,这不仅费时费力,还容易分散我们的注意力,因为我们写题解的核心内容是对题目的理解以及怎么解决这个问题的。为了解决这个问题,我编写了一个脚本,帮助我省去了这些繁琐的操作,可以专注于解题思路的书写,从abc278开始我就用该脚本进行编写题解。该脚本可在github中获取。使用方法详见README。 为什么要写题解? 写题解有许多好处。首先,它能够帮助我们深入理解题目,梳理解题思路,加深对算法和数据结...

  vFIdz9ThwdPa   2023年11月01日   330   0   0 算法与数据结构

ASashaandArrayColoring(CF1843A) 题目大意 给定一个数组,给每个元素涂色。求最大的代价。 代价为每个颜色的代价和。 每个颜色的代价为涂了该颜色的元素的极差。 解题思路 因为是极差,每个元素要么对答案有正的贡献,要么有负的贡献,要么无贡献。且正负贡献的个数要相同。 因为要最大值,自然就是想有正贡献的是最大的那些数,负贡献的是最小的那些数。 因此答案就是最大的那一半的和\(-\)最小的那一半的和。奇数的话中间多出来的一个无贡献。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong;...

  vFIdz9ThwdPa   2023年11月01日   53   0   0 算法与数据结构

AWeeklyRecords(abc307A) 题目大意 给定\(n\)周每天的散步量,求每周七天的散步量的和。 解题思路 累计求和即可。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); intn; cin>>n; while(n--){ intsum=0; for(inti=0;i<7;i){ inta; cin>>a; sum+=a...

  vFIdz9ThwdPa   2023年11月01日   42   0   0 算法与数据结构

这几天在收拾东西搬家,先附上代码,晚点补上题解补完了感觉这次FG都写不太明白 ANewScheme(abc308A) 题目大意 给定八个数,问是否满足以下要求: 不严格升序 每个数在\(100\sim675\)之间 每个数都是\(25\)的倍数 解题思路 依次对每个数判断是否符合这三个条件即可。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); array&l...

  vFIdz9ThwdPa   2023年11月01日   28   0   0 算法与数据结构

感觉F写了个乱搞做法 ANine(abc309A) 题目大意 给定一个\(3\times3\)的网格,以及两个数字。 问这两个数字是否水平相邻。 解题思路 求出两个数字的横纵坐标,看是否横坐标相同,纵坐标差一即可。 读题不仔细,开题就WA了。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); inta,b; cin>>a>>b; -a,-...

  vFIdz9ThwdPa   2023年11月01日   31   0   0 算法与数据结构

感觉F又双叒叕写复杂了 AOrderSomethingElse(abc310A) 题目大意 点杯咖啡,要\(p\)元,但可以用一个优惠券,使得咖啡只要\(q\)元,但你需要额外购买\(n\)个商品中(价格为\(a_i\))的一个。 问点杯咖啡的最小价格。 解题思路 考虑直接买还是使用优惠券,使用优惠券的话就选\(n\)个商品中价格最小的。 两种情况取最小即可。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); ...

  vFIdz9ThwdPa   2023年11月01日   38   0   0 算法与数据结构

AFirstABC(abc311A) 题目大意 给定一个字符串,问最短的一个前缀,包含ABC这三个字符。 解题思路 注意到这个前缀的末尾字母一定是这三个字母中的一个,因此答案就是这三个字母出现位置最早的最大值。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); intn; strings; cin>>n>>s; cout<<max...

  vFIdz9ThwdPa   2023年11月01日   27   0   0 算法与数据结构

AChord(abc312A) 题目大意 给定一个长度为\(3\)的字符串,问是不是ACE,BDF,CEG,DFA,EGB,FAC,GBD中的一个。 解题思路 依次判断即可。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); set<string>q{"ACE","BDF","CEG","DFA","EGB","FAC","GBD"}; stringa;...

  vFIdz9ThwdPa   2023年11月01日   26   0   0 算法与数据结构

貌似这次很难,还好去吃烧烤了发现原来G就是个类欧几里德算法,参考abc283ex,更了个G AToBeSaikyo(abc313A) 题目大意 给定\(n\)个数\(a_i\),问第一个数要成为唯一的最大的数,应该加多少。 解题思路 找到后面的最大的数\(m\),答案就是\(\max(0,m+1a_0)\)。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); i...

  vFIdz9ThwdPa   2023年11月01日   59   0   0 算法与数据结构

怎么好多陌生单词审核怎么这么逆天,半小时还没审完 A3.14(abc314A) 题目大意 给定\(pi\)的值以及数\(n\),要求保留\(n\)位小数输出,不四舍五入。 解题思路 字符串形式储存然后截取末尾即可。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); stringpi="3." "1415926535897932384626433832795028...

  vFIdz9ThwdPa   2023年11月01日   48   0   0 算法与数据结构

咕咕咕,总力战还没打,凹不过卷狗,躺了.jpg AFullMoon(abc318A) 题目大意 给定\(n,m,p\),问有多少个\(i\)满足\(0<m+pi\leqn\) 解题思路 减去初始的\(m\),剩下的就是看\(p\)的倍数个数。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); intn,m,p; cin>>n>>m&...

  vFIdz9ThwdPa   2023年11月01日   37   0   0 算法与数据结构

ALegendaryPlayers(abc319A) 题目大意 给定rating前10的选手名字和对应分数。 给定名字,问对应分数。 解题思路 复制一下,建个数组,然后一个一个判断即可。Python更好写一点。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; vector<string>s={"tourist3858","ksun483679","Benq3658", "Um_nik3648","apiad3638","Stonefeang3630", "ecnerwala3613","...

  vFIdz9ThwdPa   2023年11月01日   60   0   0 算法与数据结构

ALeylandNumber(abc320A) 题目大意 给定\(a,b\),输出\(a^b+b^a\)。 解题思路 因为数不超过\(10\),可以直接用pow计算然后转成\(int\)。不会有精度损失。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); inta,b; cin>>a>>b; cout<<int(pow(a,b)+...

  vFIdz9ThwdPa   2023年11月01日   47   0   0 算法与数据结构

100+100+100+100+60=460 坐标变换(其一) 题目大意 给定\(n\)个操作,每个操作将坐标\((x,y)\)变为\((x+dx,y+dy)\)。 给定\(m\)个点,问这\(m\)个点经过这\(n\)次操作变换后的坐标。 解题思路 注意到操作是可合并的,因此可以先将这\(n\)个操作合并成一个操作,然后对每个点都经过这个操作变换即可,时间复杂度为\(O(n+m)\)。 本题\(n,m\)只有\(100\),也可以\(O(nm)\)依次对每个点进行操作变换。 神奇的代码 include<bits/stdc.h> usingnamespacestd; int...

  vFIdz9ThwdPa   2023年11月01日   115   0   0 算法与数据结构

A321-likeChecker(abc321A) 题目大意 给定一个数,问从高位到低位,数字是不是递减的。 解题思路 可以以字符串读入,然后依次判断即可。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); strings; cin>>s; autook=[&](){ for(inti=0;i<s.size()1;i){ if(s[i+1]...

  vFIdz9ThwdPa   2023年11月01日   44   0   0 算法与数据结构

AFirstABC2(abc322A) 题目大意 给定一个字符串,找到最先出现ABC的位置。 解题思路 直接查找判断即可。 神奇的代码 include<bits/stdc.h> usingnamespacestd; usingLL=longlong; intmain(void){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); intn; strings; cin>>n>>s; intpos=s.find("ABC"); if(posstring::npos) pos=-2; cout<&...

  vFIdz9ThwdPa   2023年11月01日   55   0   0 算法与数据结构
关注 更多

空空如也 ~ ~

粉丝 更多

空空如也 ~ ~