http://codeforces.com/contest/1073

A. Diverse Substring

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define minv 1e-6
  5. #define inf 1e9
  6. #define pi 3.1415926536
  7. #define nl 2.7182818284
  8. const ll mod=1e9+;//
  9. const int maxn=1e3+;
  10.  
  11. char s[maxn];
  12.  
  13. int main()
  14. {
  15. int n,i;
  16. scanf("%d",&n);
  17. scanf("%s",s);
  18. for (i=;i<=n-;i++)
  19. if (s[i]!=s[i+])
  20. break;
  21. if (i==n-)
  22. printf("NO");
  23. else
  24. {
  25. printf("YES\n");
  26. printf("%c%c",s[i],s[i+]);
  27. }
  28. return ;
  29. }

B. Vasya and Books

  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4. const int maxn=2e5+;
  5.  
  6. int f[maxn];
  7.  
  8. int main()
  9. {
  10. int n,a,v=,i;
  11. scanf("%d",&n);
  12. for (i=;i<=n;i++)
  13. {
  14. scanf("%d",&a);
  15. f[a]=i;
  16. }
  17. for (i=;i<=n;i++)
  18. {
  19. scanf("%d",&a);
  20. if (i!=)
  21. printf(" ");
  22. if (f[a]<v)
  23. printf("");
  24. else
  25. printf("%d",f[a]-v);
  26. v=max(f[a],v);
  27. }
  28. return ;
  29. }

C. Vasya and Robot

奇偶,负数取模

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. const int maxn=2e5+;
  5. const ll inf=1e9;
  6.  
  7. int px[maxn],py[maxn];
  8.  
  9. int main()
  10. {
  11. char c;
  12. int n,x,y,ax,ay,i,l,r,m,re;
  13. scanf("%d\n",&n);
  14. for (i=;i<=n;i++)
  15. {
  16. scanf("%c",&c);
  17. if (c=='U')
  18. x=,y=;
  19. else if (c=='D')
  20. x=,y=-;
  21. else if (c=='L')
  22. x=-,y=;
  23. else
  24. x=,y=;
  25. px[i]=px[i-]+x;
  26. py[i]=py[i-]+y;
  27. }
  28. scanf("%d%d",&ax,&ay);
  29. if (px[n]==ax && py[n]==ay)
  30. {
  31. printf("");
  32. return ;
  33. }
  34. if (abs(ax+ay+n)%==)
  35. {
  36. printf("-1");
  37. return ;
  38. }
  39. re=inf;
  40. for (i=;i<=n;i++)
  41. {
  42. l=i;
  43. r=n;
  44. while (l<=r)
  45. {
  46. m=(l+r)>>;
  47. ///change [i,m] ; use [1,i-1] [m+1,n]
  48. if (m-i+>=abs(px[i-]+px[n]-px[m]-ax)+abs(py[i-]+py[n]-py[m]-ay))
  49. r=m-;
  50. else
  51. l=m+;
  52. }
  53. if (l!=n+)
  54. re=min(re,l-i+);
  55. }
  56. if (re==inf)
  57. re=-;
  58. printf("%d",re);
  59. return ;
  60. }

D. Berland Fair

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. const int maxn=2e5+;
  5.  
  6. int nex[maxn],a[maxn];
  7.  
  8. int main()
  9. {
  10. int n,i,j,g;
  11. ll m,tot=,num=;
  12. scanf("%d%lld",&n,&m);
  13.  
  14. for (i=;i<n;i++)
  15. scanf("%d",&a[i]),tot+=a[i];
  16. for (i=;i<n;i++)
  17. nex[i]=(i+)%n;
  18. g=n;
  19. i=;
  20. j=n-;
  21. while (nex[i]!=i)
  22. {
  23. num+=m/tot*g;
  24. m%=tot;
  25. while (nex[i]!=i)
  26. {
  27. if (a[i]<=m)
  28. {
  29. m-=a[i];
  30. num++;
  31. j=i;
  32. }
  33. else
  34. {
  35. nex[j]=nex[i];
  36. tot-=a[i];
  37. g--;
  38. }
  39. i=nex[i];
  40. if (m>=tot)
  41. break;
  42. }
  43. }
  44. num+=m/a[i];
  45. cout<<num;
  46. return ;
  47. }
  48. /*
  49. 1 100
  50. 1
  51.  
  52. 3 1000
  53. 1 2 100
  54. */

