Codeforces 1091

比赛链接

为什么我Good Bye 2018的CD全是打表+oeis啊=-=(你改叫oeisforces好了)

一定是我打开方式不对 反正给差评→_→

(orz \(\mathbb{mjt}\) CD都是推出来的!)

话说E只要看出是Erdős–Gallai定理然后想到二分,就是裸题么...?竟然都没怎么看题面给的链接。。sad。好吧反正我也不会二分。

以后不能直接弃疗啊。

A.New Year and the Christmas Ornament

  1. #include <set>
  2. #include <map>
  3. #include <cstdio>
  4. #include <cctype>
  5. #include <vector>
  6. #include <cstring>
  7. #include <algorithm>
  8. #define mp std::make_pair
  9. #define pr std::pair<int,int>
  10. #define gc() getchar()
  11. typedef long long LL;
  12. typedef unsigned long long ull;
  13. inline int read()
  14. {
  15. int now=0,f=1;
  16. register char c=gc();
  17. for(; !isdigit(c); c=='-'&&(f=-1),c=gc());
  18. for(; isdigit(c); now=now*10+c-'0',c=gc());
  19. return now*f;
  20. }
  21. int ans;
  22. signed main()
  23. {
  24. int A = read(), B = read(), C = read();
  25. for(int i = 1; i <= 100; i++)
  26. {
  27. if(i <= A && (i + 1 <= B) && (i + 2 <= C)) ans = i + i + 1 + i + 2;
  28. }
  29. printf("%d\n",ans);
  30. return 0;
  31. }

B.New Year and the Treasure Geolocation

解法一:因为有\(\sum x_i+a_j=n*ans_x\),所以\(ans_x\)就是\(\frac{\sum x_i+a_j}{n}\)。\(ans_y\)同理。

解法二:因为一定是最大的\(x_i\)和最小的\(a_j\)配对,所以其实输出\(\frac{\max\{x_i\}+\min\{a_j\}}{2}\)即可。

解法三:枚举\(x_1,y_1\)对应哪个\(a_j,b_j\),然后就可以\(O(n\log n)\)地判断。复杂度\(O(n^2\log n)\)。

我写的最傻的这种==。

  1. #include <set>
  2. #include <map>
  3. #include <cstdio>
  4. #include <cctype>
  5. #include <vector>
  6. #include <cstring>
  7. #include <algorithm>
  8. #define mp std::make_pair
  9. #define pr std::pair<int,int>
  10. #define gc() getchar()
  11. typedef long long LL;
  12. typedef unsigned long long ull;
  13. const int N=1005;
  14. int X[N],Y[N],A[N],B[N];
  15. inline int read()
  16. {
  17. int now=0,f=1;register char c=gc();
  18. for(;!isdigit(c);c=='-'&&(f=-1),c=gc());
  19. for(;isdigit(c);now=now*10+c-'0',c=gc());
  20. return now*f;
  21. }
  22. int main()
  23. {
  24. int n=read();
  25. for(int i=1; i<=n; ++i) X[i]=read(), Y[i]=read();
  26. for(int i=1; i<=n; ++i) A[i]=read(), B[i]=read();
  27. for(int i=1; i<=n; ++i)
  28. {
  29. bool f=1;
  30. int ansx=X[1]+A[i],ansy=Y[1]+B[i];
  31. std::map<int,int> vx,vy;
  32. for(int j=2; j<=n; ++j)
  33. ++vx[X[j]], ++vy[Y[j]];
  34. for(int j=1; j<=n; ++j)
  35. {
  36. if(i==j) continue;
  37. if(!vx[ansx-A[j]]||!vy[ansy-B[j]]) {f=0; break;}
  38. --vx[ansx-A[j]], --vy[ansy-B[j]];
  39. }
  40. if(f) return printf("%d %d\n",ansx,ansy),0;
  41. }
  42. return 0;
  43. }

C.New Year and the Sphere Transmission(思路)

首先可以猜到和是多少与\(\gcd(n,k)\)有关。因为可以打表看出有多少种\(\gcd(n,k),1\leq k\leq n\),就有多少个答案。

