占个坑先,希望不要掉的太惨了吧,不要掉到上一次之前的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的更多相关文章

  1. Codeforces:Good Bye 2018(题解)

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

  2. Codeforces Good Bye 2018

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

  3. Good Bye 2018 (A~F, H)

    目录 Codeforces 1091 A.New Year and the Christmas Ornament B.New Year and the Treasure Geolocation C.N ...

  4. Codeforces Avito Code Challenge 2018 D. Bookshelves

    Codeforces Avito Code Challenge 2018 D. Bookshelves 题目连接: http://codeforces.com/contest/981/problem/ ...

  5. Good Bye 2018

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

  6. Good Bye 2018题解

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

  7. 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) ...

  8. [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<= ...

  9. [codeforces Mail.Ru Cup 2018 Round 1 D][ xor 操作]

    http://codeforces.com/contest/1054/problem/D 题目大意:一个序列a1 a2...an,可以对若干个元素进行取反,使所得的新序列异或和为0的区间个数最多. 题 ...

随机推荐

  1. AspNetPager使用方法

    一.AspNetPager支持两种方式分页: 一种是PostBack方式分页, 一种是通过Url来实现分页以及Url重写功能 二.AspNetPager支持各种数据绑定控件GridView.DataG ...

  2. 时间序列深度学习:状态 LSTM 模型预測太阳黑子(一)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/kMD8d5R/article/details/82111558 作者:徐瑞龙,量化分析师,R语言中文 ...

  3. NYOJ-1073 最小值

    http://acm.nyist.net/JudgeOnline/problem.php?pid=1073 # include<stdio.h> # include<stdlib.h ...

  4. 关于Flag的定义

    最近在维护项目的代码,发现了由于Flag不一致导致的很多问题,现在对这一问题总结. 1,flag分为两种,可以组合的和不可以组合的.可以组合的flag适合用每一位表示一个含义.不适合组合的flag适合 ...

  5. python3与mysql:创建表、插入数据54

    import pymysql db = pymysql.connect(host=',db='jodb1',port=3307,charset='utf8') # #测试连接开发库成功 # db = ...

  6. [LeetCode] 733. Flood Fill_Easy tag: BFS

    An image is represented by a 2-D array of integers, each integer representing the pixel value of the ...

  7. CentOS6.5安装RHadoop

    1.首先安装依赖包(各个节点都要安装) [root@Hadoop-NN-01 ~]$ yum install gcc-gfortran #否则报”configure: error: No F77 co ...

  8. Python 之 os.walk()

    原文地址https://www.cnblogs.com/JetpropelledSnake/p/8982495.html          http://www.runoob.com/python/o ...

  9. JVM、Java编译器和Java解释器

    作用: JVM:JVM有自己完善的硬件架构,如处理器.堆栈(Stack).寄存器等,还具有相应的指令系统(字节码就是一种指令格式).JVM屏蔽了与具体操作系统平台相关的信息,使得Java程序只需要生成 ...

  10. mysql日志详解

    日志分类: 一.错误日志. 1.在配置文件中的配置是:log-error="DESKTOP-igoodful.err",查看参数的键值对:show variables like ' ...