Codeforces 1091 Good Bye 2018
占个坑先,希望不要掉的太惨了吧,不要掉到上一次之前的rating
upt:flag竟然没到,开心。
A - New Year and the Christmas Ornament
好像没什么可说的。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<cctype>
using namespace std;
typedef long long ll;
const int Maxn=210000;
int main() {
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a+1<=b&&a+2<=c) {
printf("%d",3*a+3);
}
else if(b<=a+1&&b+1<=c) {
printf("%d",3*b);
}
else if(c<=a+2&&c<=b+1) {
printf("%d",3*c-3);
}
return 0;
}
B - New Year and the Treasure Geolocation
有一个显然的结论,x的最小值加的一定是最大的x变化量,y同理。因为数据保证有解那么直接找即可。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<cctype>
using namespace std;
typedef long long ll;
const int Maxn=210000;
int n,x[Maxn],y[Maxn],a[Maxn],b[Maxn];
int main() {
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&x[i],&y[i]);
sort(x+1,x+n+1),sort(y+1,y+n+1);
for(int i=1;i<=n;i++)
scanf("%d%d",&a[i],&b[i]);
sort(a+1,a+n+1),sort(b+1,b+n+1);
printf("%d %d\n",x[1]+a[n],y[1]+b[n]);
return 0;
}
C - New Year and the Sphere Transmission
考虑两个数产生的答案不同当且仅当他们与n的gcd不同,那么就枚举n的约数,然后计算即可,具体参考代码。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<cctype>
using namespace std;
typedef long long ll;
const int Maxn=210000;
int n,num;
ll x[Maxn];
void work(int n,int k) {
ll d=n/k;
x[++num]=n*(d-1)/2+d;
}
int main() {
scanf("%d",&n);
for(int i=1;i*i<=n;i++)
if(n%i==0) {
work(n,i);
work(n,n/i);
}
sort(x+1,x+num+1);
for(int i=1;i<=num;i++) if(x[i]!=x[i-1]) printf("%I64d ",x[i]);
return 0;
}
D - New Year and the Permutation Concatenation
瞎猜了一波规律就过了,具体也说不清楚。。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<cctype>
using namespace std;
typedef long long ll;
const int Maxn=2100000;
const int mod=998244353;
int n;
ll jc[Maxn],ans;
ll powp(ll a,ll b) {
ll ans=1;
while(b) {
if(b&1) ans=ans*a%mod;
a=a*a%mod;
b>>=1;
}
return ans;
}
ll C(int x,int y) {
return jc[x]*powp(jc[y],mod-2)%mod*powp(jc[x-y],mod-2)%mod;
}
int main() {
scanf("%d",&n);
jc[0]=1;
for(int i=1;i<=n;i++)
jc[i]=jc[i-1]*i%mod;
for(int i=0;i<=n;i++) ans=(ans+C(n,i)*(jc[i]-1)%mod*jc[n-i]%mod)%mod;
ans=(ans+1)%mod;
printf("%I64d\n",ans);
return 0;
}
E - New Year and the Acquaintance Estimation
这个就是根据题目里面的链接,根据里面的一个结论,设第\(i\)个点的度数为\(d_i\),将所有的点的度数排起来,即\(d_1\ge d_2 \ge \cdots \ge d_n\),那么这个图合法当且仅当对于所有的\(1\le k \le n\),满足\(\sum_{i=1}^kd_i\le k\cdot (k-1)+\sum_{i=k+1}^nmin(d_i,k)\),具体证明请参考题目里面的维基百科连接。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Maxn=2100000;
int n,d[Maxn],bj[Maxn],ans[Maxn],num;
ll pre[Maxn];
int main() {
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&d[i]);
sort(d,d+n);
for(int i=1;i<=n;i++) pre[i]=pre[i-1]+d[i-1];
int j=0;
for(int k=1;k<=n;k++) {
ll l=pre[n]-pre[n-k],r=(ll)k*(k-1);
while(j<n&&d[j]<k) j++;
r+=pre[min(j,n-k)]+1ll*max(0,n-k-j)*k;
ll now=d[n-k],diff=l-r;
if(diff<=k&&diff<=now) {
bj[max(diff,0ll)]++;
bj[now+1]--;
}
l-=d[n-k],r+=min(d[n-k],k);
diff=r-l;
if(diff>=now+1) {
bj[now+1]++;
bj[min(diff+1,(ll)n+1)]--;
}
}
j=0;
for(int i=0;i<=n;i++) {
j+=bj[i];
if(j==n&&(pre[n]+i&1)==0) ans[++num]=i;
}
if(num==0) puts("-1");
else for(int i=1;i<=num;i++) printf("%d ",ans[i]);
return 0;
}
F - New Year and the Mallard Expedition
这个就是贪心,首先每次走的距离都是半米的倍数,而且在岩浆上一定要用体力,如果体力不够的话就必须往回走,那么在水上走一定要比在地上走要优。
然后剩余的体力一定要在地上用,如果地上剩下了再在水上用,这样二分一下在地上能用多少,然后计算答案。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Maxn=110000;
int n;
ll l[Maxn],a[Maxn],ans;
char s[Maxn];
int main() {
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%I64d",&l[i]);
scanf("%s",s+1);
for(int i=1;i<=n;i++) l[i]<<=1;
ll w=0,g=0,st=1,flag=5;
for(int i=1;i<=n;i++) {
if(s[i]=='G') g+=l[i],ans+=5*l[i];
if(s[i]=='W') w+=l[i],flag=3,ans+=3*l[i];
if(s[i]=='L') {
ans+=l[i];
ll re=l[i],sxz=min(re,w);
re-=sxz,w-=sxz;sxz=min(re,g);
re-=sxz,g-=sxz;
if(re) ans+=re*flag;
}
if(!g&&!w) st=i+1;
}
ll las=(g+w)/2;
if(las) {
ll lc=0,rc=0,mid,res=0;
for(int i=st;i<=n;i++) if(s[i]=='G') rc+=l[i];
rc=min(rc,las);
while(lc<=rc) {
mid=lc+rc>>1;ll re=mid;
for(int i=n;i>=st;i--)
if(s[i]=='G') {
a[i]=min(re,l[i]);
re-=a[i];
}
ll now=0;
for(int i=st;i<=n;i++) {
if(s[i]=='G') now+=l[i]-2*a[i];
if(s[i]=='W') now+=l[i];
if(s[i]=='L') now-=l[i];
if(now<0) {
rc=mid-1;
goto orznh;
}
}
lc=mid+1;res=mid;
orznh:;
}
ans-=res*4+(las-res)*2;
}
ans>>=1;printf("%I64d\n",ans);
return 0;
}
Codeforces 1091 Good Bye 2018的更多相关文章
- Codeforces:Good Bye 2018(题解)
Good Bye 2018! 题目链接:https://codeforces.com/contest/1091 A. New Year and the Christmas Ornament 题意: 给 ...
- Codeforces Good Bye 2018
咕bye 2018,因为我这场又咕咕咕了 无谓地感慨一句:时间过得真快啊(有毒 A.New Year and the Christmas Ornament 分类讨论后等差数列求和 又在凑字数了 #in ...
- Good Bye 2018 (A~F, H)
目录 Codeforces 1091 A.New Year and the Christmas Ornament B.New Year and the Treasure Geolocation C.N ...
- Codeforces Avito Code Challenge 2018 D. Bookshelves
Codeforces Avito Code Challenge 2018 D. Bookshelves 题目连接: http://codeforces.com/contest/981/problem/ ...
- Good Bye 2018
Good Bye 2018 2018年最后一场CF,OVER! 弱弱的我只能做出3道A,B,D~~~~ 最后几分钟,感觉找到了C题的规律,结束的那一刻,提交了一发 "Wrong answer ...
- Good Bye 2018题解
Good Bye 2018题解 题解 CF1091A [New Year and the Christmas Ornament] 打完cf都忘记写题解了qwq 题意就是:给你一些黄,蓝,红的球,满足蓝 ...
- Codeforces Good Bye 2018 D (1091D) New Year and the Permutation Concatenation
题意:给n!个n的排列,按字典序从小到大连成一条序列,例如3的情况为:[1,2,3, 1,3,2, 2,1,3 ,2,3,1 ,3,1,2 ,3,2,1],问其中长度为n,且和为sum=n*(n+1) ...
- [codeforces Mail.Ru Cup 2018 Round 3][B Divide Candies ][思维+数学]
https://codeforces.com/contest/1056/problem/B 题意:输入n,m 求((a*a)+(b*b))%m==0的(a,b)种数(1<=a,b<= ...
- [codeforces Mail.Ru Cup 2018 Round 1 D][ xor 操作]
http://codeforces.com/contest/1054/problem/D 题目大意:一个序列a1 a2...an,可以对若干个元素进行取反,使所得的新序列异或和为0的区间个数最多. 题 ...
随机推荐
- 虚拟机中安装Ubuntu 16.04
1.安装vmware软件(虚拟机管理软件) https://blog.csdn.net/salmon_zhang/article/details/79468918 2.安装Ubuntu https:/ ...
- 15 jmeter分布式性能测试
背景由于jmeter本身的瓶颈,当需要模拟数以千计的并发用户时,使用单台机器模拟所有的并发用户就有些力不从心,甚至还会引起Java内存溢出的错误.要解决这个问题,可以使用分布式测试,运行多台机器运用所 ...
- 从jvm来看,scala中的@究竟是个什么鬼?@模式匹配符号(scala 词法分析 语法分析常用)
从jvm来看,scala中的@究竟是个什么鬼? 我也是初步尝试来看jvm的类文件,又是初次来分析@,如不对的地方,请各位指正! 先看一下@ 是个什么? object TestScala { def m ...
- HDU Today(自己的代码不知道哪里错了一直没A抄袭大神的)
http://acm.hdu.edu.cn/showproblem.php?pid=2112 本题题目意思非常简单,麻烦的就是处理一下字符串,这是我能力欠缺的地方 ;} 先把我有乱有麻烦的错误代码贴上 ...
- [Leetcode] 336. Palindrome Pairs_Hard
Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that t ...
- Mantle 与Injection
本来Injection可以本地打补丁实时修改代码,但是不知道Mantle的数据类为何不能打补丁,可能因为Mantle利用了很多运行时的技术吧.
- 软件包管理:源码包管理-源码包与RPM包的区别
RPM会安装在默认位置,源码包会安装在指定位置. 绝大多数ROM包遵循此规范.写软件包是就固定好了. 主要影响体现在对服务的管理方法,服务的管理分三种:启动,重启动,停止. 启动时使用绝对路径来启动. ...
- Java 简明教程
本文为 Java 的快速简明教程,主要用于快速了解.学习和复习java的语法特点. // 单行注释 /* 多行注释 */ /** JavaDoc(Java文档)注释是这样的.可以用来描述类和类的属性. ...
- linux常用命令:scp 命令
scp(secure copy)用于进行远程文件拷贝. 1.命令格式: scp [参数] [源文件] [目标文件] 2.命令功能: scp在主机间复制文件,他使用 ssh(1)作为数据传输,而且用同样 ...
- 2018-2019-2 20165209 《网络对抗技术》Exp6:信息搜集与漏洞扫描
2018-2019-2 20165209 <网络对抗技术>Exp6:信息搜集与漏洞扫描 1 基础问题回答和实验内容 1.1基础问题回答 (1)哪些组织负责DNS,IP的管理. Intern ...