然后再利用一下表,多枚举几个\(g=\gcd(n,k)\),算(\(oeis\))一下这时候的答案,发现就是\(\frac{n^2-(g-2)n}{2g}\)。

或者大概能猜到,\(\gcd(n,k)=g\)时,会走到\(1,1+g,1+2g,1+3g...\)这些数,同时会有\(\frac{n}{g}\)项。等差数列求和就算出来了。

然后所有可能的\(\gcd(n,k)\)就是\(n\)的约数。对\(n\)分解约数就行了。

官方题解:

把\(1\)从序列中拿出去。

假设我们要走到\(v\)这个数,那么有\(a*k\equiv v\ (mod\ n)\),也就是\(a*k-b*n=v,\ a,b\in\mathbb{N}\)。然后我们知道当且仅当\(\gcd(n,k)\mid v\) 时方程有解。也就是当\(\gcd(n,k)=g\)时,一定会走到\(g\)的倍数这些数,有\(\frac{n}{g}\)个。同样等差数列求和就行了。

  1. #include <set>
  2. #include <map>
  3. #include <cstdio>
  4. #include <cctype>
  5. #include <vector>
  6. #include <cstring>
  7. #include <algorithm>
  8. #define mp std::make_pair
  9. #define pr std::pair<int,int>
  10. #define gc() getchar()
  11. typedef long long LL;
  12. typedef unsigned long long ull;
  13. const int N=1e6+5;
  14. LL Ans[N];
  15. std::map<LL,bool> vis;
  16. inline int read()
  17. {
  18. int now=0,f=1;register char c=gc();
  19. for(;!isdigit(c);c=='-'&&(f=-1),c=gc());
  20. for(;isdigit(c);now=now*10+c-'0',c=gc());
  21. return now*f;
  22. }
  23. void Work(int n)
  24. {
  25. int t=0; vis.clear();
  26. for(int k=1; k<=n; ++k)
  27. {
  28. int p=(1+k-1)%n+1; LL s=1;
  29. while(p!=1) s+=p, p=(p+k-1)%n+1;
  30. if(!vis[s]) vis[s]=1, Ans[++t]=s, printf("(%d,%d)=%I64d\n",n,k,s);
  31. }
  32. std::sort(Ans+1,Ans+1+t);
  33. printf("%d\n",n);
  34. for(int i=1; i<=t; ++i) printf("%d ",Ans[i]);
  35. puts(""); puts("");
  36. }
  37. int main()
  38. {
  39. // int n=read(),t=0;
  40. // for(int i=1; i<=40; ++i) Work(i); return 0;
  41. int n=read(),t=0;
  42. for(int i=1; 1ll*i*i<=n; ++i)
  43. if(!(n%i))
  44. {
  45. int g=i;
  46. Ans[++t]=(1ll*n*n-1ll*(g-2)*n)/(2*g);
  47. if(1ll*i*i!=n) g=n/i, Ans[++t]=(1ll*n*n-1ll*(g-2)*n)/(2*g);
  48. }
  49. std::sort(Ans+1,Ans+1+t);
  50. t=std::unique(Ans+1,Ans+1+t)-Ans-1;
  51. for(int i=1; i<=t; ++i) printf("%I64d ",Ans[i]);
  52. return 0;
  53. }

D.New Year and the Permutation Concatenation(思路 计数)

\(Description\)

给定\(n\)。将\(n!\)种\(n\)的排列按字典序从小到大拼接成一个长为\(n*n!\)的序列,求该序列中有多少个长为\(n\)的子段,满足它们的和为\(\frac{n(n+1)}{2}\)(就是\(1,...,n\)各出现一次)。

\(n\leq 10^6\)。

\(Solution\)

打出表来,发现什么都\(OEIS\)不到。再猜答案和\(n*n!\)有关系。然后用\(n*n!\)一减答案发现这个数列可以被\(OEIS\)到,然后套几个式子/数列再用\(n*n!\)一减就得到答案了。。

