http://codeforces.com/contest/1073

A. Diverse Substring

 #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e9
#define pi 3.1415926536
#define nl 2.7182818284
const ll mod=1e9+;//
const int maxn=1e3+; char s[maxn]; int main()
{
int n,i;
scanf("%d",&n);
scanf("%s",s);
for (i=;i<=n-;i++)
if (s[i]!=s[i+])
break;
if (i==n-)
printf("NO");
else
{
printf("YES\n");
printf("%c%c",s[i],s[i+]);
}
return ;
}

B. Vasya and Books

 #include <iostream>
#include <cstdio>
using namespace std;
const int maxn=2e5+; int f[maxn]; int main()
{
int n,a,v=,i;
scanf("%d",&n);
for (i=;i<=n;i++)
{
scanf("%d",&a);
f[a]=i;
}
for (i=;i<=n;i++)
{
scanf("%d",&a);
if (i!=)
printf(" ");
if (f[a]<v)
printf("");
else
printf("%d",f[a]-v);
v=max(f[a],v);
}
return ;
}

C. Vasya and Robot

奇偶,负数取模

 #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+;
const ll inf=1e9; int px[maxn],py[maxn]; int main()
{
char c;
int n,x,y,ax,ay,i,l,r,m,re;
scanf("%d\n",&n);
for (i=;i<=n;i++)
{
scanf("%c",&c);
if (c=='U')
x=,y=;
else if (c=='D')
x=,y=-;
else if (c=='L')
x=-,y=;
else
x=,y=;
px[i]=px[i-]+x;
py[i]=py[i-]+y;
}
scanf("%d%d",&ax,&ay);
if (px[n]==ax && py[n]==ay)
{
printf("");
return ;
}
if (abs(ax+ay+n)%==)
{
printf("-1");
return ;
}
re=inf;
for (i=;i<=n;i++)
{
l=i;
r=n;
while (l<=r)
{
m=(l+r)>>;
///change [i,m] ; use [1,i-1] [m+1,n]
if (m-i+>=abs(px[i-]+px[n]-px[m]-ax)+abs(py[i-]+py[n]-py[m]-ay))
r=m-;
else
l=m+;
}
if (l!=n+)
re=min(re,l-i+);
}
if (re==inf)
re=-;
printf("%d",re);
return ;
}

D. Berland Fair

 #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+; int nex[maxn],a[maxn]; int main()
{
int n,i,j,g;
ll m,tot=,num=;
scanf("%d%lld",&n,&m); for (i=;i<n;i++)
scanf("%d",&a[i]),tot+=a[i];
for (i=;i<n;i++)
nex[i]=(i+)%n;
g=n;
i=;
j=n-;
while (nex[i]!=i)
{
num+=m/tot*g;
m%=tot;
while (nex[i]!=i)
{
if (a[i]<=m)
{
m-=a[i];
num++;
j=i;
}
else
{
nex[j]=nex[i];
tot-=a[i];
g--;
}
i=nex[i];
if (m>=tot)
break;
}
}
num+=m/a[i];
cout<<num;
return ;
}
/*
1 100
1 3 1000
1 2 100
*/

E. Segment Sum

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

 #include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=;
