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 ...
随机推荐
- fix34
public int[] fix34(int[] nums) { int i3=0; int i4=0; int temp=0; while( (i3<nums.length)&& ...
- linux_shell基础-变量、数组、运算符
#!/bin/bash# echo 'hello world'# name='http://www.baidu.com'# for file in $(ls ./); do# echo "t ...
- express常用代码片段
请求模块: var express = require('express'); var router = express.Router(); // 拿到express框架的路由 var mongoos ...
- Python全栈 MySQL 数据库 (表字段增、删、改、查、函数)
ParisGabriel 每天坚持手写 一天一篇 决定坚持几年 为了梦想为了信仰 开局一张图 查询SQL变量 show variables 1.表字 ...
- windows auto activate
目前所支持的windows镜像都是未激活状态,未激活状态下很多功能无法使用. 以后将要实现的功能是,windows虚机启动后,网络正常后能与KMS服务器通信,自动激活key 目前想到两种办法: 1.b ...
- 【志银】Dev-Cpp配置OpenGL图形库(成功版本:Dev-Cpp 5.7.1 MinGW 4.8.1)
★配置前须知:Dev-Cpp自带OpenGL的使用和OpenGL简介 (附Dev-Cpp下载地址:http://sourceforge.net/projects/orwelldevcpp/?sourc ...
- mysql Access denied for user 'root'@'localhost'问题解决
问题描述: 系统安装mysql的过程中,没有提示配置用户名和密码相关的信息,安装完毕后,登录报错. 表现现象为: mysql -u root -p [输入root密码] 界面提示: ERROR 169 ...
- ssh 免交互登录 ,远程执行命令脚本。
##免交互SSH登录auto_login_ssh () { expect -c "set timeout -1; spawn -noecho ssh -o ...
- Block层也是有IO的优先级的
---恢复内容开始--- 今天查看iotop的原理,竟然发现了IO优先级一说,IO是block层cfs调度器中的概念 block层也有一个类似于CPU的调度算法 对进程分成三个级别:RT,BE,IDL ...
- PHP实现图片上传并压缩
本文实例讲解了PHP图片上传并压缩的实现方法,分享给大家供大家参考,具体内容如下 使用到三个文件 connect.php:连接数据库 test_upload.php:执行SQL语句 upload_im ...