没看懂题解在说啥。写一下(神仙)\(\mathbb{mjt}\)的做法orz。

对于\(n=3\),\(p=[1,2,3,1,3,2,2,1,3,2,3,1,3,1,2,3,2,1]\),(结合样例解释)我们猜,把排列分成\(n\)段,也就是以不同数开头的排列为一段,这些段的答案是一样的。(对于\(n=3\)就是分成\([1,2,3,1,3,2],[2,1,3,2,3,1],[3,1,2,3,2,1]\)三段)

事实上也确实是这样,对于相邻两段比如:\(2,n,...1,3,1,...,n\),它们之间也形不成合法子段。

所以我们现在只考虑怎么算以某个数开头的排列的答案(比如\([1,2,3,1,3,2]\)),再乘\(n\)就是答案了。

我们猜是可以递推的。也就是假设我们知道\(n-1\)时的答案\(f_{n-1}\),怎么求\(f_n\)?

拿\(n=4\)来说,考虑此时以\(4\)开头的排列,就是在每个\(3\)的排列前面加上一个\(4\)再拼在一起。

显然我们可以得到\(3!\)种合法子段。而\(f_3\)中的每种方案,在\(n=4\)时也都能和一个\(4\)组成合法的子段(写一写看)。但唯独最后面的\(4,3,2,1\)算了两次。所以有:\(f_n=\left[f_{n-1}+(n-1)!-1\right]*n\)。

代码是\(OEIS\)的那种。。懒得再写了。

  1. #include <set>
  2. #include <map>
  3. #include <cstdio>
  4. #include <cctype>
  5. #include <vector>
  6. #include <cstring>
  7. #include <algorithm>
  8. #define mp std::make_pair
  9. #define pr std::pair<int,int>
  10. #define gc() getchar()
  11. #define mod 998244353
  12. typedef long long LL;
  13. typedef unsigned long long ull;
  14. const int N=1e6+5;
  15. inline int read()
  16. {
  17. int now=0,f=1;register char c=gc();
  18. for(;!isdigit(c);c=='-'&&(f=-1),c=gc());
  19. for(;isdigit(c);now=now*10+c-'0',c=gc());
  20. return now*f;
  21. }
  22. //bool Check(int *p,int n)
  23. //{
  24. // for(int i=1; i<=n; ++i) if(p[i]!=i) return 0;
  25. // return 1;
  26. //}
  27. //void Work(int n)
  28. //{
  29. // static int A[10000004],p[15];
  30. // for(int i=1; i<=n; ++i) p[i]=i;
  31. // int t=0;
  32. // do
  33. // {
  34. // for(int i=1; i<=n; ++i) A[++t]=p[i];
  35. // std::next_permutation(p+1,p+1+n);
  36. // }while(!Check(p,n));
  37. // int ans=0;
  38. // for(int i=1; i<=t; ++i)
  39. // {
  40. // int s=0;// n<=4 && printf("%d ",A[i]);
  41. // for(int j=i; j-i+1<=n && j<=t; ++j)
  42. // s+=A[j], j-i+1==n && s==n*(n+1)/2 && (++ans);
  43. // if(n<=5 && i+n-1<=t) printf("%lld ",s);
  44. // }
  45. // puts("");
  46. // printf("%d:%d t:%d\n",n,ans,t);
  47. //}
  48. int fac[N],A[N];
  49. int main()
  50. {
  51. // for(int i=1; i<=9; ++i) Work(i);
  52. int n=read();
  53. fac[0]=1, A[0]=1;
  54. for(int i=1; i<=n; ++i) fac[i]=1ll*fac[i-1]*i%mod;
  55. for(int i=1; i<=n; ++i) A[i]=1ll*i*A[i-1]%mod+1;
  56. A[n]=(A[n]+mod-fac[n]-1)%mod;
  57. LL ans=1ll*n*fac[n]%mod-A[n];
  58. printf("%d\n",(int)(ans%mod+mod)%mod);
  59. return 0;
  60. }

E.New Year and the Acquaintance Estimation(Erdos–Gallai定理 二分)

