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

来源:互联网 发布:网络与手机失泄密 编辑:程序博客网 时间:2024/04/20 03:55

全是2013 亚洲南京区域赛的题

感触挺深的。。

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

A:GPA 水题没什么好说的

B;Poor Warehouse Keeper 贪心

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

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

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

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

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

/*ID: meixiny1PROG: testLANG: 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 LOCALint main(){#ifdef LOCALfreopen("in.txt", "r", stdin);//freopen("out.txt","w",stdout);#endifdouble 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: meixiny1PROG: testLANG: 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 LOCALint dp[2][23][1<<10];char ch[105][15];int mp[105][15];int main(){#ifdef LOCALfreopen("in.txt", "r", stdin);//freopen("out.txt","w",stdout);#endifint 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*1if(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;}


还有一个题是考读题的,就不贴上来了

0 0
原创粉丝点击