Alice's Print Service |
Time Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:65536KB |
Total submit users: 22, Accepted users: 14 |
Problem 13161 : No special judgement |
Problem description |
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. |
Input |
|
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 |
1 2 3 0 20 100 10 0 99 100 |
Sample Output |
0 1000 1000 |
题意就是 给定一个范围内打印服务内的价钱 然后给出要打印的数量 求出打印要花的最少的钱
先根据给的价钱 求出某个范围内最便宜的价格 然后根据询问的数量 二分查出这个数量所处的范围
特判两个 一个是少于最少的 一个是大于最多的
如果处于中间 那就比较两个值 一个是只打印这个数量 一个是大于这个数量时所花的最少的钱
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <string>
#define MEM(a,x) memset(a,x,sizeof a)
#define eps 1e-8
#define MOD 10009
#define MAXN 100010
#define INF 0x7fffffff
#define ll __int64
#define bug cout<<"here"<<endl;
#define fread freopen("ceshi.txt","r",stdin)
#define fwrite freopen("out.txt","w",stdout)
using namespace std;
ll s[MAXN],p[MAXN];
ll c[MAXN];
ll f[MAXN];
int n,m;
int bisearch(ll x)
{
if(x<s[0])
return 0;
if(x>s[n-1])
return n-1;
int mid;
int left=0;
int right=n-1;
while(left<=right)
{
mid=(left+right)/2;
if(s[mid]<x)
{
left=mid+1;
}
else if(s[mid]>x)
{
right=mid-1;
}
else return mid;
}
return min(left,right);
}
int main()
{
// fread;
int tc;
scanf("%d",&tc);
while(tc--)
{
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
scanf("%I64d%I64d",&s[i],&p[i]);
c[i]=s[i]*p[i];
}
ll inf=(ll)1e18;
f[n]=inf;
f[n-1]=c[n-1];
for(int i=n-1;i>=0;i--)
f[i]=min(f[i+1],c[i]);
while(m--)
{
ll q;
scanf("%I64d",&q);
int x=bisearch(q);
// cout<<x<<endl;
if(q<s[0])
{
printf("%I64d\n",f[0]);
continue;
}
if(x==n-1)
{
printf("%I64d\n",q*p[n-1]);
continue;
}
// cout<<q*p[x]<<endl;
// cout<<f[x+1]<<endl;
printf("%I64d\n",min(q*p[x],f[x+1]));
}
}
return 0;
}
Josephina and RPG |
Time Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:65536KB |
Total submit users: 8, Accepted users: 8 |
Problem 13170 : Special judge |
Problem description |
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. |
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 |
4 0.50 0.50 0.20 0.30 0.50 0.50 0.90 0.40 0.80 0.10 0.50 0.60 0.70 0.60 0.40 0.50 3 0 1 2 |
Sample Output |
0.378000 |
有m个队在游戏中 选三个队进行游戏
给出这C(m,3)互相之间的比赛赢的概率
然后依次 对阵N个AI队伍 如果赢了就可以选择替换成AI队伍 也可以继续使用这个 求最后全胜的最大的概率
思路:dp[i][j]表示打第i个敌人用第j个队伍获胜的最大概率 p[i][j]表示第i种队伍对第j种队伍获胜的概率
AI队伍的第i个为a[i] 根据选择是否替换 有状态转移 选择之前概率最大的
dp[i][j]=p[j][a[i]]*max(dp[i+1][j],dp[i+1][a[i]])
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <string>
#define MEM(a,x) memset(a,x,sizeof a)
#define eps 1e-8
#define MOD 10009
#define MAXN 10010
#define INF 0x7fffffff
#define ll __int64
#define bug cout<<"here"<<endl;
#define fread freopen("ceshi.txt","r",stdin)
#define fwrite freopen("out.txt","w",stdout)
using namespace std;
int c[11]={0,0,0,1,4,10,20,35,56,84,120}; //C(i,3)的值
double p[130][130];
double dp[MAXN][130];
int a[MAXN];
int main()
{
// fread;
int m,n;
while(scanf("%d",&m)!=EOF)
{
for(int i=0;i<c[m];i++)
for(int j=0;j<c[m];j++)
scanf("%lf",&p[i][j]);
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=0;i<=n;i++)
{
for(int j=0;j<c[m];j++)
dp[i][j]=0.0;
}
for(int i=0;i<c[m];i++)
dp[n+1][i]=1.0;
for(int i=n;i>0;i--)
{
for(int j=0;j<c[m];j++)
{
dp[i][j]=p[j][a[i]]*max(dp[i+1][j],dp[i+1][a[i]]);
}
}
double ans=0.0;
for(int i=0;i<c[m];i++)
ans=max(ans,dp[1][i]);
printf("%.6lf\n",ans);
}
return 0;
}
Collision |
Time Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:65536KB |
Total submit users: 6, Accepted users: 6 |
Problem 13163 : Special judge |
Problem description |
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. |
Input |
|
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 -1 5 20 1 30 15 -1 0 |
Sample Output |
30.000 29.394 |
给个硬币 从一个圈的外面开始移动 问能够在这个圈的范围内呆多长时间
圈内还有一个圆盘 硬币与它相撞之后会按反方向反弹
思路:简单的计算几何 给出硬币圆心运动轨迹 看与圆圈和圆盘相交的情况
得到一个关于时间t的一元二次方程 求delta根据delta正负判断有木有解
有解的话 根据公式可以得到两个解的值
氛围两种情况 一是进入圆圈内不与圆盘相撞 二是与圆盘相撞
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <string>
#define MEM(a,x) memset(a,x,sizeof a)
#define eps 1e-8
#define MOD 10009
#define MAXN 10010
#define INF 0x7fffffff
#define ll __int64
#define bug cout<<"here"<<endl;
#define fread freopen("ceshi.txt","r",stdin)
#define fwrite freopen("out.txt","w",stdout)
using namespace std;
int sig(double x)
{
if(x>eps)
return 1;
if(x<-eps)
return -1;
return 0;
}
int main()
{
double Rm, R, r, x, y, vx, vy;
while(scanf("%lf%lf%lf%lf%lf%lf%lf",&Rm,&R,&r,&x,&y,&vx,&vy)!=EOF)
{
double a=vx*vx+vy*vy;
double b=2*x*vx+2*y*vy;
double c1=x*x+y*y-(R+r)*(R+r);
double c2=x*x+y*y-(Rm+r)*(Rm+r);
double delta1=b*b-4*a*c1;
double delta2=b*b-4*a*c2;
if(sig(delta1)<=0)
{
puts("0.000");
continue;
}
double ans11=-b+sqrt(delta1)/(2.0*a);
double ans12=-b-sqrt(delta1)/(2.0*a);
if(sig(ans12)>=0)
{
if(sig(delta2)<=0)
{
printf("%.3lf\n",ans11-ans12);
}
else
{
double ans22=-b-sqrt(delta2)/(2.0*a);
printf("%.3lf\n",(ans22-ans12)*2.0);
}
}
else
puts("0.000");
}
return 0;
}