\(Description\)

给定度数序列\(d_1,...,d_n\),求\(d_{n+1}\)等于多少时,度数序列\(d_1,d_2,...,d_{n+1}\)可简单图化。输出所有可能的\(d_{n+1}\)。

可简单图化是指,存在一张简单无向图,使得该图点的度数可以与该度数序列一一对应。

\(n\leq 5\times 10^5\)。

\(Solution\)

话说E只要看出是Erdős–Gallai定理然后想到二分,就是裸题么...?

题意就是,输出\(d_{n+1}\)等于多少时,度数序列\(d_1,d_2,...,d_{n+1}\)可简单图化(就是存在一张简单图使得满足该度数序列)。(当时竟然想都没想真是气人)

考虑枚举\(d_{n+1}\)。给定一个度数序列判断其是否合法可以用Erdős–Gallai定理,复杂度\(O(n)\)。所以现在的复杂度是\(O(n^2)\)的。

根据样例我们还可以猜想并验证:

  1. 由握手定理(就是无向图中所有点的度数之和为偶数),\(d_{n+1}\)的奇偶性可以确定。
  2. 满足条件的\(d_{n+1}\)一定是一段连续的区间。

    所以我们就可以二分了。

二分要得到的是某段区间,分别二分左右端点,但还需要讨论一下。

令\(n=n+1\),写一下Erdős–Gallai定理的式子:$$\sum_{i=1}^kd_i\leq k(k-1)+\sum_{i=k+1}^n\min(d_i,k)$$

二分\(n\)的度数\(d_n=mid\),然后\(sort\)一下度数序列。

从小到大枚举\(k\)的时候,记\(left\)为左式的值,\(right\)为右式的值。若一直有\(left\leq right\),显然\(mid\)可行。

否则若\(left>right\),我们要么减小\(left\),要么增大\(right\)。而唯一能改变的就是\(n\)的度数\(mid\)。

所以现在若\(mid\geq d_k\)(影响左式),我们可以减小\(mid\)使得序列合法,也就是答案偏大。

若\(mid<d_k\)(影响右式),可以增大\(mid\),也就是答案偏小。

可以确定答案偏大偏小,就可以二分出区间了。复杂度\(O(n\log n)\)。

经过一些预处理也可以做到\(O(n)\)

  1. //187ms 8200KB
  2. #include <cstdio>
  3. #include <cctype>
  4. #include <algorithm>
  5. //#define gc() getchar()
  6. #define MAXIN 500000
  7. #define gc() (SS==TT&&(TT=(SS=IN)+fread(IN,1,MAXIN,stdin),SS==TT)?EOF:*SS++)
  8. typedef long long LL;
  9. const int N=5e5+5;
  10. int A[N];
  11. char IN[MAXIN],*SS=IN,*TT=IN;
  12. inline int read()
  13. {
  14. int now=0;register char c=gc();
  15. for(;!isdigit(c);c=gc());
  16. for(;isdigit(c);now=now*10+c-'0',c=gc());
  17. return now;
  18. }
  19. int Check(const int n,const int mid)
  20. {
  21. static int d[N];
  22. static LL sum[N];
  23. A[n]=-1;
  24. for(int i=1,p=1; i<=n; ++i) d[i]=(p==i&&mid>A[p])?mid:A[p++], sum[i]=sum[i-1]+d[i];
  25. LL vl,vr;
  26. for(int k=1,p=n; k<=n; ++k)
  27. {
  28. while(p>k && d[p]<k) --p;
  29. vl=sum[k], vr=1ll*k*(k-1)+1ll*(std::max(p,k)-k)*k+sum[n]-sum[std::max(p,k)];
  30. if(vl>vr) return mid<d[k]?-1:1;
  31. }
  32. return 0;
  33. }
  34. int main()
  35. {
  36. int n=read(),parity=0;
  37. for(int i=1; i<=n; ++i) parity^=(A[i]=read())&1;
  38. std::sort(A+1,A+1+n,std::greater<int>());
  39. int l=0,r=n-parity>>1,L=0,R=-1,mid;
  40. while(l<=r)
  41. if(Check(n+1,(mid=l+r>>1)*2+parity)>=0) L=mid, r=mid-1;
  42. else l=mid+1;
  43. l=0,r=n-parity>>1;
  44. while(l<=r)
  45. if(Check(n+1,(mid=l+r>>1)*2+parity)<=0) R=mid, l=mid+1;
  46. else r=mid-1;
  47. if(L>R) puts("-1");
  48. else for(int i=L; i<=R; ++i) printf("%d ",i*2+parity);
  49. return 0;
  50. }

