2013长沙现场赛三道铜牌题目
来源:互联网 发布:端口号查询 编辑:程序博客网 时间:2024/04/27 14:22
Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using her print service found some tricks to save money.
For example, the price when printing less than 100 pages is 20 cents per page, but when printing not less than 100 pages, you just need to pay only 10 cents per page. It's easy to figure out that if you want to print 99 pages, the best choice is to print an extra blank page so that the money you need to pay is 100 × 10 cents instead of 99 × 20 cents.
Now given the description of pricing strategy and some queries, your task is to figure out the best ways to complete those queries in order to save money.
Input
The first line contains an integer T (≈ 10) which is the number of test cases. Then T cases follow.
Each case contains 3 lines. The first line contains two integers n, m (0 < n, m ≤ 105). The second line contains 2n integers s1, p1, s2, p2, ..., sn, pn (0=s1 < s2 < ... < sn ≤ 109, 109 ≥ p1 ≥ p2 ≥ ... ≥ pn ≥ 0). The price when printing no less than si but less than si+1 pages is pi cents per page (for i=1..n-1). The price when printing no less than sn pages is pn cents per page. The third line containing m integers q1 .. qm (0 ≤ qi ≤ 109) are the queries.
Output
For each query qi, you should output the minimum amount of money (in cents) to pay if you want to print qi pages, one output in one line.
Sample Input
12 30 20 100 100 99 100
Sample Output
010001000
Author: ZHUANG, Junyuan
Contest: The 2013 ACM-ICPC Asia Changsha Regional Contest
#include<iostream>#include<cstdio>using namespace std;const int maxn=100005;int n,q;int s[maxn];int v[maxn];long long val[maxn];int bitsearch(int x) //二分还是写得很次{ int l,r,mid; l=1,r=n; mid=(l+r)>>1; while(l<r) { if(l==r-1) { if(s[r]<x) { mid=r; break; } else { mid=l; break; } } if(s[mid]<x) l=mid; else r=mid-1; mid=(l+r)>>1; } return mid;}int main(){ int tes,i; cin>>tes; int a,b,tmp; while(tes--) { scanf("%d%d",&n,&q); for(i=1;i<=n;i++) { scanf("%d%d",&a,&b); s[i]=a; v[i]=b; val[i]=(long long)a*b; } for(i=n-1;i>=1;i--) val[i]=min(val[i],val[i+1]); for(i=1;i<=q;i++) { scanf("%d",&tmp); if(tmp>=s[n]) printf("%lld\n",(long long)tmp*v[n]); else { int ans = bitsearch(tmp); //cout<<ans<<endl; int t=min(n,ans+1); long long res= min ((long long)tmp*v[ans],val[t]); printf("%lld\n",res); } } } return 0;}
A role-playing game (RPG and sometimes roleplaying game) is a game in which players assume the roles of characters in a fictional setting. Players take responsibility for acting out these roles within a narrative, either through literal acting or through a process of structured decision-making or character development.
Recently, Josephina is busy playing a RPG named TX3. In this game, M characters are available to by selected by players. In the whole game, Josephina is most interested in the "Challenge Game" part.
The Challenge Game is a team play game. A challenger team is made up of three players, and the three characters used by players in the team are required to be different. At the beginning of the Challenge Game, the players can choose any characters combination as the start team. Then, they will fight with N AI teams one after another. There is a special rule in the Challenge Game: once the challenger team beat an AI team, they have a chance to change the current characters combination with the AI team. Anyway, the challenger team can insist on using the current team and ignore the exchange opportunity. Note that the players can only change the characters combination to the latest defeated AI team. The challenger team get victory only if they beat all the AI teams.
Josephina is good at statistics, and she writes a table to record the winning rate between all different character combinations. She wants to know the maximum winning probability if she always chooses best strategy in the game. Can you help her?
Input
There are multiple test cases. The first line of each test case is an integer M (3 ≤ M ≤ 10), which indicates the number of characters. The following is a matrix T whose size is R × R. R equals to C(M, 3). T(i, j) indicates the winning rate of team i when it is faced with team j. We guarantee that T(i, j) + T(j, i) = 1.0. All winning rates will retain two decimal places. An integer N (1 ≤ N ≤ 10000) is given next, which indicates the number of AI teams. The following line contains N integers which are the IDs (0-based) of the AI teams. The IDs can be duplicated.
Output
For each test case, please output the maximum winning probability if Josephina uses the best strategy in the game. For each answer, an absolute error not more than 1e-6 is acceptable.
Sample Input
40.50 0.50 0.20 0.300.50 0.50 0.90 0.400.80 0.10 0.50 0.600.70 0.60 0.40 0.5030 1 2
Sample Output
0.378000
Author: LIN, Yue
Contest: The 2013 ACM-ICPC Asia Changsha Regional Contest
dp[i][j]代表是打败前i个队伍后且当前的队伍是j的最大胜率。。
dp[i][j] = max(dp[i][j],dp[i-1][j]*P[j][no[i]]); //代表不换
dp[i][no[i]] = max(dp[i][no[i]],dp[i-1][j]*P[j][no[i]]);//代表换战队
#include<iostream>#include<cstdio>using namespace std;double mp[202][202];double dp[10005][202];int a[10005];int cal(int x){ return x*(x-1)*(x-2)/6;}int main(){ int n,s,i,j; double res; int m; while(~scanf("%d",&n)) { s=cal(n); for(i=0;i<s;i++) for(j=0;j<s;j++) scanf("%lf",&mp[i][j]); //memset(dp,0,sizeof(dp)); for(i=0;i<s;i++) { dp[0][i]=1; for(j=1;j<=m;j++) dp[j][i]=0; } res=0; scanf("%d",&m); for(i=1;i<=m;i++) scanf("%d",&a[i]); for(i=1;i<=m;i++) { for(j=0;j<s;j++) { dp[i][j]=max(dp[i][j],dp[i-1][j]*mp[j][a[i]]); //²»½»»» dp[i][a[i]]=max(dp[i][a[i]],dp[i-1][j]*mp[j][a[i]]); //½»»» } } for(i=0;i<s;i++) res=max(res,dp[m][i]); printf("%.8f\n",res); } return 0;}
There's a round medal fixed on an ideal smooth table, Fancy is trying to throw some coins and make them slip towards the medal to collide. There's also a round range which shares exact the same center as the round medal, and radius of the medal is strictly less than radius of the round range. Since that the round medal is fixed and the coin is a piece of solid metal, we can assume that energy of the coin will not lose, the coin will collide and then moving as reflect.
Now assume that the center of the round medal and the round range is origin ( Namely (0, 0) ) and the coin's initial position is strictly outside the round range. Given radius of the medal Rm, radius of coin r, radius of the round range R, initial position (x, y) and initial speed vector (vx, vy) of the coin, please calculate the total time that any part of the coin is inside the round range.
Please note that the coin might not even touch the medal or slip through the round range.
Input
There will be several test cases. Each test case contains 7 integers Rm, R, r, x, y, vx and vy in one line. Here 1 ≤ Rm < R ≤ 2000, 1 ≤ r ≤ 1000, R + r < |(x, y)| ≤ 20000, 1 ≤ |(vx, vy)| ≤ 100.
Output
For each test case, please calculate the total time that any part of the coin is inside the round range. Please output the time in one line, an absolute error not more than 1e-3 is acceptable.
Sample Input
5 20 1 0 100 0 -15 20 1 30 15 -1 0
Sample Output
30.00029.394
Author: FAN, Yuzhe
Contest: The 2013 ACM-ICPC Asia Changsha Regional Contest
#include<iostream>#include<cmath>#include<cstdio>#include<cstring>using namespace std;const double eps = 1e-12;const double PI = acos(-1.0);double fun(double a){ if(a<0) return -a; return a;}int main(){ double Rm,R,r,x0,y0,vx,vy,v; while(~scanf("%lf%lf%lf%lf%lf%lf%lf",&Rm,&R,&r,&x0,&y0,&vx,&vy)) { v=sqrt(vx*vx+vy*vy); double dis = fun(y0*vx-x0*vy)/v; if(dis-R-r>=eps) puts("0"); else if(dis-Rm-r>=eps) { if(x0*vx+y0*vy>=eps) puts("0"); //这个地方坑了很久,感谢那天志愿者的高钙牛奶 else { double s=2.0*sqrt((R+r)*(R+r)-dis*dis); printf("%.9f\n",s/v); } } else { if(x0*vx+y0*vy>=eps) puts("0"); /*else //自己开始写的代码,后来可以简化成下面的 { double a,b,c; double angel=asin(dis/(Rm+r)); angel = PI - angel; b=Rm+r,c=R+r; a=(2.0*b*cos(angel)+sqrt(4.0*b*b*cos(angel)*cos(angel)-4.0*(b*b-c*c)))/2.0; printf("%.9f\n",2.0*a/v); }*/ else { double s = sqrt((R+r)*(R+r)-dis*dis)-sqrt((Rm+r)*(Rm+r)-dis*dis); printf("%.9f\n",2*s/v); } } } return 0;}
- 2013长沙现场赛三道铜牌题目
- 2013长沙现场赛 K . Pocket Cube
- 2013 长沙现场赛 K (Pocket Cube)
- 2013长沙现场赛C - Collision
- 组队赛3 - 2014.7.27 - 2013长沙现场赛
- zoj 3735 Josephina and RPG(2013 长沙现场赛)
- 2013长沙现场赛 Alice's Print Service
- 2013长沙现场赛A - Alice's Print Service
- 2013长沙现场赛J - Josephina and RPG
- 长沙现场赛C题
- 长沙现场赛A题
- 2013 ACM/ICPC 长沙赛区现场赛A题 解题报告
- ZOJ 3732 2013 ACM/ICPC 长沙赛区现场赛G题 Graph Reconstruction (图论)
- CUGBACM_Summer_Tranning3 2013长沙现场赛(二分+bfs模拟+DP+几何)
- HDU 4793 计算几何 2013长沙区现场赛题C题
- ZJU 3733 长沙现场赛 H Skycity
- hdu 4801 长沙现场赛K题
- hdu 4791 长沙现场赛A题
- Web开发者需具备的8个好习惯
- 11个Linux基础面试问题
- 五个 ping 工具的使用实例
- [C++]实现委托模型
- 程序调试错误记录
- 2013长沙现场赛三道铜牌题目
- 如何在Linux下监控系统温度
- Win32多线程之线程优先级
- 如何在Linux上配置基于Web的网络流量监控系统
- 为什么匿名内部类和局部内部类只能访问final变量
- 黑马程序员基础加强---泛型
- C++基础学习笔记----第十一课(类的静态成员、对象模型初步认识)
- Mysql编译安装参数优化
- easyui---layout 有无横的间隔 的区别 split:true