const double minv=1e-; ll sum=,shi[],k,f[][]; void work(ll a,int w,int g,int hav,ll num,int ori,int cond)
{
int s,gg,i,j,c;
if (a==)
return;
s=a/shi[w];
for (i=;i<=s;i++)
{
gg=g-(!((hav>>i) & ) && (!(i== && ori==)));
if (gg>=)
{
if (i<s)
{
/**
这一位选的是i,
除去这一位,还有w位,
从gg个数中选j个数作为需要添加的数(之前没出现过的),
每一位都有k-gg+j种选择
**/
f[][]=;
for (j=;j<=w;j++)
{
f[j][]=f[j-][]*(k-gg)%mod;
///already k-gg numbers
sum=(sum+f[j-][]* sum of k-gg numbers )%mod; for (c=;c<=min(gg,j);c++) sum=(sum+f[j-][c]* k-gg+c numbers + f[j-][c-]* any number(random average of gg numbers)) f[j][c]=(f[j-][c]*(k-gg+c)+f[j-][c-]*(-(k-gg+c-)))%mod;
}
for (c=;c<=min(gg,w);c++)
sum=(sum+f[w][c]*cond)%mod; ///geshu
// f[0][0]=1;
// for (j=1;j<=w;j++)
// {
// f[j][0]=f[j-1][0]*(k-gg)%mod;
// for (c=1;c<=min(gg,j);c++)
// f[j][c]=(f[j-1][c]*(k-gg+c)+f[j-1][c-1]*(10-(k-gg+c-1)))%mod;
// }
// for (c=0;c<=min(gg,w);c++)
// sum=(sum+f[w][c]*cond)%mod;
}
else
work(a%shi[w],w-,gg,hav|(<<i),ori&(i==),cond);
}
}
} int main()
{
ll l,r;
int i,w;
scanf("%lld%lld%d",&l,&r,&k);
shi[]=;
for (i=;i<=;i++)
shi[i]=shi[i-]*; w=log(r+minv)/log();
work(r,w,k,,,,);
if (l!=)
{
w=log(l-+minv)/log();///l=1???
work(l-,w,k,,,,-);
}
printf("%lld",(sum+mod)%mod);
return ;
}

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. C#通过Socket读取大量数据

    在C#中经常会用到Socket去接收和发送数据,而且也是非常方便的,有时候我们会向服务端去请求数据,如果返回的数据量很大,比如超过10M甚至是更多,那么该怎样去接收数据呢?下面以一个在项目中用到的实例 ...

  2. vscode实现vue.js项目的过程

    https://blog.csdn.net/weixin_37567150/article/details/81291433 https://blog.csdn.net/ywl570717586/ar ...

  3. redis.clients.jedis.exceptions.JedisDataException :READONLY You can't write

    分布式直连同步调用测试时出现的错误:主从复制架构下,默认Slave是只读的,如果写入则会报错: redis.clients.jedis.exceptions.JedisDataException: R ...

  4. SpringMVC 重定向到其他系统的页面的两种方式

    //测试重定向到另外的一个系统 @RequestMapping("/tttt") public void testRed(HttpServletResponse response) ...

  5. SQL Server 数据库try catch 存储过程

    SQL Server 在生产环境中这样写存储过程的坑都避免了吗? 原文链接: http://www.cnblogs.com/chenmh/p/7856777.html 概述 最近因为业务的需求写了一段 ...

  6. 在 ubuntu 中安装 python3.5、 tornado、 pymysql

    一.在 ubuntu 中安装 python3.5 1.首先,在系统中是自带python2.7的.不要卸载,因为一些系统的东西是需要这个的.python2.7和python3.5是可以共存的. 命令如下 ...

  7. centos6 nginx 安装【转】

    原文 https://www.cnblogs.com/yaoximing/p/6068622.html 1.下载nginx 方法一 wget http://nginx.org/download/ngi ...

  8. HUST 1555 数学作业

    参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6394892.html 1555 - A Math Homework 时间限制:1秒 内存限制:12 ...

  9. BZOJ3230 相似子串 【后缀数组】

    题目分析: 容易想到sa排好序之后,子串排名就是前面的子串减去height数组.所以正着做一遍,倒着做一遍就行了. 代码: #include<bits/stdc++.h> using na ...

  10. Codeforces963C Cutting Rectangle 【数学】

    错了一个小地方调了一晚上.... 题目大意: 给出最多2E+5种不同的矩形,每种有它的长h和宽v还有数量d,现在你要构造大矩形,使得在上面沿着平行于长或宽的边划刀,切出来的矩形正好是给出的所有矩形.问 ...