F.New Year and the Mallard Expedition(贪心)

写了近一天,改了4遍越改越麻烦...mmp...

其实很好写...

先假设所有路程都飞过去,能量不够等会再补。则此时的答案为\(ans=\sum\limits_{i=1}^nL_i\)。

然后从\(i=1\sim n\)枚举。如果此时的能量不够飞\(L_i\)的距离,就从之前补。

所以记\(W,G\)分别表示之前飞过的\(water\)有多少、之前飞过的\(grass\)有多少。

显然能量来自,将飞过的\(W\)路程变成游过去,还不够的话将飞过的\(G\)路程变成走过去,再不够的话,如果出现过\(water\)就来回游补够能量,没出现过\(water\)就在\(grass\)来回走补够能量。

所以对于\(L_i\),我们需要从\(W\)转移过来的能量有\(t=\min\{L_i,2W\}\)(\(W\)的路程能变成\(2W\)能量,因为是将原先的飞替换成游),也就是需要将之前\(\frac t2\)路程的飞变为游泳,来获得这\(t\)能量。所以\(ans\)+=\(\frac t2\times2\),\(W\)-=\(\frac t2\)(为了避免小数将\(W\)*=\(2\),此时就是\(W\)-=\(t\))。

如果此时\(L_i-t\)仍不为\(0\),那么同样从\(G\)转移。

还不为\(0\),则如上所述来回游/走。

  1. //46ms 1000KB
  2. #include <cstdio>
  3. #include <cctype>
  4. #include <algorithm>
  5. #define gc() getchar()
  6. typedef long long LL;
  7. const int N=1e5+5,Ref1[3]={5,3,1},Ref2[3]={1,3,1};
  8. int mp[N];
  9. LL A[N];
  10. inline LL read()
  11. {
  12. LL now=0;register char c=gc();
  13. for(;!isdigit(c);c=gc());
  14. for(;isdigit(c);now=now*10+c-'0',c=gc());
  15. return now;
  16. }
  17. int main()
  18. {
  19. int n=read(); LL ans=0;
  20. for(int i=1; i<=n;++i) ans+=A[i]=read();
  21. register char c=gc(); while(c!='W'&&c!='G'&&c!='L') c=gc();
  22. //Grass:0 Water:1 Lava:2
  23. mp[1]=c=='L'?2:c=='W';
  24. for(int i=2; i<=n;++i) c=gc(), mp[i]=c=='L'?2:c=='W';
  25. LL W=0,G=0;
  26. for(int i=1,cost=5; i<=n; ++i)
  27. {
  28. if(!mp[i]) G+=A[i]<<1;
  29. else if(mp[i]==1) W+=A[i]<<1, cost=3;
  30. LL rest=A[i],t;
  31. t=std::min(rest,W), rest-=t, ans+=t, W-=t;
  32. t=std::min(rest,G), rest-=t, ans+=t<<1, G-=t;
  33. ans+=rest*cost;
  34. }
  35. printf("%I64d\n",ans);
  36. return 0;
  37. }

咕咕


H.New Year and the Tricolore Recreation(博弈论 bitset)

\(Description\)

Alice和Bob玩游戏。给定\(n,f\),表示有\(n\)行的棋盘,每行有三个棋子。Alice每次可以选择一行将该行左边的一个或两个棋子往右移动\(d\)步,Bob每次可以选择一行将该行右边的一个或两个棋子往左移动\(d\)步。

