[ACM]2013山东省“浪潮杯”省赛 解题报告
题目地址:http://acm.upc.edu.cn/problemset.php?page=13 2217~2226
一个等边三角形告诉前2个点,求逆时针序的第三个点坐标。
简单几何,其实做法有很多,好像大多数都是带直线方程然后判断方向做的。我觉得直接将A放在原点,让B绕A逆时针旋转60度,最后加上A的偏移更简单。旋转直接用方向向量乘旋转矩阵就好。
- #include <map>
- #include <set>
- #include <list>
- #include <queue>
- #include <stack>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <bitset>
- #include <cstdio>
- #include <string>
- #include <numeric>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- ]={-,,,};
- ]={,,-,};//up down left right
- ||x>n||y<||y>m)return false;return true;}
- )*m+y;}
- #define eps 1e-8
- #define inf 0x7fffffff
- #define debug puts("BUG")
- #define lson l,m,rt<<1
- #define rson m+1,r,rt<<1|1
- #define root 1,n,1
- #define read freopen("in.txt","r",stdin)
- #define write freopen("out.txt","w",stdout)
- #define maxn 2005
- #define maxe 10005
- const double sqt3=sqrt(3.0);
- ][],m3[][];
- ][]={{},{-sqt3/,0.5}};
- void gao()
- {
- memset(m3,,sizeof(m3));
- ;k<;++k)
- ;j<;++j)
- m3[][j]+=m1[][k]*m2[k][j];
- }
- int main()
- {
- read;
- int cas;
- scanf("%d",&cas);
- while(cas--)
- {
- double x1,x2,y1,y2;
- scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
- m1[][]=x2-x1;
- m1[][]=y2-y1;
- gao();
- printf(][]+x1,m3[][]+y1);
- }
- ;
- }
题干冗长,实际上就是在一个1000个点,10000条有向边的图上判断是否存在两个点A,B不可达,不可达定义为从A不能走到B且B不能走到A,A,B不能都动。
据说可以1000个点都暴力BFS过掉O(n*m)。此题可以先tarjan缩点,然后判断缩点后的图是否是一条链即可。链的充要条件应该不止一个,比较好想的是只有1个入度为0出度为1的点,只有1个入度为1出度为0的点,剩下的全是出度和入度均为1的点,平凡图特判。做的时候没考虑重边,WA了4次,还好赛场上不是我写这道题。
- #include <map>
- #include <set>
- #include <list>
- #include <queue>
- #include <stack>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <bitset>
- #include <cstdio>
- #include <string>
- #include <numeric>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- ]={-,,,};
- ]={,,-,};//up down left right
- ||x>n||y<||y>m)return false;return true;}
- )*m+y;}
- #define eps 1e-8
- #define inf 0x7fffffff
- #define debug puts("BUG")
- #define lson l,m,rt<<1
- #define rson m+1,r,rt<<1|1
- #define root 1,n,1
- #define read freopen("in.txt","r",stdin)
- #define write freopen("out.txt","w",stdout)
- #define maxn 2005
- #define maxe 10005
- struct str
- {
- int u,v,n;
- }edge[maxe];
- int head[maxn],cnt;
- int dfn[maxn],low[maxn];
- bool ins[maxn];
- int incom[maxn];
- int dep,comn;
- stack<int>st;
- void init()
- {
- memset(dfn,,sizeof(dfn));
- memset(ins,,sizeof(ins));
- memset(head,-,sizeof(head));
- dep=comn=cnt=;
- }
- void addEdge(int u,int v)
- {
- edge[cnt].u=u;
- edge[cnt].v=v;
- edge[cnt].n=head[u];
- head[u]=cnt++;
- }
- void tarjan(int u)
- {
- dfn[u]=low[u]=++dep;
- ins[u]=true;
- st.push(u);
- for(int i=head[u];~i;i=edge[i].n)
- {
- int v=edge[i].v;
- if(!dfn[v])
- {
- tarjan(v);
- if(low[v]<low[u])
- low[u]=low[v];
- }
- else if(ins[v]&&dfn[v]<low[u])
- low[u]=dfn[v];
- }
- if(dfn[u]==low[u])
- {
- int v;
- ++comn;
- do
- {
- v=st.top();
- st.pop();
- ins[v]=false;
- incom[v]=comn;
- }while(v!=u);
- }
- }
- ];
- bool gao()
- {
- )return true;
- memset(du,,sizeof(du));
- ;i<cnt;++i)
- {
- int u=incom[edge[i].u],v=incom[edge[i].v];
- if(u==v)continue;
- ++du[u][];
- ++du[v][];
- }
- int c1,c2,c3;
- c1=c2=c3=;
- ;i<=comn;++i)
- {
- ]==&&du[i][]==)++c1;
- ]==&&du[i][]==)++c2;
- ]==&&du[i][]==)++c3;
- }
- &&c2==&&c3==(comn-));
- }
- bool vis[maxn][maxn];
- int main()
- {
- //read;
- int cas;
- scanf("%d",&cas);
- ;xx<=cas;++xx)
- {
- int n,m;
- scanf("%d%d",&n,&m);
- init();
- int u,v;
- memset(vis,,sizeof(vis));
- ;i<m;++i)
- {
- scanf("%d%d",&u,&v);
- vis[u][v]=true;
- }
- ;i<=n;++i)
- ;j<=n;++j)
- if(vis[i][j])addEdge(i,j);
- ;i<=n;++i)
- if(!dfn[i])tarjan(i);
- bool ff=gao();
- printf("Case %d: ",xx);
- if(!ff)puts("The Burning Shadow consume us all");
- else puts("Kalimdor is just ahead");
- }
- ;
- }
f(x) = K, x = 1 . f(x) = (a*f(x-1) + b)%m , x > 1 . 求( A^(f(1)) + A^(f(2)) + A^(f(3)) + ...... + A^(f(n)) ) modular P (n<10^6,其余<10^9 )
总感觉可以无脑快速幂搞过的样子,赛场上没几个出的,就想肯定不可能了。其实这题只需要预处理下所有A^(1,10^9)就行,可是10^9空间和时间上都不允许。于是我们找一个k,让所有x=k*i+j,所以先求出A^k,那么A^x==(A^k)^i * A^j。感觉不是很难,还在自己太弱了。
- #include <map>
- #include <set>
- #include <list>
- #include <queue>
- #include <stack>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <bitset>
- #include <cstdio>
- #include <string>
- #include <numeric>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- ]={-,,,};
- ]={,,-,};//up down left right
- ||x>n||y<||y>m)return false;return true;}
- )*m+y;}
- #define eps 1e-8
- #define inf 0x7fffffff
- #define debug puts("BUG")
- #define lson l,m,rt<<1
- #define rson m+1,r,rt<<1|1
- #define root 1,n,1
- #define read freopen("in.txt","r",stdin)
- #define write freopen("out.txt","w",stdout)
- #define maxn 50005
- #define maxm 100005
- ll p1[maxm+],p2[maxm+];
- ll n, A, K, a, b, m, P;
- void init()
- {
- p1[]=p2[]=1LL;
- ;i<=maxm;++i)
- p1[i]=(A*p1[i-])%P;
- ;i<=maxm;++i)
- p2[i]=(p2[i-]*p1[maxm])%P;
- }
- ll gao()
- {
- ll t=K,ans=;
- ;i<=n;++i)
- {
- ans=(ans+p2[t/maxm]*p1[t%maxm])%P;
- t=(a*t+b)%m;
- }
- return ans;
- }
- int main()
- {
- //read;
- int cas;
- scanf("%d",&cas);
- ;xx<=cas;++xx)
- {
- scanf("%lld%lld%lld%lld%lld%lld%lld",&n,&A,&K,&a,&b,&m,&P);
- init();
- printf("Case #%d: %lld\n",xx,gao());
- }
- ;
- }
给一个乱的2色4格魔方,求拧成每面同色的最小步数。
其实转的方法一共12种,前后 上下 左右 各四种(上面2个格子2个方向 下面2个格子2个方向),由于转上面2个格子等于反向转下面的格子,所以实际上只有6种。求最少步数,暴力BFS可过,中间需要记录某个状态是否拧出来过。唯一蛋疼的地方是每个面的1234顺序不完全对应。找准转的时候是哪些面的哪个格子转动到的目标面和目标格子就好。这类题,我一直不知道怎么写简单,完全暴力模拟,代码巨丑 300+,这里不贴了。可以参见这份报告:http://blog.csdn.net/binwin20/article/details/9073941 瞬间感觉被爆了。
给出一个10^5长的字符串,字母的ASCII码做权值,问有多少个长度大于3,形如: a1 < ...< ai < ai+1 < Amax > aj > aj+1 > ... > an的序列。
赛场上真是跪给这个题了,想到了正确思路,先WA后T,回来写就AC了。DP[i][j]表示前i个字符,以j为结尾的上升序列个数,正着和反着都做一遍,然后枚举中点,两边一组合就行了。复杂度O(n*26)。其实可以降到1维,顺序扫i的时候只需要查询前面val小于val[i]的个数就可以了,然后再更新。这样写起来就很像线段树了。
dp:
- #include <map>
- #include <set>
- #include <list>
- #include <queue>
- #include <stack>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <bitset>
- #include <cstdio>
- #include <string>
- #include <numeric>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- ]={-,,,};
- ]={,,-,};//up down left right
- ||x>n||y<||y>m)return false;return true;}
- )*m+y;}
- #define eps 1e-8
- #define inf 0x7fffffff
- #define debug puts("BUG")
- #define lson l,m,rt<<1
- #define rson m+1,r,rt<<1|1
- #define read freopen("in.txt","r",stdin)
- #define write freopen("out.txt","w",stdout)
- #define maxn 100005
- #define MOD 2012
- char ss[maxn];
- ],dp2[maxn][];
- //dp[i][j]代表前i个单词权值小于等于j的上升序列方案数,dp2同理,只不过是反过来。
- int main()
- {
- //read;
- int n;
- while(~scanf("%d",&n))
- {
- scanf("%s",ss);
- memset(dp,,sizeof(dp));
- memset(dp2,,sizeof(dp2));
- ;i<=n;++i)
- {
- ]-;
- dp[i][t]=;
- ;j<t;++j)
- dp[i][t]=(dp[i][t]+dp[i-][j])%MOD;
- ;j<=;++j)
- dp[i][j]=(dp[i][j]+dp[i-][j])%MOD;
- }
- ;i<=n;++i)
- ;j<=;++j)
- dp[i][j]=(dp[i][j]+dp[i][j-])%MOD;
- ;--i)
- {
- ]-;
- dp2[i][t]=;
- ;j<t;++j)
- dp2[i][t]=(dp2[i][t]+dp2[i+][j])%MOD;
- ;j<=;++j)
- dp2[i][j]=(dp2[i][j]+dp2[i+][j])%MOD;
- }
- ;i<=n;++i)
- ;j<=;++j)
- dp2[i][j]=(dp2[i][j]+dp2[i][j-])%MOD;
- ;
- ;i<n;++i)
- {
- ]-;
- ans=(ans+dp[i-][t-]*dp2[i+][t-])%MOD;
- }
- printf("%d\n",ans);
- }
- ;
- }
seg:
- #include <map>
- #include <set>
- #include <list>
- #include <queue>
- #include <stack>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <bitset>
- #include <cstdio>
- #include <string>
- #include <numeric>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- ]={-,,,};
- ]={,,-,};//up down left right
- ||x>n||y<||y>m)return false;return true;}
- )*m+y;}
- #define eps 1e-8
- #define inf 0x7fffffff
- #define debug puts("BUG")
- #define lson l,m,rt<<1
- #define rson m+1,r,rt<<1|1
- #define root 1,26,1
- #define read freopen("in.txt","r",stdin)
- #define write freopen("out.txt","w",stdout)
- #define maxn 100005
- #define maxm 30
- #define MOD 2012
- ];
- void pushup(int rt)
- {
- sum[rt]=(sum[rt<<]+sum[rt<<|])%MOD;
- return ;
- }
- void build(int l,int r,int rt)
- {
- if(l==r)
- {
- sum[rt]=;
- return ;
- }
- ;
- build(lson);
- build(rson);
- pushup(rt);
- }
- void update(int p,int v,int l,int r,int rt)
- {
- if(l==r)
- {
- sum[rt]=(sum[rt]+v)%MOD;
- return ;
- }
- ;
- if(p<=m)update(p,v,lson);
- else update(p,v,rson);
- pushup(rt);
- }
- int query(int l1,int r1,int l,int r,int rt)
- {
- if(l1<=l&&r1>=r)
- return sum[rt];
- ,ans=;
- if(l1<=m)ans=(ans+query(l1,r1,lson))%MOD;
- if(r1>m)ans=(ans+query(l1,r1,rson))%MOD;
- return ans;
- }
- char ss[maxn];
- ];
- int main()
- {
- //read;
- int n;
- while(~scanf("%d",&n))
- {
- scanf();
- memset(tot,,sizeof(tot));
- build(root);
- ;i<=n;++i)
- {
- ,t;
- )t=;
- ,p-,root)+;
- update(p,t,root);
- tot[i][]=(t-+MOD)%MOD;
- }
- build(root);
- ;--i)
- {
- ,t;
- )t=;
- ,p-,root)+;
- update(p,t,root);
- tot[i][]=(t-+MOD)%MOD;
- }
- ;
- ;i<n;++i)
- ans=(ans+tot[i][]*tot[i][])%MOD;
- printf("%d\n",ans);
- }
- ;
- }
一个多项式:(a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*.......*(an-1 * x^(2^(n-1))+1) ,给出p,求x^p的系数 (n<50 0 <=P <=1234567898765432)
其实就是把P二进制展开,然后对应位为1的a乘起来就OK。
- #include <map>
- #include <set>
- #include <list>
- #include <queue>
- #include <stack>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <bitset>
- #include <cstdio>
- #include <string>
- #include <numeric>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- ]={-,,,};
- ]={,,-,};//up down left right
- ||x>n||y<||y>m)return false;return true;}
- )*m+y;}
- #define eps 1e-8
- #define inf 0x7fffffff
- #define debug puts("BUG")
- #define lson l,m,rt<<1
- #define rson m+1,r,rt<<1|1
- #define root 1,26,1
- #define read freopen("in.txt","r",stdin)
- #define write freopen("out.txt","w",stdout)
- #define maxn 105
- #define MOD 2012
- int a[maxn];
- int gao(ll p)
- {
- ;
- ;p;++i,p>>=)
- )ans=(ans*a[i])%MOD;
- return ans;
- }
- int main()
- {
- //read;
- int cas;
- scanf("%d",&cas);
- while(cas--)
- {
- int n,m;
- scanf("%d",&n);
- memset(a,,sizeof(a));
- ;i<=n;++i)
- scanf("%d",a+i);
- scanf("%d",&m);
- ll p;
- while(m--)
- {
- scanf("%lld",&p);
- printf("%d\n",gao(p));
- }
- }
- ;
- }
一个数如果某位含有7或能被7整除,那么这种数为A-Number ,把A数写成数列,如果下标不是A-number的A-number是B-number。求第n个B-number,保证答案不超long long
这题真像腾讯马拉松 HDU 4507,首先如果我们知道n以内有多少个A-Number,那么不仅第n个A-Number可以通过二分求出,B-Number,同理也能求出。问题的关键就是求n以内A-Number的个数。可以用数位DP求出n内的A-Number,其中DP[i][j][k]表示i位数,mod 7 ==j k==1?数位含7:不含7的数的A-Number的个数,将n十进制分解,然后逐位累加就可以求出答案了。
- #include <map>
- #include <set>
- #include <list>
- #include <queue>
- #include <stack>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <bitset>
- #include <cstdio>
- #include <string>
- #include <numeric>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- ]={-,,,};
- ]={,,-,};//up down left right
- ||x>n||y<||y>m)return false;return true;}
- )*m+y;}
- #define eps 1e-8
- #define inf 0x7fffffff
- #define debug puts("BUG")
- #define lson l,m,rt<<1
- #define rson m+1,r,rt<<1|1
- #define root 1,n,1
- #define read freopen("in.txt","r",stdin)
- #define write freopen("out.txt","w",stdout)
- #define maxn 25
- #define MOD 2012
- int d[maxn];
- ull dp[maxn][][];
- ull dfs(int dx,int mod7,int have7,int limit)
- {
- if(!dx)return (!mod7||have7);
- if(!limit&&~dp[dx][mod7][have7])
- return dp[dx][mod7][have7];
- ;
- if(limit)w=d[dx];
- ull tot=0ULL;
- ;i<=w;++i)
- {
- *mod7+i)%;
- );
- tot+=dfs(dx-,tmod7,thave7,limit&&i==w);
- }
- if(!limit)dp[dx][mod7][have7]=tot;
- return tot;
- }
- ull gao(ull n)
- {
- ;
- while(n)
- {
- d[++cnt]=n%;
- n/=;
- }
- ull t=dfs(cnt,,,);
- ;
- }
- ull bin(ull n)
- {
- ull l=7ULL,r=(1ULL<<)-,m;
- while(l<=r)
- {
- m=(l+r)>>;
- ull t1=gao(m);
- ull t2=t1-gao(t1);
- ;
- ;
- }
- ;
- }
- int main()
- {
- //read;
- memset(dp,-,sizeof(dp));
- ull n;
- while(~scanf("%llu",&n))
- printf("%llu\n",bin(n));
- ;
- }
一个长度为n的数组,q次询问[L,R]之间在[A,B]范围内的个数(n,q<5*10^4)。
这题很像HDU 4417 ,线段树离线操作,可以先把数组和询问全部保存下来,然后数组按照权从小到大排序,然后询问先按照B从小到大排序,然后线段树在按序插入数组中的数,然后就可以依次回答排序后的询问了,同理再按A排序,做差就是答案。另外还可以用划分树做。
- #include <map>
- #include <set>
- #include <list>
- #include <queue>
- #include <stack>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <bitset>
- #include <cstdio>
- #include <string>
- #include <numeric>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- ]={-,,,};
- ]={,,-,};//up down left right
- ||x>n||y<||y>m)return false;return true;}
- )*m+y;}
- #define eps 1e-8
- #define inf 0x7fffffff
- #define debug puts("BUG")
- #define lson l,m,rt<<1
- #define rson m+1,r,rt<<1|1
- #define root 1,n,1
- #define read freopen("in.txt","r",stdin)
- #define write freopen("out.txt","w",stdout)
- #define maxn 50005
- #define MOD 2012
- ];
- struct str1
- {
- int h,dx;
- bool operator <(const str1 t) const{return h<t.h;}
- }nd[maxn];
- struct str2
- {
- int l,r,h1,h2,dx;
- }que[maxn];
- bool cmp1(str2 s1,str2 s2)
- {
- return s1.h1<s2.h1;
- }
- bool cmp2(str2 s1,str2 s2)
- {
- return s1.h2<s2.h2;
- }
- ];
- void pushup(int rt)
- {
- sum[rt]=sum[rt<<]+sum[rt<<|];
- return ;
- }
- void build(int l,int r,int rt)
- {
- if(l==r)
- {
- sum[rt]=;
- return ;
- }
- ;
- build(lson);
- build(rson);
- pushup(rt);
- }
- void update(int p,int l,int r,int rt)
- {
- if(l==r)
- {
- ++sum[rt];
- return ;
- }
- ;
- if(p<=m)update(p,lson);
- else update(p,rson);
- pushup(rt);
- }
- int query(int l1,int r1,int l,int r,int rt)
- {
- if(l1<=l&&r1>=r)
- return sum[rt];
- ,ans=;
- if(l1<=m)ans+=query(l1,r1,lson);
- if(r1>m)ans+=query(l1,r1,rson);
- return ans;
- }
- int main()
- {
- //read;
- int cas;
- scanf("%d",&cas);
- ;xx<=cas;++xx)
- {
- int n,m;
- scanf("%d%d",&n,&m);
- //保存节点和查询信息,离线线段树
- ;i<=n;++i)
- {
- scanf("%d",&nd[i].h);
- nd[i].dx=i;
- }
- ;i<=m;++i)
- {
- scanf("%d%d%d%d",&que[i].l,&que[i].r,&que[i].h1,&que[i].h2);
- que[i].dx=i;
- }
- //对于每个节点,按权值从小到大排序
- sort(nd+,nd+n+);
- //对每个询问,先按h2从小到大排序
- sort(que+,que++m,cmp2);
- build(root);
- ;
- ;i<=m;++i)
- {
- while(cnt<=n&&nd[cnt].h<=que[i].h2)
- {
- update(nd[cnt].dx,root);
- ++cnt;
- }
- ans[que[i].dx][]=query(que[i].l,que[i].r,root);
- }
- build(root);
- //再对每个询问,先按h1从小到大排序
- sort(que+,que++m,cmp1);
- cnt=;
- ;i<=m;++i)
- {
- while(cnt<=n&&nd[cnt].h<que[i].h1)
- {
- update(nd[cnt].dx,root);
- ++cnt;
- }
- ans[que[i].dx][]=query(que[i].l,que[i].r,root);
- }
- printf("Case #%d:\n",xx);
- //答案就是两次统计的差值
- ;i<=m;++i)
- printf(]-ans[i][]);
- }
- ;
- }
一个n行三角形迷宫,有概率向左,向左下,向右下移动。求从顶点移动到最左下角的步数期望(n<45)。
比较简单的期望题,因为递推关系中无环,所以DP线性递推。方向要搞对,从下向上,从左到右。
- #include <map>
- #include <set>
- #include <list>
- #include <queue>
- #include <stack>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <bitset>
- #include <cstdio>
- #include <string>
- #include <numeric>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- ]={-,,,};
- ]={,,-,};//up down left right
- ||x>n||y<||y>m)return false;return true;}
- )*m+y;}
- #define eps 1e-8
- #define inf 0x7fffffff
- #define debug puts("BUG")
- #define lson l,m,rt<<1
- #define rson m+1,r,rt<<1|1
- #define read freopen("in.txt","r",stdin)
- #define write freopen("out.txt","w",stdout)
- #define maxn 55
- #define MOD 1000000007
- double dp[maxn][maxn];
- int main()
- {
- //read;
- int n;
- while(scanf("%d",&n),n)
- {
- double a,b,c,d,e;
- scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
- dp[n][]=;
- ;i<=n;++i)
- dp[n][i]=dp[n][i-]+1.0;
- ;i>;--i)
- {
- dp[i][]=a*dp[i+][]+b*dp[i+][]+1.0;
- ;j<n;++j)
- dp[i][j]=c*dp[i+][j]+d*dp[i+][j+]+e*dp[i][j-]+1.0;
- }
- printf(][]);
- }
- ;
- }
题意是模拟一个打印服务。
一道水题,可以直接模拟,由于赛场上一个很戏剧性的剧情,导致这个题AC的并不多。
- #include <map>
- #include <set>
- #include <list>
- #include <queue>
- #include <stack>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <bitset>
- #include <cstdio>
- #include <string>
- #include <numeric>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <functional>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- ]={-,,,};
- ]={,,-,};//up down left right
- ||x>n||y<||y>m)return false;return true;}
- )*m+y;}
- #define eps 1e-8
- #define inf 0x7fffffff
- #define debug puts("BUG")
- #define lson l,m,rt<<1
- #define rson m+1,r,rt<<1|1
- #define read freopen("in.txt","r",stdin)
- #define write freopen("out.txt","w",stdout)
- #define maxn 105
- #define MOD 2012
- int n,s,x,y,mod;
- struct str
- {
- ];
- int p;
- };
- str tt[maxn];
- void gao(int ff)
- {
- int now=s;
- ;i<=n;++i)
- {
- if(tt[i].p<=now)
- {
- printf("%d pages for %s\n",tt[i].p,tt[i].name);
- now-=tt[i].p;
- }
- else
- {
- printf("%d pages for %s\n",now,tt[i].name);
- s=(x*s+y)%mod;
- now=s;
- --i;
- }
- }
- puts("");
- }
- int main()
- {
- //read;
- int cas;
- scanf("%d",&cas);
- while(cas--)
- {
- scanf("%d%d%d%d%d",&n,&s,&x,&y,&mod);
- ],s2[];
- ;i<=n;++i)
- scanf("%s%s%d%s",tt[i].name,s1,&tt[i].p,s2);
- gao(cas);
- }
- ;
- }
这次省赛很悲剧,由于160min出第4题后一直哑火到比赛结束。最终只拿到银牌。
很讽刺的是这是最后一次参加比赛了,可却是总结最认真的一次。平时做题不好好总结,赛场上出这么多原题就傻眼了吧,看来这就是平时偷懒不认真总结的报应了。
最后感谢SDUT E_star 给了我一些题目的思路,并提供了标程和数据让我能对拍。
[ACM]2013山东省“浪潮杯”省赛 解题报告的更多相关文章
- 2013山东省“浪潮杯”省赛 A.Rescue The Princess
A.Rescue The PrincessDescription Several days ago, a beast caught a beautiful princess and the princ ...
- 2016 ACM/ICPC亚洲区大连站-重现赛 解题报告
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5979 按AC顺序: I - Convex Time limit 1000 ms Memory li ...
- ZROIDay4-比赛解题报告
ZROIDay4-比赛解题报告 扯闲话 感觉这个出题人的题做起来全都没感觉啊,今天又凉了,T1完全不知道什么意思,T2只会暴力,T3现在还不懂什么意思,真的太菜了 A 题意半天没搞懂爆零GG了,讲了一 ...
- ZROIDay3-比赛解题报告
ZROIDay3-比赛解题报告 瞎扯 从今天开始考试有点不在状态,可能是因为不太适应题目的原因,T1已经接近了思想但是没有想到状态转移,T2思考方向错误,T3不会打LCT,还是太菜了 A 考场上想到要 ...
- 10.30 NFLS-NOIP模拟赛 解题报告
总结:今天去了NOIP模拟赛,其实是几道USACO的经典的题目,第一题和最后一题都有思路,第二题是我一开始写了个spfa,写了一半中途发现应该是矩阵乘法,然后没做完,然后就没有然后了!第二题的暴力都没 ...
- CH Round #56 - 国庆节欢乐赛解题报告
最近CH上的比赛很多,在此会全部写出解题报告,与大家交流一下解题方法与技巧. T1 魔幻森林 描述 Cortana来到了一片魔幻森林,这片森林可以被视作一个N*M的矩阵,矩阵中的每个位置上都长着一棵树 ...
- 2018.10.26NOIP模拟赛解题报告
心路历程 预计得分:\(100 + 100 + 70\) 实际得分:\(40 + 100 + 70\) 妈妈我又挂分了qwq..T1过了大样例就没管,直到临考试结束前\(10min\)才发现大样例是假 ...
- 2014山东省“浪潮杯”第五届ACM省赛总结
一次比赛做一次总结,弱菜又来总结了…… 我这种大四的又死皮赖来混省赛了,貌似就我和山大威海的某哥们(不详其大名)了吧.颁奖前和他聊天,得知他去百度了,真是不错,ORZ之. 比赛流水账: 题目目前不知道 ...
- Anagram(山东省2018年ACM浪潮杯省赛)
Problem Description Orz has two strings of the same length: A and B. Now she wants to transform A in ...
随机推荐
- 简谈Redis
1.为什么使用redis 分析:博主觉得在项目中使用redis,主要是从两个角度去考虑:性能和并发.当然,redis还具备可以做分布式锁等其他功能,但是如果只是为了分布式锁这些其他功能,完全还有其他中 ...
- Python之爬虫-猫眼电影
Python之爬虫-猫眼电影 #!/usr/bin/env python # coding: utf-8 import json import requests import re import ti ...
- python flask获取微信用户信息报404,nginx问题
在学习flask与微信公众号时问题,发现测试自动回复/wechat8008时正常,而测试获取微信用户信息/wechat8008/index时出现404.查询资料后收发是nginx配置问题. 在loca ...
- LeetCode(61) Rotate List
题目 Given a list, rotate the list to the right by k places, where k is non-negative. For example: Giv ...
- LeetCode(88)Merge Sorted Array
题目 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note ...
- Borrowers
Description I mean your borrowers of books - those mutilators of collections, spoilers of the symmet ...
- 下载Spring4.1.x源码并用IntelliJ IDEA打开-----
下载Spring4.1.x源码并用IntelliJ IDEA打开-------https://blog.csdn.net/boling_cavalry/article/details/79426075 ...
- SPOJ 3261 (树套树傻逼题)
As another one of their crazy antics, the N (1 ≤ N ≤ 100,000) cows want Farmer John to race against ...
- codeforces 362A找规律
刚开始以为是搜索白忙活了原来是个简单的找规律,以后要多想啊 此题是两马同时跳 A. Two Semiknights Meet time limit per test 1 second memory l ...
- [转]MySQL5字符集支持及编码研究
前言 在更新数据库时,有时会遇到这样的错误: Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_general_ci,COER ...