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 == ? b : gcd(b, a % b);}
int a[],d;
int main()
{
while (cin>>a[]>>a[]>>a[]>>a[]>>d)
{
int ans = ;
for (int i = ; i <= d; i++)
{
for (int j = ; j < ; j++)
if (i % a[j] == )
{
ans ++;
break;
}
}
cout<<ans<<endl;
}
return ;
}
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 == ? b : gcd(b, a % b);}
int vp,vd,t,f,c;
int pos[];
int main()
{
while (cin>>vp>>vd>>t>>f>>c)
{
if (vp >= vd) {puts("");continue;}
int thev = vd - vp;
double pospri = vp * t;int ans = ;
while (pospri < c)
{
double ti = pospri / (double)thev;
if ((double) vd * ti >= c) break;
ans ++;
pospri = pospri + f * vp +(double) * ti * vp;
// printf("%d\n",pospri);
if (pospri >= c) break;
}
cout <<ans <<endl;
}
return ;
}
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 == ? b : gcd(b, a % b);}
int n,a,b;
int num[];
int main()
{
while (cin >> n >> a >> b)
{
if (a > n || b > n){ puts("-1");continue;}
if (a > && b == )
{
if (n - a < ) {puts("-1");continue;}
else
{
printf("1 1 ");
for (int i = ,k = ,j = ; j <= n && i <= a ; k++,i++) printf("%d ",k);
for (int i = a + ; i <= n; i++) printf("%d ",a + );
puts("");
}
continue;
}
for (int i = ; i < ; i++) num[i] = ;
int cas = ;
int sum = ;
for (int i = ; i <= b + ; i++)
{
num[i] = sum + cas;
sum += num[i];
}
cas = ;
for (int i = b + ; i <= a + b + ;i ++)
{
num[i] = num[i - ] + cas;
}
for (int i = ; i <= n; i++)
if (i == ) cout << num[i];
else cout << ' ' << num[i];
puts("");
}
return ;
}
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 == ? b : gcd(b, a % b);}
int w,b;
double dp[][];
void init()
{
for (int i = ; i < ; i++)
{
dp[i][] = 1.0;
dp[][i] = 0.0;
}
for (int w = ; w < ; w++)
for (int b = ; b < ; b++)
{
dp[w][b] += 1.0 * w / (w + b);
if (b >= )
dp[w][b] += dp[w][b - ] * 1.0 * b / (w + b) * 1.0 * (b - ) / (w + b - ) * 1.0 * (b - ) / (w + b - );
if (b >= )
dp[w][b] += dp[w - ][b - ] * 1.0 * b / (w + b) * 1.0 * (b - ) / (w + b - ) * w / (w + b - );
}
}
int main()
{
init();
while (scanf("%d%d",&w,&b) != EOF)
printf("%.9lf\n",dp[w][b]);
return ;
}
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 == ? 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,,sizeof(dp));
memset(res,,sizeof(res));
for (int i = ; i <= N; i++)
{
scanf("%d",&num[i]);
sum[i][] = ;
for (int j = ; j <= num[i];j++)
{
int tmp;
scanf("%d",&tmp);
sum[i][j] = sum[i][j - ] + tmp;
}
res[i][] = ;
for (int j = ; j <= num[i]; j++)
for (int k = ; 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 = ; i <= N; i++)
for (int j = ; j <= M; j++)
for (int k = ; k <= num[i] && k <= j; k++)
dp[i][j] = max(dp[i][j],max(dp[i - ][j],dp[i - ][j - k] + res[i][k]));
printf("%d\n",dp[N][M]);
}
return ;
}
Codeforces #105 DIV2 ABCDE的更多相关文章
- codeforces#518 Div2 ABCDE
A---Birthday http://codeforces.com/contest/1068/problem/A 题意: 有n种硬币,m个人.m个人要给Ivan送硬币,每个人送的硬币都要互不相同但数 ...
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
- Codeforces #263 div2 解题报告
比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...
- codeforces #round363 div2.C-Vacations (DP)
题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...
随机推荐
- 3、springboot配置文件占位符
RandomValuePropertySource:配置文件中可以使用随机数 ${random.value}.${random.int}.${random.long}.${random.int(10) ...
- 笔记-pytho-语法-yield
笔记-python-语法-yield 1. yield 1.1. yield基本使用 def fab(max): n,a,b = 0, 0, 1 while n < max: y ...
- 笔记-scrapy-item
笔记-scrapy-item 1.总述 爬虫数据保存用,一般情况下无需过多处理,引用并使用Field方法即可. 2.使用 常规使用: import scrapy class Product(scrap ...
- nodejs基础1
nodejs学习网站: https://github.com/alsotang/node-lessons 1.全局对象 (1)node中没有window对象,有global对象替代window对象 g ...
- 把SVN版本控制讲给 非IT同事 听
场景: 什么是版本: 什么是版本控制: 为什么要用版本控制: 推荐使用SVN: 如何快速理解SVN: SVN简单使用:
- 验证表单的js代码段
JS常用功能 转载自:http://blog.csdn.net/kalision/article/details/12516103 引用js文件: <script src="js/d ...
- Python网络编程(http协议,IO多路复用、select内核监听)
前言: 什么是IO? 分为IO设备和IO接口两个部分 如Linux系统,I/O操作可以有多种方式 比如DIO(DirectI/O) AIO(AsynchronousI/O异步I/O) Memory-M ...
- hnust 分蛋糕
问题 B: 分蛋糕 时间限制: 1 Sec 内存限制: 128 MB提交: 2430 解决: 966[提交][状态][讨论版] 题目描述 今天是DK生日,由于DK的朋友很多,所以DK在蛋糕店定制了 ...
- HDU 4731 Minimum palindrome (找规律)
M=1:aaaaaaaa…… M=2:DFS+manacher, 暴出N=1~25的最优解,找规律.N<=8的时候直接输出,N>8时,头两个字母一定是aa,剩下的以aababb循环,最后剩 ...
- vue vscode 开始
E:\Html\4 Vue版>npm config set registry https://registry.npm.taobao.org E:\Html\4 Vue版>npm i &g ...