要求移动时一个棋子不能跨越另一个棋子,且\(d\)是质数或两个质数的乘积,且\(d\neq f\)。求出Alice和Bob分别作为先手时,谁能赢。

\(n\leq10^5,\ 坐标绝对值\leq10^5\)。

\(Solution\)

右移一个棋子就是缩小第二三两个棋子之间的距离,右移两个棋子就是缩小一二两个棋子之间的距离。设三个棋子位置为\(a,b,c\),每一行实际就是两个棋子数为\(c-b-1,b-a-1\)的\(nim\)游戏。

如果能算出棋子数为\(x\)的游戏的\(SG\)函数,将\(2n\)个游戏的\(sg\)值全异或起来即可。考虑如何算,显然有\(sg(x)=\mathbb{mex}_{d\in P}\{sg(x-d)\}\),但是复杂度是\(n^2\)的。

打个表发现,\(sg\)值最大不会超过\(100\)(我也不知道怎么能得出的)。我们开\(100\)个\(bitset\ A[i]\),分别表示每个数字是否存在\(sg\)值为\(i\)的后继。再预处理\(d\in P\)的\(bitset\ S\)。这样从小到大求\(sg(i)\)时,就for一遍看它不存在哪个\(sg\)值的后继;然后\(A[sg(i)]|=S<<i\)即可(更新上能到\(i\)的位置)。

复杂度\(O(\frac{n^2}{w})\)。

  1. //1638ms 4700KB
  2. #include <cstdio>
  3. #include <cctype>
  4. #include <bitset>
  5. #include <algorithm>
  6. #define gc() getchar()
  7. #define MAXIN 500000
  8. //#define gc() (SS==TT&&(TT=(SS=IN)+fread(IN,1,MAXIN,stdin),SS==TT)?EOF:*SS++)
  9. typedef long long LL;
  10. const int N=2e5+1,M=102;
  11. int sg[N];
  12. std::bitset<N> S,A[M];
  13. char IN[MAXIN],*SS=IN,*TT=IN;
  14. inline int read()
  15. {
  16. int now=0,f=1;register char c=gc();
  17. for(;!isdigit(c);c=='-'&&(f=-1),c=gc());
  18. for(;isdigit(c);now=now*10+c-48,c=gc());
  19. return now*f;
  20. }
  21. void Init()
  22. {
  23. static int P[N],mn[N];
  24. int cnt=0;
  25. for(int i=2; i<N; ++i)
  26. {
  27. if(!mn[i]) P[++cnt]=i;
  28. for(int j=1; j<=cnt&&i*P[j]<N; ++j)
  29. {
  30. mn[i*P[j]]=i;
  31. if(!(i%P[j])) break;
  32. }
  33. }
  34. for(int i=2; i<N; ++i) if(!mn[mn[i]]) S[i]=1;
  35. }
  36. int main()
  37. {
  38. int n=read(); Init(), S[read()]=0;
  39. for(int i=0; i<N; ++i)
  40. {
  41. while(A[sg[i]][i]) ++sg[i];
  42. A[sg[i]]|=S<<i;
  43. }
  44. int ans=0;
  45. for(int a,b,c; n--; ) a=read(),b=read(),c=read(),ans^=sg[b-a-1]^sg[c-b-1];
  46. puts(ans?"Alice\nBob":"Bob\nAlice");
  47. return 0;
  48. }

