03 2025 档案
摘要:/* Migrated from Lutece 300 木杆上的蚂蚁 Description 在一根细木杆上,有一些速度相同蚂蚁,它们有的往左走,有的往右走,木杆很细,只允许一只蚂蚁通过,所以当两只蚂蚁碰头的时候,它们会掉头继续前进,直到走出边界,掉下木杆。 已知木杆的长度和每只蚂蚁的名字、位置和初
阅读全文
摘要:/* Migrated from Lutece 24 8球胜负(eight) Description 8球是一种台球竞赛的规则。台面上有7个红球、7个黄球以及一个黑球,当然还有一个白球。 对于本题,我们使用如下的简化规则:红、黄两名选手轮流用白球击打各自颜色的球,如果将该颜色的7个球全部打进, 则这
阅读全文
摘要:/* Migrated from Lutece 2015 质因子分解 Description 读入一个自然数n, 将n分解为质因子连乘的形式输出. Input 有多组测试数据. 输入的第一行是整数T(0<T<=10000), 表示测试数据的组数. 每一组测试数据只有一行, 由待分解的自然数n构成.
阅读全文
摘要:/* Migrated from Lutece 1936 最长回文子串 Description 读入一个全由小写英文构成的字符串, 求出其中最长的回文子串. 回文串是指正着看和倒着看相同, 如abba和yyxyy. Input 有多组测试数据。第一行是整数T (T <= 100),表示测试数据的组数
阅读全文
摘要:/* Migrated from Lutece 1939 能否被3整除2 Description 有数列定义为:F(0) = a, F(1) =b,F(n) = F(n-1)+F(n-2), 且0 < a < b < 20.现给出a, b, n,请问F(n)能否被3整除. Input 有多组测试数据
阅读全文
摘要:/* Migrated from Lutece 1967 今天是第几天 Description 任给三个用一个空格隔开的整数,依次表示年、月、日,说出它是今年的第几天。定义该年的第1天是1月1日。 Input 有多组测试数据.输入的第一行是整数T(1<=T<=200), 表示随后测试数据的组数. 每
阅读全文
摘要:/* Migrated from Lutece 1937 猴子选大王 Description 在m只猴子聚在一起选大王, 商定规则如下: 大家围成一圈, 按顺时针从1编号, 第一次从编号为1的开始报数, 以后循环进行, 当报到n时退出圈子, 下一只则重新从1开始报数, 圈子中剩下的最后一只猴子则为大
阅读全文
摘要:/* Migrated from Lutece 1935 旋转字符矩阵 Description 读入一个n*n的字符矩阵, 绕矩阵中心顺时针旋转90度并输出结果. Input 有多组测试数据。第一行是整数T (T <= 100),表示测试数据的组数,随后有T组测试数据。每一组测试数据的第一行是正号数
阅读全文
摘要:/* Migrated from Lutece 1906 开灯问题 Description 有n盏灯, 编号为1~n. 第1个人把所有灯打开, 第2个人按下所有编号为2的倍数的开关(这些灯将被关掉), 第3个人按下所有编号为3的倍数的开关(其中关掉的灯将被打开, 开着的灯将被关闭), 依此类推. 一
阅读全文
摘要:// /* // Migrated from Lutece 1893 排列问题 // Description // 读入两个非负大整数,判断其中一个是否能由另一个大整数内的数字重新排列得到。 // Input // 有多组测试数据。输入的第一行是整数T(1<=T<=200),表示随后有T组测试数据。
阅读全文
摘要:/* Migrated from Lutece 1888 跳水打分问题 Description 运动员跳水时,有n个评委打分,分数为10分制,且有两位小数。得分规则为:去掉最高分和最低分,求剩下分数的平均值,就是运动员的最终得分。 Input 有多组测试数据。第一行是整数T (T <= 100),表
阅读全文
摘要:/* Migrated from Lutece 1886 中间数 Description 从标准输入设备读入三个整数a、b、c,找出中间数并输出。 中间数定义为: 若三数不相等,则第2大的数是中间数;若有两个数相等,则最大数作为中间数。 Input 第一行是T(T<=10),表明后面有T组测试数据,
阅读全文
摘要:''' RGB To Hex Conversion https://www.codewars.com/kata/513e08acc600c94f01000001/train/python 255, 255, 255 --> "FFFFFF" 255, 255, 300 --> "FFFFFF" 0,
阅读全文
摘要:# codewars,Calculating with Functions ''' seven(times(five())) # must return 35 four(plus(nine())) # must return 13 eight(minus(three())) # must retur
阅读全文
摘要:# https://www.codewars.com/kata/51ba717bb08c1cd60f00002f/solutions/python?filter=all&sort=best_practice&invalids=false # Range Extraction def solution
阅读全文
摘要:''' codewars,Tic-Tac-Toe Checker,525caa5c1bf619d28c000335 ''' def is_solved(board): isFull = True for i in range(3): if board[i][0]==0 or board[i][1]=
阅读全文
摘要:''' The observed PIN,https://www.codewars.com/kata/5263c6999e0f40dee200059d/train/python ''' def get_pins(observed): adjacent = { '0' : '08', # 0 '1'
阅读全文
摘要:# Sum of Intervals # https://www.codewars.com/kata/52b7ed099cdc285c300001cd/train/python def sum_of_intervals(intervals): intervals.sort(key = lambda
阅读全文
摘要:# Strings Mix # https://www.codewars.com/kata/5629db57620258aa9d000014 def mix(s1, s2): s1 = ''.join([c for c in s1 if c.islower()]) # [c for c in s1
阅读全文
摘要:# Roman Numerals Helper # https://www.codewars.com/kata/51b66044bce5799a7f000003/train/python class RomanNumerals: # @staticmethod 是一个装饰器, 用来标识一个方法为静态
阅读全文
摘要:# Twice linear # https://www.codewars.com/kata/5672682212c8ecf83e000050/train/python def dbl_linear(n): # i=0 # j=0 i,j = 0,0 #同时定义多个变量的方式 sequence =
阅读全文
摘要://B. Transfusion #include <iostream> #include <vector> void solve(){ int n; std::cin>>n; int countOfOdd = (n+1)/2; int countOfEven = n/2; long long su
阅读全文
摘要://A. Line Breaks #include <string> #include <iostream> void solve(){ int n,left; std::cin>>n>>left; int count = 0; while(n--){ std::string temp; std::
阅读全文
摘要:#include <iostream> void solve(){ int n,a,b,c; std::cin>>n>>a>>b>>c; int ans = n/(a+b+c) * 3; n = n%(a+b+c); if(n==0){ std::cout<<ans<<std::endl; retu
阅读全文
摘要://luogu,P11568 「chaynOI R1 T1」一维数组p11568 //洛谷T382521 #include <iostream> int main(){ int n,m; std::cin>>n>>m; for(int i = 0;i<n;++i){ std::cout<<1; }
阅读全文
摘要://codeforces 2057B #include <iostream> #include <utility> #include <set> #include <map> #include <numeric> struct cmp{ bool operator()(const std::pair
阅读全文
摘要:#include <iostream> void solve(){ int n,a,b;std::cin>>n>>a>>b; if((a-b)%2==0 || (b-a)%2==0){ std::cout<<"YES"<<std::endl; }else{ std::cout<<"NO"<<std:
阅读全文
摘要:#include <iostream> #include <vector> #include <climits> void solve(){ int n;std::cin>>n; std::vector<int> a(n); for(int i = 0;i<n;++i)std::cin>>a[i];
阅读全文
摘要://codeforce 2053B #include <iostream> #include <vector> #include <unordered_set> #include <map> #include <algorithm> void solve(){ int n;std::cin>>n;
阅读全文
摘要:// / Universal Online Judge //#15. 【NOIP2014】生活大爆炸版石头剪刀布 #include <iostream> #include <vector> void once(int& aPoint,int& bPoint,int a,int b){ if(a==b
阅读全文
摘要://codeforces 2057A #include <iostream> void solve(){ int n,m;std::cin>>n>>m; std::cout<< (n>m?n:m)+1<<std::endl; } int main(){ int t;std::cin>>t; whil
阅读全文
摘要:// URL: https://codeforces.com/contest/2053/problem/A #include <iostream> void solve(){ int n;std::cin>>n; bool flag = false; int a;std::cin>>a; for(i
阅读全文
摘要:// URL: https://codeforces.com/gym/2051/problem/D #include <iostream> #include <vector> #include <algorithm> void solve(){ long long ans = 0; int n;lo
阅读全文
摘要://codeforces 2051C #include <iostream> #include <vector> void solve(){ int n,m,k;std::cin>>n>>m>>k; if(k==n){ for(int i = 0;i<m;++i){ std::cout<<'1';
阅读全文
摘要://luogu,P11654 「FAOI-R5」becoder #include <iostream> #include <vector> int main(){ int n,L,R;std::cin>>n>>L>>R; --L;--R; std::vector<int> time(n),memor
阅读全文
摘要://luogu,P1603 斯诺登的密码 #include <iostream> #include <set> #include <string> #include <map> /* one two three four five six seven eight nine ten eleven tw
阅读全文
摘要://luogu,P11679 [Algo Beat Contest 001 A] Animal Beheaded #include <string> #include <iostream> int main(){ int a;std::cin>>a; std::string str; std::ci
阅读全文
摘要://luogu,P11681 [Algo Beat Contest 001 C] Creating a Queue #include <iostream> #include <set> int main(){ int N,M;std::cin>>N>>M; int countOfZero = 0;
阅读全文
摘要://luogu,P11680 [Algo Beat Contest 001 B] Between Head and Tail #include <algorithm> #include <iostream> void solve(){ int l,r;std::cin>>l>>r; for(int
阅读全文
摘要:/* codeforces,466AA. Cheap Travel 1张票a元, m张票b元, 买n张票, 最少多少钱 哪种方式均价更低就用哪种方式 要注意最终可能有的不足m张票的尾部 要计算哪种方式更划算 是用更高的均价单只买需要的票数 还是用更低的均价却要买满m张票 */ #include <i
阅读全文
摘要:/* codewars,Stop gninnipS My sdroW!,5264d2b162488dc400000001 设计一个函数,获取一个字符串, 将该字符串中长度大于等于5的单词反转, 将反转后的内容作为新字符串返回 */ #include <string> #include <iostre
阅读全文
摘要:/* codeforces, 1A, Theatre Square 对n*m的方格进行铺砖,每块砖的边长为a,最少需要多少块砖,砖可以裁剪 */ /* n和m除以a向上取整,然后相乘即可 */ #include <iostream> int main(){ int n,m,a; std::cin>>
阅读全文
摘要:/* codeforces,43A,Football 两个队伍进行n局比赛,给一个字符串,其中每个字符代表胜利者的队伍,求胜利者 */ /* 用map记录每个队伍的胜利次数,然后遍历map找出胜利次数最多的队伍 */ #include <iostream> #include <string> #in
阅读全文
摘要:/* codeforces, 58A, Chat rooms 判断一个字符串是否可以通过移除若干个字符得到 hello 输入一个字符串 输出YES或者NO */ /* 遍历输入字符串看能否按顺序得到h,e,l,l,o这五个字符 */ #include <iostream> #include <str
阅读全文
摘要:/* codeforces,69A,Young Physicist n个向量和是否为0,向量为(x,y,z) 第一行输入数字n 之后n行, 每行一个向量, 三个空格隔开的数字 输出YES或NO 和是0输出YES,否则输出NO */ #include <iostream> int main(){ in
阅读全文
摘要:/* codeforces,118A,String Task 将一个字符串中的所有元音字母删除,在所有辅音字母前添加一个字符".",并将所有字母转换为小写 输入一个字符串 输出处理后的字符串 */ #include <iostream> #include <string> int main(){ s
阅读全文
摘要:/* codeforces,122A,A. Lucky Division 幸运数是仅由4和7组成的数 快要幸运的数是 能被幸运数整除的数 判断一个数是不是快要幸运的数 输入一个数(1<= n <=1000) 如过是快要幸运的数,输出YES否则输出NO */ #include <iostream> #
阅读全文
摘要:/* codeforces,131A,A. cAPS lOCK 输入一个字符串,如果这个字符串是全大写或首字母外均大写,则将所有字母大小写反转;否则保持不变 输出处理后的字符串 */ #include <iostream> #include <string> int main(){ std::str
阅读全文
摘要:/* codeforces,158B,B. Taxi 将n组学生送到目的地,每组学生包含1~4名学生 每辆车最多载4名学生,每个组的所有学生必须乘坐同一辆车,一辆车可以载多组的学生 最少需要多少辆车 输入 第一行: 一个数字,n 第二行: n个空格隔开的数字,表示第i组学生的人数 */ /* */
阅读全文
摘要:/* codeforces,230A,A. Dragons 桐人需要击败n条龙,若力量大于龙的力量则能击败龙,否则会失败 初始时,桐人的力量为s,击败第i条龙后桐人的力量会增加y_i 第i条龙的力量是x_i 桐人可以按任意顺序与这n条龙对战 输入 s n x_1 y_2 x_1 y_2 ... 输出
阅读全文
摘要:/* codeforces, 339B, B. Xenia and Ringroad 问题说明`: 有一个单向环形的道路,长度为n,有m个任务,每个任务都是在道路上的某个位置,按顺序完成这些任务,每次完成一个任务,需要花费这个任务的位置和上一个任务的位置的距离的时间,问完成所有任务需要多少时间。 输
阅读全文
摘要:/* codeforces, 479A,A. Expression 问题描述: 给定三个正整数a,b,c,求一个表达式,使得表达式的值最大 使用加法,乘法,括号 输入: 三个正整数a,b,c(1<=a,b,c<=100) 输出: 一个整数,表示表达式的最大值 */ /* 两个正整数数运算,如果有一个
阅读全文
摘要:/* codeforces,492B,B. Vanya and Lanternslanterns 问题描述: 有长度为l的街道,n个位置固定的灯笼,每个灯笼可以照亮周围d的范围 照亮整个街道需要的最小的d是多少 输入: 第一行n,l(2<=n<=1000,1<=l<=10^9) 第二行n个数,表示灯
阅读全文
摘要:/* codeforces,1873A, A. Short Sort 判断一个由a,b,c组成的字符串是否是可以通过对字符串"abc"进行1次或0次交换字符操作得到 交换字符操作是指,将字符串中的两个字符交换位置 */ /* 符号条件的字符串一定有一个位置的字符与"abc"相同,即 abc,acb
阅读全文
摘要:/* codeforces,1956A,A. Nene's Game 题目描述: https://codeforces.com/problemset/problem/1956/A */ #include <iostream> void solve(){ int k,q;std::cin>>k>>q;
阅读全文
摘要:/* codeforces,1956B,B. Nene and the Card Game 问题描述: https://codeforces.com/problemset/problem/1956/A */ #include <iostream> #include <vector> void sol
阅读全文
摘要://2048C /* codeforces,2048C,C. Kevin and Binary Strings https://codeforces.com/problemset/problem/2048/C */ #include <iostream> #include <algorithm> v
阅读全文
摘要:/* codeforces,2049A,A. MEX Destruction */ #include <iostream> void solve(){ int n; std::cin>>n; bool a=true,b=true; int ans = 0; while(n--){ int temp;
阅读全文
摘要:/* codewars,Hamming Numbers,525d84b98f428f14a60008da Hamming数是指其质因子只包含1,3,5的正整数。 即2^i * 3^j * 5^k,其中i,j,k>=0。 要求编写一个函数hamming(n)返回从小到大的第n个Hamming数。 */
阅读全文
摘要:/* codewars,RGB To Hex Conversion,513e08acc600c94f01000001 */ #include <string> std::string rgb_to_hex(int r, int g, int b) { char hexChars[] = "01234
阅读全文
摘要:int main(){ int num = 52; const int constNum = 52; //指向常量的指针 const int *ptrToConst = # //从右向左, 标识符是ptrToConst,*说明是指针,int说明指针指向的是int,const说明指向的int是
阅读全文
摘要:codewars,Rot13,530e15517bc88ac656000716 ROT13 是一种简单的字母替换密码, 用字母表中某字母后面的第13字母替换这个字母。ROT13 是 Caesar 密码的一个示例。 创建一个函数,该函数获取字符串并返回使用 Rot13 加密的字符串。 如果字符串中包含
阅读全文
摘要:/* codewars,Directions Reduction,550f22f4d758534c1100025a 给定一个数组,数组中的元素是方向,例如["NORTH", "SOUTH", "SOUTH", "EAST", "WEST", "NORTH", "WEST"], 相邻的两个元素若方向相
阅读全文
摘要:/* codewars,Hamming Numbers,525d84b98f428f14a60008da Hamming数是指其质因子只包含1,3,5的正整数。 即2^i * 3^j * 5^k,其中i,j,k>=0。 要求编写一个函数hamming(n)返回从小到大的第n个Hamming数。 */
阅读全文
摘要:/* codewars,525f4206b73515bffb000b21,Adding Big Numbers 写一个实现正整数字符串实现的大整数相加的函数 */ #include <iostream> #include <string> #include <algorithm> std::stri
阅读全文