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 ...
随机推荐
- Kings(状压DP)
Description 用字符矩阵来表示一个8x8的棋盘,'.'表示是空格,'P'表示人质,'K'表示骑士.每一步,骑士可以移动到他周围的8个方格中的任意一格.如果你移动到的格子中有人质(即'P'), ...
- Android面试收集录12 View测量、布局及绘制原理
一.View绘制的流程框架 View的绘制是从上往下一层层迭代下来的.DecorView-->ViewGroup(--->ViewGroup)-->View ,按照这个流程从上往下, ...
- 15,redis基础学习
redis Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库.缓存和消息中间件 yum安装redis 1.yum安装 #前提得配置好阿里云yum源,epel源 #查看 ...
- python语法re.compile模块介绍
1. re模块是正则表达式模块,re模块中包含一个重要函数是compile(pattern [, flags]) ,该函数根据包含的正则表达式的字符串创建模式对象.可以实现更有效率的匹配. impor ...
- C#冒泡算法复习
C#冒泡算法复习 冒泡算法的意思:每一趟找到一个最小或最大的数放到最后面,比较总数的n-1次(因为比较是2个双双比较的) 第一层循环表示进行比较的次数,总共要比较(数的)-1次 (因为比较是2个双双比 ...
- 内存压缩PK页面交换 解决内存问题谁更在行
一台服务器能够支持的虚拟机数量通常取决于物理硬件所能够提供的可用计算资源.大多数资源, 比如处理器周期.存储I/O和网络带宽等,都能够相对简单地进行共享.这种做法的原理在于负载并不总是处于忙碌状态,因 ...
- gprof使用介绍 (gcc -pg) [转]
原文出处: http://blog.csdn.net/unbutun/article/details/6609498 linux服务端编程,性能总是不可避免要思考的问题. 而单机(严格的说是单核)单线 ...
- 程序员必看:如何降低APP软件开发的成本?
程序员必看:如何降低APP软件开发的成本? 作为一名曾经的程序猿,一直想写一点东西给大家分享一下,今天终于动笔了,写写我们在开发的过程中怎样才能更快更好的进行开发,降低app开发成本.无论是个人开发者 ...
- 天性 & 如水一般,遇强则强 —— 梦想、行为、性格
开篇声明,我博客中“小心情”这一系列,全都是日记啊随笔啊什么乱七八糟的.如果一不小心点进来了,不妨直接关掉.我自己曾经写过一段时间的日记,常常翻看,毫无疑问我的文笔是很差的,而且心情也是瞬息万变的.因 ...
- [转载]python 变量命名规范
原文地址:python 变量命名规范作者:loveflying python源码和其他一些书籍,命名各种个性,没有一个比较统一的命名规范.于是自己总结了一些,可供参考. 模块名: 小写字母,单词之间用 ...