上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 15 下一页
摘要: 描述 求 a 的 b 次方对 p 取模的值,其中 1≤a,b,p≤10^9 输入格式 三个用空格隔开的整数a,b和p。 输出格式 一个整数,表示a^b mod p的值。 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long l 阅读全文
posted @ 2022-01-26 22:10 matt-11 阅读(38) 评论(0) 推荐(0)
摘要: 描述 给定一张 n(n≤20) 个点的带权无向图,点从 0~n-1 标号,求起点 0 到终点 n-1 的最短Hamilton路径。 Hamilton路径的定义是从 0 到 n-1 不重不漏地经过每个点恰好一次。 输入格式 第一行一个整数n。 接下来n行每行n个整数,其中第i行第j个整数表示点i到j的 阅读全文
posted @ 2022-01-26 22:09 matt-11 阅读(32) 评论(0) 推荐(0)
摘要: 考虑如果顺序模拟会T,注意到最后一个元素一定在它确定的位置,考虑从后往前放,找第k个空位,完美解决这题; 1 #include<iostream> 2 #include<cstdio> 3 #define ls (x<<1) 4 #define rs (x<<1|1) 5 using namespa 阅读全文
posted @ 2022-01-11 22:19 matt-11 阅读(32) 评论(0) 推荐(0)
摘要: 1 class Solution { 2 public: 3 typedef long long ll; 4 const int lim=1e6; 5 int dx[8]={-1,0,1,0},dy[8]={0,1,0,-1}; 6 bool isEscapePossible(vector<vect 阅读全文
posted @ 2022-01-11 15:13 matt-11 阅读(47) 评论(0) 推荐(0)
摘要: 1 class Solution { 2 public: 3 vector<string>ans; 4 bool isAdditiveNumber(string num) { 5 int n=num.size(); 6 function<int(int,int)>dfs=[&](int u,int 阅读全文
posted @ 2022-01-10 21:50 matt-11 阅读(53) 评论(0) 推荐(0)
摘要: P5490 【模板】扫描线 这题线段树的节点表示的是区间,树上节点x表示的区间【l,r】是实际点的[l,r+1]区间;因为我们纯用点一一对应 当标记落到一个点时 没有任何意义;标记更新,如果当前节点被标记,说明区间被标记,如果当前节点没被标记,返回左节点和右节点被标记的总长度 sum[x]维护的是节 阅读全文
posted @ 2022-01-10 21:06 matt-11 阅读(55) 评论(0) 推荐(0)
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int main() 5 { 6 string s; 7 cin>>s; 8 int ans=0,cnt=0; 9 for(auto &p:s) 10 { 11 if(p=='(')cnt++; 阅读全文
posted @ 2022-01-09 20:22 matt-11 阅读(53) 评论(0) 推荐(0)
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n; 4 5 unordered_map<string,set<string>>mp; 6 vector<string>vec; 7 unordered_map<string,int>ch; 阅读全文
posted @ 2022-01-09 20:19 matt-11 阅读(28) 评论(0) 推荐(0)
摘要: 1 任选两颗A,B两颗种子,pa是种A种子需要的天数,ga是A种子开花需要的天数; 2 1.考虑先种A,后种B 3 mina_day=max(pa+ga,pa+pb+gb); 4 2.先种B,后种A; 5 minb_day=max(pb+gb,pb+pa+ga); 6 7 不妨设ga>gb; 8 p 阅读全文
posted @ 2022-01-09 18:02 matt-11 阅读(64) 评论(0) 推荐(0)
摘要: 1 class Solution { 2 public: 3 int minSwaps(vector<int>& nums) { 4 int n=nums.size(),sum1=0; 5 for(auto &p:nums)if(p)sum1++; 6 for(int i=0;i<n;i++)num 阅读全文
posted @ 2022-01-09 14:06 matt-11 阅读(92) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 15 下一页