链接

A

套上题目里给的公式就过了

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+7;
typedef long long ll;
ll w,h,k,ans;
int main()
{scanf("%lld%lld%lld",&w,&h,&k);for(int i=1;i<=k;i++)ans += 2*((w-4*(i-1))+(h-4*(i-1)))-4;printf("%lld\n",ans);return 0;
}

B

写了个dp,dp[i][j],,表示第i个位置放j时候的方案数,那么看最后的dp[n-1][j]是否存在就可以了

倒着扫一遍输出路径

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+7;
typedef long long ll;
int n,flag;
int a[maxn],b[maxn],c[maxn][4];
int ans[maxn];
int main()
{scanf("%d",&n);for(int i=0;i<n-1;i++)scanf("%d",&a[i]);for(int i=0;i<n-1;i++)scanf("%d",&b[i]);c[0][0] = c[0][1] = c[0][2] = c[0][3] = 1;for(int i=0;i<n-1;i++){flag = 0;for(int j=0;j<4;j++){if(c[i][j]){for(int k=0;k<4;k++){if(a[i] == (j|k) && b[i] == (j&k)){c[i+1][k]++,flag++;}}}}if(!flag)break;}if(flag)printf("NO\n");else{printf("YES\n");for(int i=0;i<4;i++){if(c[n-1][i]){ans[n-1] = i;break;}}for(int i=n-2;i>=0;i--){for(int j=0;j<4;j++){if(c[i][j] && a[i] == (j|ans[i+1]) && b[i] == (j&ans[i+1])){ans[i] = j;break;}}}for(int i=0;i<n;i++)printf("%d ",ans[i]);}return 0;
}

C

我写的很乱,最后wa几发后总算过了,想法是后来看到的(自己的想法太乱,虽然能A,但是决定不说了),

考虑其实很简单,稍微推一下能看出来肯定是个连续的1*****x

(x+1)*x/2=(a+b),求出x来,倒着扫一遍,给a或给b,最后输出即可

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e7+7;
typedef long long ll;
ll a,b,x,tx,sum;
int i,j,k;
bool ans[maxn];
int main()
{cin>>a>>b;tx = x = sqrt(2*(a+b)+0.25)-0.5;while(x){if(a>=x)ans[x] = 1,i++,a -= x;elseans[x] = 0,j++,b -= x;x--;}printf("%d\n",i);for(k=1;k<=tx;k++){if(ans[k])printf("%d ",k);}printf("\n%d\n",j);for(k=1;k<=tx;k++){if(!ans[k])printf("%d ",k);}return 0;
}

codeforces round#517相关推荐

  1. Codeforces Round #517 Div.2 FST神场

    恐怖如斯 神场神场. 题解 A B C D 神场神场. 一看场号517直接去打了. 一上来首先看A题,一看数据范围直接大模拟写上去,竟然3分钟给写完了. 再看B题,发了2分钟呆,然后发现能够满足的没有 ...

  2. Educational Codeforces Round 25 E. Minimal Labelshdu1258

    这两道题都需要用到拓扑排序,所以先介绍一下什么叫做拓扑排序. 这里说一下我是怎么理解的,拓扑排序实在DAG中进行的,根据图中的有向边的方向决定大小关系,具体可以下面的题目中理解其含义 Educatio ...

  3. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  4. Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈)

    Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈) 标签: codeforces 2017-06-02 11:41 29人阅读 ...

  5. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  6. Codeforces Round #270

    Codeforces Round #270 题目链接 A:我是筛了下素数.事实上偶数仅仅要输出4和x - 4,奇数输出9和x - 9就可以 B:贪心的策略,把时间排序后.取每k个的位置 C:贪心.每次 ...

  7. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...

  8. [Educational Codeforces Round 16]A. King Moves

    [Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...

  9. Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...

最新文章

  1. 1月国内操作系统市场:Windows XP份额高达60.84%
  2. slackware12.0 安装AdobeReader_chs-7.0.9-1.i386.tar.gz后程序启动报错解决?
  3. 新的方法 (New Approach)¶
  4. 亲情奉献一些搜集的网站
  5. Android App解决卡顿慢之内存抖动及内存泄漏(发现和定位)
  6. 2018年创业最火热点的是什么?看到这个你可能就知道哪方面发展最热了
  7. 数组的最长平台c语言,2010台湾省C语言版高级
  8. MySql错误1045 Access denied for user 'root'@'localhost' (using password:YES)
  9. python 模块学习--Numpy
  10. python四大高阶函数_四大高阶函数
  11. BC 2015在百度之星程序设计大赛 - 预赛(1)(矩形区域-旋转卡)
  12. 给Xcode增加复制行、删除行快捷键的方法
  13. 重构:改善既有代码的设计 精彩书评二
  14. 我可以不做但我不可以不会
  15. perl脚本GET系统命令执行
  16. 利用spring AOP 实现 sql注入检测
  17. matlab 信道容量的迭代算法,实验二一般信道容量迭代算法详解.ppt
  18. 服务器经常被攻击怎么办
  19. 三星手机动态修改分辨率信息
  20. 解释一下label中的写法:plt.plot(t, sig, b-, linewidth=2, label=r$\sigma(t) = \frac{1}{1 + e^{-t}}$)...

热门文章

  1. 至联云讲解《IPFS/Filecoin上线后会涨的八大理由》
  2. 彻底解决MySQL导入Excel无法打开Excel的问题
  3. python update函数会调用哪些内置函数_Python字典的内置函数中没有 append()操作,可以用 update()来更新字典内容...
  4. 小米note android7,小米note MIUI9.0+Android7.1刷机包
  5. 微信公众号发红包php开发教程
  6. android系统目录和作用是什么意思,安卓Android手机系统内文件夹目录解释
  7. 小米2022校招前端实习一面总结
  8. 俄罗斯android课程设计,基于Android的俄罗斯方块的设计与实现毕业设计报告.docx...
  9. R语言 | 关联规则
  10. 第四章 DirectX 渲染流水线(上)