E. Segment Sum

代码是错的,以待后续埋坑

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. const ll mod=;
  5. const double minv=1e-;
  6.  
  7. ll sum=,shi[],k,f[][];
  8.  
  9. void work(ll a,int w,int g,int hav,ll num,int ori,int cond)
  10. {
  11. int s,gg,i,j,c;
  12. if (a==)
  13. return;
  14. s=a/shi[w];
  15. for (i=;i<=s;i++)
  16. {
  17. gg=g-(!((hav>>i) & ) && (!(i== && ori==)));
  18. if (gg>=)
  19. {
  20. if (i<s)
  21. {
  22. /**
  23. 这一位选的是i,
  24. 除去这一位,还有w位,
  25. 从gg个数中选j个数作为需要添加的数(之前没出现过的),
  26. 每一位都有k-gg+j种选择
  27. **/
  28. f[][]=;
  29. for (j=;j<=w;j++)
  30. {
  31. f[j][]=f[j-][]*(k-gg)%mod;
  32. ///already k-gg numbers
  33. sum=(sum+f[j-][]* sum of k-gg numbers )%mod;
  34.  
  35. for (c=;c<=min(gg,j);c++)
  36.  
  37. sum=(sum+f[j-][c]* k-gg+c numbers + f[j-][c-]* any number(random average of gg numbers))
  38.  
  39. f[j][c]=(f[j-][c]*(k-gg+c)+f[j-][c-]*(-(k-gg+c-)))%mod;
  40. }
  41. for (c=;c<=min(gg,w);c++)
  42. sum=(sum+f[w][c]*cond)%mod;
  43.  
  44. ///geshu
  45. // f[0][0]=1;
  46. // for (j=1;j<=w;j++)
  47. // {
  48. // f[j][0]=f[j-1][0]*(k-gg)%mod;
  49. // for (c=1;c<=min(gg,j);c++)
  50. // f[j][c]=(f[j-1][c]*(k-gg+c)+f[j-1][c-1]*(10-(k-gg+c-1)))%mod;
  51. // }
  52. // for (c=0;c<=min(gg,w);c++)
  53. // sum=(sum+f[w][c]*cond)%mod;
  54. }
  55. else
  56. work(a%shi[w],w-,gg,hav|(<<i),ori&(i==),cond);
  57. }
  58. }
  59. }
  60.  
  61. int main()
  62. {
  63. ll l,r;
  64. int i,w;
  65. scanf("%lld%lld%d",&l,&r,&k);
  66. shi[]=;
  67. for (i=;i<=;i++)
  68. shi[i]=shi[i-]*;
  69.  
  70. w=log(r+minv)/log();
  71. work(r,w,k,,,,);
  72. if (l!=)
  73. {
  74. w=log(l-+minv)/log();///l=1???
  75. work(l-,w,k,,,,-);
  76. }
  77. printf("%lld",(sum+mod)%mod);
  78. return ;
  79. }

