Codeforces Round #650 (Div. 3) B. Even Array 题目链接:https://codeforces.com/contest/1367/problem/B 题意 有一大小为 nn 的数组 aa,问能否经过交换使所有元素与下标奇偶性相同(0 - indexed)。 题解 奇偶性不同的奇数和偶数个数应相等。 代码 #include <bits/stdc++.h> using namespace std; ...
using namespace std; int main() { __int64 n, k; while (cin >> n >> k) { if (k <= (n+1)/2) cout << (k-1)*2 + 1 << endl; else { k -= (n+1)/2; cout << k*2 << endl; } } return 0; } B.Sereja and Array 就是找到以“heavy” 开头和“metal”结尾的字符串...
codeforces 318 A.Even Odds B.Sereja and Array A.Even Odds 给你n和k, 把从1到n先排奇数后排偶数排成一个新的序列,输出第k个位置的数。 比如10 3 拍好后就是 1 3 5 7 9 2 4 6 8 10 第3个数是5。 //cf 318 A //2013-06-18-20.30 #include <iostream> usingnamespacestd;...
1374D-ZeroRemainderArray.cpp 1374E1-ReadingBooksEasyVersion.cpp 1375A-SignFlipping.cpp 1375B-NeighborGrid.cpp 1375C-ElementExtermination.cpp 1379A-AcaciusAndString.cpp 1380A-ThreeIndices.cpp 1380B-UniversalSolution.cpp 1380C-CreateTheTeams.cpp 1382A-CommonSubsequence.cpp 1382B-SequentialNim.cpp 1382...
curr^= (1 <<diff); } map.putIfAbsent(curr, i); best= Math.max(best, i -map.get(curr)); }returnbest; } } Related Problems [LeetCode 525] Contiguous Array [LeetCode 560] Subarray Sum Equals K [LeetCode 1542] Find Longest Awesome Substring...
cout << (k-1)*2 + 1 << endl; else { k -= (n+1)/2; cout << k*2 << endl; } } return 0; } B.Sereja and Array 就是找到以“heavy” 开头和“metal”结尾的字符串有多少个。 我的思路是标记“heavy” 和“metal”的位置然后计算以每一个“metal”结尾的有多少个,然后相加。