上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 22 下一页

2021年2月19日

摘要: A:给定一个序列,一个操作是向其中任何一个位置插入一个数,问至少需要多少次操作才能保证两两之间的max(a[i],a[i+1])/min(a[i],a[i+1])<=2。 假设在i和i+1之间插入一个数,这个操作并不会影响到其他,所以我们可以线性的考虑整个序列。 那么我们现在只需要考虑如果a和b,m 阅读全文
posted @ 2021-02-19 17:00 greenofyu 阅读(31) 评论(0) 推荐(0)

2021年2月16日

摘要: A:问能否将一个数组通过轮换的方式得到一个单调不减的数组。 因为范围只有100,直接将数组拷贝并排序,然后对原数组轮换n次,每次进行一下判断。 1 class Solution { 2 public: 3 bool check(vector<int>&a,vector<int>& b){ 4 int 阅读全文
posted @ 2021-02-16 21:19 greenofyu 阅读(41) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/1479/ 水题。 得到sum后可每一次提取个位数字,或直接将其to_string。 解法一: 1 #include<iostream> 2 #include<algorithm> 3 using namespace st 阅读全文
posted @ 2021-02-16 19:38 greenofyu 阅读(39) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/447/ 水题。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int n; 5 cin>>n; 6 int res=0; 7 while( 阅读全文
posted @ 2021-02-16 19:35 greenofyu 阅读(26) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/451/ 水题。 确定p有且仅有两个质因子。 故可直接枚举较小的那个质因子。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int p; 5 阅读全文
posted @ 2021-02-16 19:34 greenofyu 阅读(27) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/443/ 水题。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int l,r; 5 cin>>l>>r; 6 int cnt=0; 7 f 阅读全文
posted @ 2021-02-16 19:33 greenofyu 阅读(23) 评论(0) 推荐(0)

2021年2月11日

摘要: https://www.acwing.com/problem/content/501/ 1 #include<iostream> 2 using namespace std; 3 const int N=200010; 4 typedef long long LL; 5 int v[N],w[N]; 阅读全文
posted @ 2021-02-11 16:40 greenofyu 阅读(73) 评论(0) 推荐(0)

2021年2月10日

摘要: https://www.acwing.com/activity/content/code/content/846810/ n个牛进行叠罗汉,每头牛有一个重量w和强壮程度s,风险等级定义为头上的牛的质量减去我的强壮程度,问如何叠最大的风险等级最小。 1 #include<algorithm> 2 #i 阅读全文
posted @ 2021-02-10 22:58 greenofyu 阅读(69) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/460/ 发现L的范围只有100,直接枚举分子分母。 1 #include<iostream> 2 #include<cmath> 3 using namespace std; 4 int gcd(int a,int b) 阅读全文
posted @ 2021-02-10 21:45 greenofyu 阅读(50) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/submission/124/ n个同学围成一个圈,每个同学手上有ai个糖果,每传递一个糖果代价为1,问最少代价为多少使得糖果均分。 将解得的x1,x2....xn带入目标式子中。 所以只需要构造一种糖果传递方案,使得每次 阅读全文
posted @ 2021-02-10 21:31 greenofyu 阅读(56) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 22 下一页