Educational Codeforces Round 53 (Rated for Div. 2)的更多相关文章

  1. Educational Codeforces Round 53 (Rated for Div. 2) (前五题题解)

    这场比赛没有打,后来补了一下,第五题数位dp好不容易才搞出来(我太菜啊). 比赛传送门:http://codeforces.com/contest/1073 A. Diverse Substring ...

  2. Educational Codeforces Round 53 (Rated for Div. 2) E. Segment Sum (数位dp求和)

    题目链接:https://codeforces.com/contest/1073/problem/E 题目大意:给定一个区间[l,r],需要求出区间[l,r]内符合数位上的不同数字个数不超过k个的数的 ...

  3. [codeforces][Educational Codeforces Round 53 (Rated for Div. 2)D. Berland Fair]

    http://codeforces.com/problemset/problem/1073/D 题目大意:有n个物品(n<2e5)围成一个圈,你有t(t<1e18)元,每次经过物品i,如果 ...

  4. Educational Codeforces Round 53 (Rated for Div. 2) E. Segment Sum

    https://codeforces.com/contest/1073/problem/E 题意 求出l到r之间的符合要求的数之和,结果取模998244353 要求:组成数的数位所用的数字种类不超过k ...

  5. Educational Codeforces Round 53 (Rated for Div. 2) C. Vasya and Robot 【二分 + 尺取】

    任意门:http://codeforces.com/contest/1073/problem/C C. Vasya and Robot time limit per test 1 second mem ...

  6. Educational Codeforces Round 53 (Rated for Div. 2)G. Yet Another LCP Problem

    题意:给串s,每次询问k个数a,l个数b,问a和b作为后缀的lcp的综合 题解:和bzoj3879类似,反向sam日神仙...lcp就是fail树上的lca.把点抠出来建虚树,然后在上面dp即可.(感 ...

  7. Educational Codeforces Round 53 (Rated for Div. 2) D. Berland Fair

    题意:一个人  有T块钱 有一圈商店 分别出售 不同价格的东西  每次经过商店只能买一个  并且如果钱够就必须买 这个人一定是从1号店开始的!(比赛的时候读错了题,以为随意起点...)问可以买多少个 ...

  8. Educational Codeforces Round 53 (Rated for Div. 2) C. Vasya and Robot

    题意:给出一段操作序列 和目的地 问修改(只可以更改 不可以删除或添加)该序列使得最后到达终点时  所进行的修改代价最小是多少 其中代价的定义是  终点序号-起点序号-1 思路:因为代价是终点序号减去 ...

  9. Educational Codeforces Round 53 (Rated for Div. 2) A Diverse Substring

    传送门 https://www.cnblogs.com/violet-acmer/p/10163375.html 题意: 给出串是多态的定义“长度为 n 的串 s ,当串 s 中所有字母出现的次数严格 ...

随机推荐

  1. WampServer的安装和配置

    1.安装WampServer 启动时发现WampServer的图标是红色的,状态为put offline状态:发现无法put online,并报错could not found the menu it ...

  2. AngularJS从入门到精通

    第一 AngularJS的四大特性 1. MVC 例如:使用angularjs向模板传递数据 <!doctype html> <html> <head> <m ...

  3. C#后台绑定select

  4. C# WebSocket模拟发送接收

    WebSocket服务端 C#示例代码 using System; using System.Collections.Generic; using System.Linq; using System. ...

  5. 官网下载旧版本jdk,老版本jdk,jdk1.7,jdk1.8

    1.进入中文oracle官网(不是国内官网下载速度超级慢): http://www.oracle.com/technetwork/cn/indexes/downloads/index.html 2.进 ...

  6. Html5 拖拽api

    拖拽要有两个元素,一个是要拖动的元素,一个是要放置到的元素. 1, 在默认情况下, 只有图片和文字是可以拖拽的,其它元素都不可以.因此要想使一个元素可拖动,必须设置它的draggable 属性为tru ...

  7. Java拦截器

    拦截器,主要用于拦截前端请求,常用于登录检查. 下面是演示使用拦截器拦截未登录的用户访问需要登录的模块情景,使用配置方式实现和注解方式实现代码: 配置方式: 1.web.xml中配置监听器,对于所有的 ...

  8. 【C/C++】递归算法

    所谓递归——函数的递归调用.c语言的这种特性给程序设计带来许多方便.尤其是接触数据结构时,会发现递归的出现频率非常之高,也行之有效~下面是笔者在接触递归这个东西时的一些个人总结和体会: 1.直接或间接 ...

  9. Kafka消费时报错:Producer connection to xxx:9092 unsuccessful

    使用kafka消费数据时报Producer错误,具体错误如下: kafka.producer.SyncProducer:103 Producer connection to xxx:9092 unsu ...

  10. Git——简说.git目录【五】

    我们都知道初始化项目时,会生成一个.git的隐藏目录,那么这个目录究竟放了那些东西呢,又有什么作用呢?现在我们就来看看. HEAD HEAD指向的是当前工作所在的分支 $ cat HEAD ref: ...