占个坑先,希望不要掉的太惨了吧,不要掉到上一次之前的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. Json和List的表示形式

    JsonObject和List的表示形式 package payItem.test; import java.util.ArrayList; import java.util.List; import ...

  2. [kx]宇宙-银河

    行星/恒星/卫星的区分 目前太阳系内有8颗行星,分别是:水星.金星.地球.火星.木星.土星.天王星.海王星. 参考 恒星是自发光,而行星(行星通常指自身不发光,其公转方向常与所绕恒星的自转方向相同.) ...

  3. 关于LUA中的随机数问题

    也许很多人会奇怪为什么使用LUA的时候,第一个随机数总是固定,而且常常是最小的那个值,下面我就简要的说明一下吧,说得不好,还请谅解.我现在使用的4.0版本的LUA,看的代码是5.0的,呵呵 LUA4. ...

  4. POJ3096:Surprising Strings(map)

    http://poj.org/problem?id=3096 for循环真是奇妙! #include <string.h> #include <stdio.h> #includ ...

  5. jquery closest & parent比较

    .closest() .parents() 从当前元素开始 从父元素开始 沿 DOM 树向上遍历,直到找到已应用选择器的一个匹配为止. 沿 DOM 树向上遍历,直到文档的根元素为止,将每个祖先元素添加 ...

  6. Windows程序自启动方法汇总

    文件夹 一.当前用户专有的启动文件夹 二.对所有用户有效的启动文件夹 三.Load注册键 四.Userinit注册键 五.Explorer\Run注册键 六.RunServicesOnce注册键 七. ...

  7. Android弹性滑动的三种实现方式

    引言 上一篇文章我们介绍了实现弹性滑动的三种方式,但仅仅是给出了代码片段和方法理论.今天我们结合一个具体的例子来谈一下如何使用这三种方法来实现弹性滑动.今天我们的例子是仿IOS的下拉操作,我们知道An ...

  8. linux命令:linux文件处理命令

    命令格式 : 命令  [-选项]   [参数] 例:ls -la /etc 说明:1)个别命令使用不遵循此格式,[]代表可选 2)当有多个选项时,可以写在一起 3)-a等于 --all,调用简化选项用 ...

  9. 001-Two Sum

    Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...

  10. JAVA如何调用mysql写的存储过程

    存储过程是干什么的,自己百度,百度上讲的比我讲的好.为什么要用存储过程,这样可以提高效率.废话少说,直接上代码: 首先说一下语法:在mysql中写存储过程 DELIMITER $$ CREATE /* ...