01 2024 档案
摘要:全局变量 string a,b; int kmp_next[1000010]; // next数组 初始化next数组 void getNext(int m){ int j = 0; // 初始化next[0]的值 kmp_next[0] = 0; for(int i=1; i<m; ++i){ /
阅读全文
摘要:A. Tricky Template 思维有点难转过来,而且当时在C也能匹配c这卡了很久 #include<bits/stdc++.h> using namespace std; void solve(){ int n; cin>>n; string a,b,c; cin>>a>>b>>c; int
阅读全文
摘要:A. Square #include<bits/stdc++.h> using namespace std; void solve(){ int a1,b1,a2,b2,a3,b3,a4,b4; cin>>a1>>b1>>a2>>b2>>a3>>b3>>a4>>b4; int s1,s2; if(a
阅读全文
摘要:多米诺骨牌 在棋盘上放置多米诺骨牌,两端的颜色都不一样,要求横竖的总和是一样的
阅读全文
摘要:组合数(2次方级)的组合 #include<bits/stdc++.h> #define int long long using namespace std; const int mod=998244353; void solve(){ int n; cin>>n; vector<int>a(n+1
阅读全文
摘要:Friendly Arrays 打表 #include<bits/stdc++.h> #define int long long using namespace std; void solve(){ int n,m; cin>>n>>m; vector<int>a(n+1); vector<int>
阅读全文
摘要:Money Trees 用双指针不断的收缩区间即可 #include<bits/stdc++.h> using namespace std; const int N=2e5+10; int a[N],b[N]; void solve(){ int n,k; cin>>n>>k; for(int i=
阅读全文
摘要:Jellyfish and Game 因为n,m很小,所有直接暴力就行 #include<bits/stdc++.h> #define int long long using namespace std; void solve(){ int n,m,k; cin>>n>>m>>k; vector<i
阅读全文
摘要:int lowbit(int x){return x&(-x);} bool check(int x){ if(lowbit(x)!=x)return true; else return false; }
阅读全文
摘要:Jellyfish and Green Apple 数论 将苹果平均的分给人,可以将苹果一分为二,问你最少分多少次。 首先把能分的都分掉就是n%=m,其次操作数是很好想的,就一直*2并且%m,直到n==0,关于这题有难度的就是n,m分不了的情况。 设想一下,成功的情况,也就是这个n一直在乘2最后能=
阅读全文
摘要:Joyboard 打表 题目数据给的很夸张,单纯的模拟肯定不行,直接打表找出规律! #include <bits/stdc++.h> using namespace std; typedef long long ll; void solve() { ll n, m, k; cin >> n >> m
阅读全文
摘要:首先这是一个离线的操作,所以可以用st表,所有区间的&运算结果求出来 其次&运算是相同取1,不同取0。意味着值是不断变小的,所有我们可以二分找到答案 #include<bits/stdc++.h> #define int long long using namespace std; const in
阅读全文
摘要:不断的去插入删除线段,问你有无两个线段是不相交的 个人认为很好的一道题训练multiset #include<bits/stdc++.h> using namespace std; multiset<int>sl,sr; int main(){ ios::sync_with_stdio(false)
阅读全文
摘要:for(int j=2;j<=sqrt(x);j++){ while(!(x%j)){ mp[j]++; x/=j; } } if(x!=1){ mp[x]++; }
阅读全文
摘要:大致就是选择任意的i,j 提出a[i]的一个因子,给a[j] 所以题目的本质就是因子间的相互转化,问你进行任意次的操作后能使a中的所有元素相等吗 #include<bits/stdc++.h> #define int long long using namespace std; void solve
阅读全文
摘要:如果要是子数组唯一,没有子序列与之相同,那么就要找同一个字母的第一个出现的位置和最后一个出现的位置 #include<bits/stdc++.h> #define int long long using namespace std; const int N=1e5+10; int a[N]; voi
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; void solve(){ int n,m; cin>>n>>m; vector<int>a; vector<int>b; a.push_back(1); for(int i=2;i<=n;i++){ int
阅读全文
摘要:题目是一定有答案的,说明所有的情况都是可行的,那么就会有两种情况 1 两个圆都包括了起点和终点 2 一个原包括了起点,另一个原包括了终点(圆一定是相交的) #include<bits/stdc++.h> using namespace std; double dx(int x1,int y1,int
阅读全文
摘要:题目大致就是让你判断有没有一个a数组,选一个定点向左循环x次,这样的操作一个k次,能变成给定的b数组 其实这样的题目是死的,你要做的只不过是不断的倒推。 当你找不到一个可以操作的定点,说明是不行。 因为k很大不可以循环1e9次的,说明这个题目一定要缩小k的范围。这其中有一个思想就是如果模拟到了同一个
阅读全文
摘要:很容易能想到哈希,把每个字符串的数位拆开。然后遍历每个字符串匹配就行 当时我自己漏了一种情况,就是每一种的字符串其实是可以和三种情况的字符串匹配的,分别是比自己长的,短的,一样长的。 #include<bits/stdc++.h> #define int long long using namesp
阅读全文
摘要:n的范围有2e5,暴力找肯定不行。将这题时间复杂度打下来的关键在于贪心 贪心的点在于局部最优,尽可能的将b里相对大的分给a里相对小的,一共分k个这样的。最后再检查一下,如果不满足就是-1 #include<bits/stdc++.h> using namespace std; const int N
阅读全文
摘要:打表找到的规律 #include<bits/stdc++.h> #define int long long using namespace std; const int N=2e5+10; int a[N]; void solve(){ int n; cin>>n; map<int,int>mp;
阅读全文
摘要:当时直接秒了 #include<bits/stdc++.h> using namespace std; const int N=2e5+10; int a[N]; void solve(){ int n; cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; int mi=
阅读全文
摘要:typedef long long LL; LL pow(LL a, LL n, LL m){ LL res = 1; while(n){ if(n & 1){ res = res * a % m; } a = a * a % m; n >>= 1; } return res;
阅读全文
摘要:A. Wallet Exchange #include<bits/stdc++.h> using namespace std; void solve(){ int a,b; cin>>a>>b; int k=a+b; if(!(k&1)){ cout<<"Bob\n"; }else{ cout<<"
阅读全文
摘要:A #include<bits/stdc++.h> using namespace std; void solve(){ string s; cin>>s; for(int i=0;i<s.size()-1;i++){ cout<<s[i]; } cout<<"4"; } int main(){ i
阅读全文
摘要:__int128 li = -2e18,ri = 2e18; //向上找最小值 while(li<ri) { __int128 mid = (li+ri-1)/2; if(a+mid*m>=l) ri=mid; else li = mid+1; } __int128 lj = -2e18,rj =
阅读全文
摘要:能承载39位的大数 #define int long long必开 template <typename _Tp> inline void read(_Tp&x) {//输入 char ch;bool flag=0;x=0; while(ch=getchar(),!isdigit(ch)) if(c
阅读全文
摘要:操作:选取词性最大的子序列,向右循环一次 问你进行多少次这样的操作能使数组有序,如果不能就输出-1 思路:首先要知道的是一个词性最大的序列整个右移过后,数组的新词性最大的序列就是之前的词性最大序列去了最后一个字母. 找出词性最大的子序列 int n; string s; cin>>n>>s; for
阅读全文
摘要:必须是强化攻击杀死,也就是7的倍数次,也就是每7次能打9滴血,那么反过来想如果这三个怪的血是9的倍数就一定是强化攻击打死的,否则不是。 #include<bits/stdc++.h> using namespace std; void solve(){ int a,b,c; cin>>a>>b>>c
阅读全文
摘要:int mergeSort(vector<int>& nums, int left, int right) { if (left >= right) return 0; int mid = left + (right - left) / 2; // 分治递归 long long count = me
阅读全文
摘要:D. Unnatural Language Processing 给字符串元素按要求间隔”.“ #include<bits/stdc++.h> using namespace std; void solve(){ int n; string s; cin>>n>>s; string o=s; for
阅读全文
摘要:A. Least Product 求乘积最小,可以改数组元素 #include<bits/stdc++.h> #define int long long using namespace std; void solve(){ int n; cin>>n; int ans=1; for(int i=1;
阅读全文