Good Bye 2018 (A~F, H)的更多相关文章

  1. Codeforces Good Bye 2018

    咕bye 2018,因为我这场又咕咕咕了 无谓地感慨一句:时间过得真快啊(有毒 A.New Year and the Christmas Ornament 分类讨论后等差数列求和 又在凑字数了 #in ...

  2. Codeforces:Good Bye 2018(题解)

    Good Bye 2018! 题目链接:https://codeforces.com/contest/1091 A. New Year and the Christmas Ornament 题意: 给 ...

  3. ZOJ 4009 And Another Data Structure Problem(ZOJ Monthly, March 2018 Problem F,发现循环节 + 线段树 + 永久标记)

    题目链接  ZOJ Monthly, March 2018 Problem F 题意很明确 这个模数很奇妙,在$[0, mod)$的所有数满足任意一个数立方$48$次对$mod$取模之后会回到本身. ...

  4. Good Bye 2018题解

    Good Bye 2018题解 题解 CF1091A [New Year and the Christmas Ornament] 打完cf都忘记写题解了qwq 题意就是:给你一些黄,蓝,红的球,满足蓝 ...

  5. Good Bye 2018

    Good Bye 2018 2018年最后一场CF,OVER! 弱弱的我只能做出3道A,B,D~~~~ 最后几分钟,感觉找到了C题的规律,结束的那一刻,提交了一发 "Wrong answer ...

  6. Good Bye 2018 C. New Year and the Sphere Transmission

    传送门 https://www.cnblogs.com/violet-acmer/p/10201535.html 题意: n 个people,编号1~n,按顺时针方向围城一圈: 初始,编号为1的peo ...

  7. 2016CCPC长春 - B/D/F/H/I/J/K - (待补)

    目录: B - Fraction D - Triangle F - Harmonic Value Description H - Sequence I I - Sequence II B题:HDU 5 ...

  8. Good Bye 2018 Solution

    A. New Year and the Christmas Ornament 签到. #include <bits/stdc++.h> using namespace std; int a ...

  9. 2019牛客暑期多校训练营(第七场)E F H I

    E Find the median 题意:每次往序列中增加连续的[l,r]的数,每加入一次就询问当前序列的中位数. 解法:此题没有要求在线,那么直接离线+线段树+二分就可以了.求出每个端点之后排序得到 ...

随机推荐

  1. lightoj1197 素数双筛,可以参考poj的那题双筛

    /* 判断一个数是否是素数,只要判断这个数有没有在[2,sqrt(n)]区间的因子 同样,对于大数短区间的筛选,同样可以用这种判断方式, 先筛出sqrt(n)范围内的素数,然后用这些素数去筛出区间内的 ...

  2. lightoj1259 线性筛的另一种写法 v变成bool标记数组

    也是用线性筛,但是v用int会爆,所以这个线性筛用的是另外一种写法 #include<cstdio> #include<cmath> #include<queue> ...

  3. yii2 Menu组件的使用

    1.首先引入类 use yii\widgets\Menu; 2.配置组件 <?php echo Menu::widget([ //ul的样式以及相应的属性 'options' => ['c ...

  4. c++与java的几个不同点

    Java.C.C++在近两年一直稳居世界编程语言排行榜前三名.Java与c++都是面向对象的语言,但Java晚于C++发布,部分语法和思想也参考了C++,只是Java 没有头文件.指针.运算符重载.虚 ...

  5. OrCAD Capture CIS 为库里的元器件添加新属性

    1.进入元器件编辑界面 2.菜单:Options > Part Properties... 3.在窗口User Properties中,点击按钮New... 4.在弹出的子窗口NewProper ...

  6. AI-restful接口写法

    AI-restful接口写法 restful接口规范 http协议请求方式:GET POST DELETE PUT PATCH OPTION HEAD 设计接口时必须使用这种格式的数据 GET 查看数 ...

  7. Html列表分页算法

    public class PageHelper { /// <summary> /// 标签 /// </summary> public string Tag { get; s ...

  8. openCV 备忘

    yum install python-devel numpy cmake gcc gcc-c++yum install gtk2-devel libdc1394-devel libv4l-devel ...

  9. POJ 2243 简单搜索 (DFS BFS A*)

    题目大意:国际象棋给你一个起点和一个终点,按骑士的走法,从起点到终点的最少移动多少次. 求最少明显用bfs,下面给出三种搜索算法程序: // BFS #include<cstdio> #i ...

  10. js 给定时间,如'2013-08-30',换算和今天的天数差

    由于项目中需要用到给定时间格式,如'2013-08-30',需要计算其和当前时间的间隔,需要算出间隔的时间,自己在网上搜索,并做了下简单的整理,总体思路分3步:1.将给定的时间和当前时间转换为毫秒 2 ...