您的位置:首页 > 其它

周赛题解报告-2013 亚洲南京区域赛

2016-02-29 21:41 337 查看
全是2013 亚洲南京区域赛的题

感触挺深的。。

补了五道题,之后要是补了会加上来。。。。

A:GPA 水题没什么好说的

B;Poor Warehouse Keeper 贪心

这道题被精度wa了。。。1e-5

要以最短的步数到达给定的x,y

可以看出x的增加次数是固定的

步数要最短,那么我们贪心的原则就是在x越小的情况下使得y的增长到极限

极限是什么呢,就是当前的均值要小于等于(y+1-eps)/x (因为最后的y值可能不为整数,所以+1-eps)

/*
ID: meixiny1
PROG: test
LANG: C++11
*/
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <cctype>
using namespace std;
typedef long long ll;
typedef pair<int ,int> pii;
#define MEM(a,b) memset(a,b,sizeof a)
#define CLR(a) memset(a,0,sizeof a);
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
#define PI 3.1415926535898
//#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
//	freopen("out.txt","w",stdout);
#endif
double x,y;
ll cnt = 0;
while(scanf("%lf%lf",&x,&y)!=EOF){
if(y<x){
printf("-1\n");
continue;
}
else{
double k = 1.0*(y+1-1e-5)/x;
double tt = 1.0;
cnt = x-1;
for(ll i=1;i<=(int)x;i++){
double t = i*k;
ll u = (ll)(t-tt);
tt += u;
tt = tt*(1+i)/i;
cnt+=u;
}
}
printf("%lld\n",cnt);
}
return 0;
}
Campus Design 轮廓线dp

听说是插头dp,但是看了cqd的论文看不懂,感觉这个可以自己yy

这道题的dp的精髓在于由0-n然后对于每次对于每一个m,更新当前小于m的所有情况

然后使用动态数组直到遍历完每一个格子

/*
ID: meixiny1
PROG: test
LANG: C++11
*/
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <cctype>
using namespace std;
typedef long long ll;
typedef pair<int ,int> pii;
#define MEM(a,b) memset(a,b,sizeof a)
#define CLR(a) memset(a,0,sizeof a);
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
#define PI 3.1415926535898
//#define LOCAL
int dp[2][23][1<<10];
char ch[105][15];
int mp[105][15];
int main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
//	freopen("out.txt","w",stdout);
#endif
int n,m,c,d;
while(scanf("%d%d%d%d",&n,&m,&c,&d)!=EOF){
MEM(dp,0);
for(int i=1;i<=n;i++){
scanf("%s",ch[i]);
}
int all = 1<<m;
for(int i=1;i<=n;i++)
for(int j=0;j<m;j++)mp[i][j] = ch[i][j]-'0';
int p = 0;
dp[p][0][all-1]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<m;j++){
p^=1;
if(!mp[i][j]){
for(int t=0;t<=d;t++){
for(int k=0;k<all;k++){
if(k&(1<<j))dp[p][t][k|(1<<j)]=(dp[p][t][k|(1<<j)]+dp[p^1][t][k])%MOD;
}
}
}
else{
for(int t=0;t<=d;t++){
for(int k=0;k<all;k++){
//不放
if(k&(1<<j))dp[p][t][k&(all-(1<<j)-1)]=(dp[p][t][k&(all-(1<<j)-1)]+dp[p^1][t][k])%MOD;
//放1*1
if(k&(1<<j))dp[p][t+1][k|(1<<j)]=(dp[p][t+1][k|(1<<j)]+dp[p^1][t][k])%MOD;
//横放
if(j && !(k&(1<<(j-1))) && k&(1<<j))
dp[p][t][k|(1<<(j-1))|(1<<j)]=(dp[p][t][k|(1<<(j-1))|(1<<j)]+dp[p^1][t][k])%MOD;
//竖放
if(!(k&(1<<j)))
dp[p][t][k|(1<<j)]=(dp[p][t][k|(1<<j)]+dp[p^1][t][k])%MOD;
}
}
}
MEM(dp[p^1],0);
}
}
int ans=0;
for(int i=c;i<=d;i++){
//for(int j=all-1;j<all;j++){
ans=(ans+dp[p][i][all-1])%MOD;
//}
}
printf("%d\n",ans);
}
return 0;
}


还有一个题是考读题的,就不贴上来了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: