占个坑先,希望不要掉的太惨了吧,不要掉到上一次之前的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. Java学习之路-Spring的HttpInvoker学习

    Hessian和Burlap都是基于HTTP的,他们都解决了RMI所头疼的防火墙渗透问题.但当传递过来的RPC消息中包含序列化对象时,RMI就完胜Hessian和Burlap了. 因为Hessian和 ...

  2. 代码实现SQL SERVER TCP/IP协议配置

    代码实现SQL SERVER TCP/IP协议配置 SET NOCOUNT ON ) ,) ,) SET @Root = 'HKEY_LOCAL_MACHINE' SET @Path = 'Softw ...

  3. 【生产问题】LDF丢失

    参考 : https://www.cnblogs.com/gered/p/9450622.html CREATE DATABASE db_logs ON PRIMARY ( NAME % ) LOG ...

  4. Tomcat项目部署的三种方法

    第一种方法如下:直接把我们的项目文件夹放到tomcat里面,在这里我自己做的是一个测试项目oa,如图 启动tomcat,打开浏览器,输入localhost/oa  即可打开你的文件,注意 :访问的时候 ...

  5. 包含.h就可以用其对应的函数

    //callee.h 被调用者 #pragma once void display(); //展示函数 //callee.cpp 被调用者 #include "callee.h" ...

  6. break continue练习

    break :跳出 1.当break单独存在时,下面不要定义其他语句,因为执行不到. 2.如果出现了循环嵌套,break响应跳出指定的循环,可以通过标号来完成 例如: continue:要么是swit ...

  7. UMI标签学习【转载】

    转自: https://club.1688.com/threadview/50123159.htm 简单介绍一下利用单分子标签(Unique Molecular Identifier,UMI)对残留噪 ...

  8. nltk模块基础操作

     几个基础函数 (1)搜索文本:text.concordance(word) 例如,在text1中搜索词”is”在文本中出现的次数以及上下文的词:text1.concordance("is& ...

  9. JavaScript循环练习

    1.蓝球弹起的高度篮球从10米高的地方落下,每次弹起的高度是原来的0.3倍,问弹跳10次之后篮球的高度. <script type="text/javascript"> ...

  10. Java性能优化——HashCode的使用

    背景 告警子系统监控4万个大网元所有端口的某些指标数据,根据阈值配置判断是否产生告警.采集——数据处理子系统每5分钟会主动采集24万次数据,发送24万条消息给告警子系统,这24万条消息涉及100万实体 ...