摘要: 质数的判定——试除法 时间复杂度O(sqrt(n)) 写sqrt(n)比较慢,i*i<=n容易溢出 bool is_prime(int x) { if(x<2) return false; for(int i=2;i<=x/i;i++) if(x%i==0) return false; return 阅读全文
posted @ 2021-02-17 12:17 standard_zsz 阅读(18) 评论(0) 推荐(0)
摘要: 原题链接:https://codeforces.com/contest/1475 A. Odd Divisor 倒着判,每次除2,时间复杂度nlogn #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> 阅读全文
posted @ 2021-01-26 11:11 standard_zsz 阅读(78) 评论(0) 推荐(0)
摘要: 原题链接:https://codeforces.com/contest/1467 A. Wizard of Orz A题就WA了两发才过,真是令人难受 #include<iostream> #include<cstdio> #include<cstring> using namespace std; 阅读全文
posted @ 2021-01-24 11:09 standard_zsz 阅读(106) 评论(0) 推荐(0)
摘要: 原题链接:https://codeforces.com/contest/1472 C. Long Jumps 用过了这个数就跳过,没有用过就接着加,最后ans取最大值 #include<iostream> #include<cstdio> #include<cstring> using namesp 阅读全文
posted @ 2021-01-24 10:52 standard_zsz 阅读(108) 评论(0) 推荐(0)
摘要: 原题链接:https://codeforces.com/contest/1474 A. Puzzle From the Future 贪心,不多说 View Code B. Different Divisors 找四个数,他们之间的差最小是d,暴力+贪心,第一个数是1,最后一个数是第二个数*第三个数 阅读全文
posted @ 2021-01-24 10:34 standard_zsz 阅读(92) 评论(0) 推荐(0)
摘要: 原题链接:https://codeforces.com/contest/1445 A. Array Rearrangment 给定两个序列,判断a+b<=x,由于序列b可以排序,所以将两个序列都进行排序。 #include<iostream> #include<cstdio> #include<al 阅读全文
posted @ 2020-11-18 13:36 standard_zsz 阅读(136) 评论(0) 推荐(0)
摘要: 原题链接https://codeforces.com/contest/1430 A - Number of Apartments 将一个数分为3,5,7。将这个数对3取余,余数为0时则其可全部由3组成;余数为1时,取出两个3组成一个7;余数为2时,取出一个3组成一个5。特殊情况:1、2、4无法拆分 阅读全文
posted @ 2020-11-12 23:41 standard_zsz 阅读(99) 评论(0) 推荐(0)