Educational Codeforces Round 8
开始填坑_(:з」∠)_
628A - Tennis Tournament 20171124
小学数学题,\((x,y)=((n-1)\cdot(2b+1),np)\)
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,b,p,x,y;
int main()
{
scanf("%d%d%d",&n,&b,&p);
x=(n-)*(*b+),y=n*p;
printf("%d %d\n",x,y);
return ;
}
628B - New Skateboard 20171124
由于能根据末尾的两个数字判断出是否为4的倍数,直接每相邻两位判断一下就好了
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
string s;
LL ans;
bool check(int k){return k%==;}
int main()
{
cin>>s;
ans=check(s[]-'');
for(LL i=;i<s.size();i++)
ans+=check(s[i]-''),ans+=i*check(s[i-]*+s[i]);
printf("%I64d\n",ans);
return ;
}
628C - New Skateboard 20171124
让每一位修改产生的距离尽可能大即可
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int n,k,f[];
int main()
{
scanf("%d%d",&n,&k);
cin>>s;
for(int i=;i<=n;i++)
f[i]=max(s[i-]-'a','z'-s[i-])+f[i-];
if(f[n]<k)return printf("-1\n"),;
for(int i=;i<n;i++)
{
if(k>=f[i+]-f[i])
s[i]=(s[i]-'a'>'z'-s[i])?'a':'z';
else s[i]=(s[i]-k>='a')?s[i]-k:s[i]+k;
k-=f[i+]-f[i];if(k<=)break;
}
cout<<s<<endl;return ;
}
628D - Magic Numbers 20190301
比较恶心的DP,首先将区间\((l,r)\)的询问转化为两次对区间\((1,n)\)的询问
令\(f[i][j][k]\)表示当前进行到第\(i\)位,除以\(m\)的余数为\(j\)时,与\(n\)的大小关系为\(k\)的方案数
循环时\(i\)从\(1\)到\(n\),通过枚举第\(i\)位的数字来推出\(j\)进行转移
接下去就是各种细节处理了
#include<bits/stdc++.h>
using namespace std;
#define N 2005
#define LL long long
#define MOD 1000000007
LL m,d,f[N][N][],ans;
char s[N];
LL rua()
{
LL n=strlen(s+);
memset(f,,sizeof(f));
for(LL j=;j<=;j++)if(j!=d)
{
if(j<s[]-'')f[][j%m][]++;
if(j==s[]-'')f[][j%m][]++;
if(j>s[]-'')f[][j%m][]++;
}
for(LL i=;i<n;i++)
for(LL j=;j<m;j++)
for(LL k=;k<;k++)if(f[i][j][k])
{
//cout<<i<<" "<<j<<" "<<k<<" "<<f[i][j][k]<<endl;
if(i&)
{
if(k==)(f[i+][(j*10ll+d)%m][k]+=f[i][j][k])%=MOD;
if(k==)
{
if(d<s[i+]-'')(f[i+][(j*10ll+d)%m][]+=f[i][j][k])%=MOD;
else if(d==s[i+]-'')(f[i+][(j*10ll+d)%m][]+=f[i][j][k])%=MOD;
else if(d>s[i+]-'')(f[i+][(j*10ll+d)%m][]+=f[i][j][k])%=MOD;
}
if(k==)(f[i+][(j*10ll+d)%m][k]+=f[i][j][k])%=MOD;
continue;
}
for(LL l=;l<=;l++)if(l!=d)
{
if(k==)(f[i+][(j*10ll+l)%m][k]+=f[i][j][k])%=MOD;
if(k==)
{
if(l<s[i+]-'')(f[i+][(j*10ll+l)%m][]+=f[i][j][k])%=MOD;
else if(l==s[i+]-'')(f[i+][(j*10ll+l)%m][]+=f[i][j][k])%=MOD;
else if(l>s[i+]-'')(f[i+][(j*10ll+l)%m][]+=f[i][j][k])%=MOD;
}
if(k==)(f[i+][(j*10ll+l)%m][k]+=f[i][j][k])%=MOD;
}
}
LL res=;
//for(LL j=0;j<m;j++)for(LL k=0;k<2;k++)if(f[n][j][k])cout<<n<<" "<<j<<" "<<k<<" "<<f[n][j][k]<<endl;
for(LL i=;i<n;i++)
for(LL k=;k<;k++)
(res+=f[i][][k])%=MOD;
(res+=f[n][][]+f[n][][])%=MOD;
return res;
}
bool check()
{
LL n=strlen(s+);
for(LL i=;i<=n;i++)
{
if((i&) && s[i]==d+'')
return false;
if(i%== && s[i]!=d+'')
return false;
}
LL r=;
for(LL i=;i<=n;i++)
r=(r*+s[i]-'')%m;
return r==;
}
int main()
{
scanf("%I64d%I64d",&m,&d);
scanf("%s",s+);
ans=MOD-rua()+check();
//cout<<rua()<<endl;
scanf("%s",s+);
ans+=rua();
//cout<<rua()<<endl;
return printf("%I64d\n",ans%MOD),;
}
628E - Zbazi in Zeydabad 20190305
这题只能说。。。bitset大法好,莽就完事了
#include<bits/stdc++.h>
using namespace std;
#define N 3005
#define LL long long
LL n,m,ans;
bitset<N>a[N],b[N],c[N];
int get()
{
char ch=getchar();
while(ch!='.' && ch!='z')ch=getchar();
return ch=='z';
}
int main()
{
scanf("%I64d%I64d",&n,&m);
for(LL i=;i<n;i++)
for(LL j=;j<m;j++)
a[i][m-j-]=get(),b[i].set(),c[i].set();
for(LL i=;i<min(m,n);i++)
{
for(LL j=;j<n;j++)b[j]&=a[j]>>i;
for(LL j=;j<n-i;j++)c[j]&=a[j+i]>>i,ans+=(b[j]&b[j+i]&c[j]).count();
}
return printf("%I64d\n",ans),;
}
628F - Bear and Fair Set 20190306
标解是网络流,但是有种瞎搞的方法不知道为什么能过_(:з」∠)_
考虑\(\{0,1,2,3,4\}\)的所有子集\(A\),对每个区间,计算出满足\(i\%5\epsilon A\)的\(i\)的个数,并与该区间可取数字的个数取\(min\),加起来后若个数小于\(\frac{|A|\cdot n}{5}\),则一定无解
若考虑完所有子集后依旧没有出现不合法的情况,则一定有解(本弱不会证,求大佬证明)
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
int nn,n,b,q;
vector<pair<int,int> >d;
int main()
{
d.push_back(mp(,));
scanf("%d%d%d",&n,&b,&q),nn=n;
d.push_back(mp(b,n));
for(int i=;i<=q;i++)scanf("%d%d",&b,&n),d.push_back(mp(b,n));
sort(d.begin(),d.end());
for(int i=;i<=q;i++)
if(d[i].second>d[i+].second || d[i+].second-d[i].second>d[i+].first-d[i].first)
return printf("unfair\n"),;
for(int k=;k<;k++)
{
int res=;
for(int i=;i<=q+;i++)
{
int cnt=;
for(int j=d[i-].first+;j<=d[i].first;j++)
cnt+=bool((<<(j%))&k);
res+=min(cnt,d[i].second-d[i-].second);
}
if(res<nn/*__builtin_popcount(k))return printf("unfair\n"),;
}
printf("fair\n");
return ;
}
Educational Codeforces Round 8的更多相关文章
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
- [Educational Codeforces Round 16]C. Magic Odd Square
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...
- [Educational Codeforces Round 16]B. Optimal Point on a Line
[Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...
- [Educational Codeforces Round 16]A. King Moves
[Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...
- Educational Codeforces Round 6 C. Pearls in a Row
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...
- Educational Codeforces Round 9
Educational Codeforces Round 9 Longest Subsequence 题目描述:给出一个序列,从中抽出若干个数,使它们的公倍数小于等于\(m\),问最多能抽出多少个数, ...
- Educational Codeforces Round 37
Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
随机推荐
- PostgreSQL学习笔记(一)-安装PostgreSQL
PostgreSQL官网:https://www.postgresql.org/docs/11/index.html1.如何安装2.如何修改配置文件3.如何设置自动启动4.如何修改数据用户密码 本文环 ...
- 机器学习基石12-Nonlinear Transformation
注: 文章中所有的图片均来自台湾大学林轩田<机器学习基石>课程. 笔记原作者:红色石头 微信公众号:AI有道 上一节课介绍了分类问题的三种线性模型,可以用来解决binary classif ...
- CSS 左右两边底部对齐
https://demo.cssworld.cn/4/3-2.php <style type="text/css"> .parent{ width:500px; tex ...
- arm寄存器
ARM 处理器拥有 37 个寄存器. 这些寄存器按部分重叠组方式加以排列. 每个处理器模式都有一个不同的寄存器组. 编组的寄存器为处理处理器异常和特权操作提供了快速的上下文切换. 提供了下列寄存器:三 ...
- 解决svn更新项目目录时“Error:svn: E155037: Previous operation has not finished; run 'cleanup' if it was interrupted”的报错问题
今天在IDEA更新项目目录时,发现报错“Error:svn: E155037: Previous operation has not finished; run 'cleanup' if it was ...
- Flink写入kafka时,只写入kafka的部分Partitioner,无法写所有的Partitioner问题
1. 写在前面 在利用flink实时计算的时候,往往会从kafka读取数据写入数据到kafka,但会发现当kafka多个Partitioner时,特别在P量级数据为了kafka的性能kafka的节点有 ...
- sql 选取分组中的第一条,显示聚合以外的列,having字句的使用
分组中的第一条:select * from(select row_number() over(partition by 列1,列2,... order by 列1,列2,...) as rownum ...
- Emsemble
RM # -*- coding: utf-8 -*- """ RandomForestClassifier 예 """ import pan ...
- SQL注入绕WAF总结
0x00 前言 在服务器客户端领域,曾经出现过一款360主机卫士,目前已停止更新和维护,官网都打不开了,但服务器中依然经常可以看到它的身影.从半年前的测试虚拟机里面,翻出了360主机卫士Apache版 ...
- kvm虚拟机迁移
一.迁移简介 迁移: 系统的迁移是指把源主机上的操作系统和应用程序移动到目的主机,并且能够在目的主机上正常运行.在没有虚拟机的时代,物理机之间的迁移依靠的是系统备份和恢复技术.在源主机上实时备份操作系 ...