Codeforces #105 DIV2 ABCDE
开始按照顺序刷刷以前的CF。
#include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio> #include <string> #include <vector> #include <climits> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> #define LL long long #define PI 3.1415926535897932626 using namespace std; int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} int a[4],d; int main() {while (cin>>a[0]>>a[1]>>a[2]>>a[3]>>d){int ans = 0;for (int i = 1; i <= d; i++){for (int j = 0; j < 4; j++)if (i % a[j] == 0){ans ++;break;}}cout<<ans<<endl;}return 0; }
View Code
B贡献无数发WA。注意相遇的条件 直接double处理就可以。一直以为按照相应直接直接跳跃相应距离 直接int处理
#include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio> #include <string> #include <vector> #include <climits> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> #define LL long long #define PI 3.1415926535897932626 using namespace std; int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} int vp,vd,t,f,c; int pos[1010]; int main() {while (cin>>vp>>vd>>t>>f>>c){if (vp >= vd) {puts("0");continue;}int thev = vd - vp;double pospri = vp * t;int ans = 0;while (pospri < c){double ti = pospri / (double)thev;if ((double) vd * ti >= c) break;ans ++;pospri = pospri + f * vp +(double) 2 * ti * vp;// printf("%d\n",pospri);if (pospri >= c) break;}cout <<ans <<endl;}return 0; }
View Code
C 坑点比较多。注意b等于0的情况
#include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio> #include <string> #include <vector> #include <climits> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> #define LL long long #define PI 3.1415926535897932626 using namespace std; int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} int n,a,b; int num[110]; int main() {while (cin >> n >> a >> b){if (a > n || b > n){ puts("-1");continue;}if (a > 0 && b == 0){if (n - a < 2) {puts("-1");continue;}else{printf("1 1 ");for (int i = 1 ,k = 2,j = 3; j <= n && i <= a ; k++,i++) printf("%d ",k);for (int i = a + 3; i <= n; i++) printf("%d ",a + 1);puts("");}continue;}for (int i = 0; i < 110; i++) num[i] = 1;int cas = 1;int sum = 1;for (int i = 2; i <= b + 1; i++){num[i] = sum + cas;sum += num[i];}cas = 1;for (int i = b + 2; i <= a + b + 1;i ++){num[i] = num[i - 1] + cas;}for (int i = 1; i <= n; i++)if (i == 1) cout << num[i];else cout << ' ' << num[i];puts("");}return 0; }
View Code
D DP
#include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio> #include <string> #include <vector> #include <climits> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> #define LL long long #define PI 3.1415926535897932626 using namespace std; int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} int w,b; double dp[1010][1010]; void init() {for (int i = 0; i < 1001; i++){dp[i][0] = 1.0;dp[0][i] = 0.0;}for (int w = 1; w < 1001; w++)for (int b = 1; b < 1001; b++){dp[w][b] += 1.0 * w / (w + b);if (b >= 3)dp[w][b] += dp[w][b - 3] * 1.0 * b / (w + b) * 1.0 * (b - 1) / (w + b - 1) * 1.0 * (b - 2) / (w + b - 2);if (b >= 2)dp[w][b] += dp[w - 1][b - 2] * 1.0 * b / (w + b) * 1.0 * (b - 1) / (w + b - 1) * w / (w + b - 2);} } int main() {init();while (scanf("%d%d",&w,&b) != EOF)printf("%.9lf\n",dp[w][b]);return 0; }
View Code
E DP预处理+DP
#include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio> #include <string> #include <vector> #include <climits> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> #define LL long long #define PI 3.1415926535897932626 using namespace std; int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} #define MAXN 110 #define MAXD 10010 int sum[MAXN][MAXD],dp[MAXN][MAXD],res[MAXN][MAXD]; int N,M; int num[MAXN]; int main() {while (scanf("%d%d",&N,&M) != EOF){memset(dp,0,sizeof(dp));memset(res,0,sizeof(res));for (int i = 1; i <= N; i++){scanf("%d",&num[i]);sum[i][0] = 0;for (int j = 1; j <= num[i];j++){int tmp;scanf("%d",&tmp);sum[i][j] = sum[i][j - 1] + tmp;}res[i][0] = 0;for (int j = 1; j <= num[i]; j++)for (int k = 0; k <= j; k++)res[i][j] = max(res[i][j],sum[i][k] + sum[i][num[i]] - sum[i][num[i] - (j - k)]);}for (int i = 1; i <= N; i++)for (int j = 1; j <= M; j++)for (int k = 0; k <= num[i] && k <= j; k++)dp[i][j] = max(dp[i][j],max(dp[i - 1][j],dp[i - 1][j - k] + res[i][k]));printf("%d\n",dp[N][M]);}return 0; }
View Code
转载于:https://www.cnblogs.com/Commence/p/4033713.html
Codeforces #105 DIV2 ABCDE相关推荐
- codeforces#320(div2) D Or Game 贪心
codeforces#320(div2) D "Or" Game 贪心 D. "Or" Game time limit per test 2 seconds ...
- codeforces 628.div2
# Codeforces 628.div2 A. EhAb AnD gCd B. CopyCopyCopyCopyCopy C. Ehab and Path-etic MEXs D. Ehab the ...
- codeforces#324(div2) E. Anton and Ira 贪心
codeforces#324(div2) E. Anton and Ira 贪心 E. Anton and Ira time limit per test 1 second memory limit ...
- codeforces 712 div2 ABC
codeforces 712 div2 ABC A. Déjà Vu A palindrome is a string that reads the same backward as forward. ...
- 【Codeforces #130 Div2】Solutions
[208A Dubstep] http://codeforces.ru/problemset/problem/208/A 题目大意:一个句子被添加了若干"WUB",问原句. 将W ...
- codeforces round div2,3周赛补题计划(从开学到期末)
1. 本学期场次 从2020.09.19-2021.01.18,一共18周. 题号 场次 日期 备注 1475 Codeforces Round #697 (Div. 3) 1.25 1474 Cod ...
- Codeforces #449 div2 C题
C. Nephren gives a riddle time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Codeforces#371 Div2
这是一场非常需要总结的比赛,交了3题,最后终测的时候3题全部没过,一下掉到了绿名,2333 Problem A 题意:给定区间[l1,r1],[l2,r2],然后给定一个整数k,求区间当中相交的元素, ...
- 付忠庆的练习小笔记-Codeforces #277 Div2 C
原题链接 http://codeforces.com/contest/486/problem/C 这个C题显然更水一些 步数可以分为两种 上下一种 左右一种 总步数最小 = 上下最小+左右最小 先讨论 ...
最新文章
- [置顶] 软件设计之道_读书纪要.doc
- 搭建FastDFS分布式文件方式一(Docker版本)
- 服务器维护菜单,Romley平台BIOS常用操作
- 新版ipados可以编辑C语言吗,iPadOS新增了五个有用的功能,看你需不需要
- php 获取localstorage,浅谈localStorage的本地存储
- Linux 简单文本处理命令
- 一加手机史上超大购机优惠 以旧换新至高补贴3800元
- select时尽可能少使用as对性能很有好处
- 联想E450c下vmware安装ubuntu Intel VT-x 处于禁用状态
- 空指针、NULL指针、零指针
- 大数据技术 - MapReduce 作业的运行机制
- 递归流程图(java)
- [RK3399][Android7.1] 移植笔记 --- 音频Codec RT5640添加
- 计算机设备故障,计算机常见硬件故障及其原因
- 【Linux】如何查看命令运行历史时间以及操作人IP
- 网站SEO提升关键词排名的六个步骤
- 第二周周报:预备队训练-week2(二分查找)
- android软键盘和导航栏冲突,Android透明状态栏和软键盘配合的坑
- Kali Linux 渗透测试之被动信息收集(三)——Recon-NG框架
- 软件构造Lab6总结
热门文章
- docker容器内安装ifconfig netstat ping vim 等测试工具的方法
- openCVPracticalExercise学习笔记02
- X 分钟速成 Python
- 读书笔记_量化交易如何建立自己的算法交易03
- 【实例解析】某水泥企业应用商业智能提升管理效率
- Flash务实主义——Loading
- windows 读写锁 python_用Python实现读写锁
- vs矩形框边框线显示被选中的区域;_Excel中,重复的数据高亮显示,如何快速删去?...
- win7 网络打印机 未授予用户在此计算机上的请求登录类型,Win7提示未授予用户在此计算机上的请求登录类型...
- 牛客寒假算法基础训练营6