2013 亚洲区域赛 长沙站


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.
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



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.
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 gets 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
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.
Please note that the coin might not even touch the medal or slip through 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
hnu 13163 hdu 4793

给个硬币  从一个圈的外面开始移动  问能够在这个圈的范围内呆多长时间

圈内还有一个圆盘  硬币与它相撞之后会按反方向反弹


思路:简单的计算几何  给出硬币圆心运动轨迹 看与圆圈和圆盘相交的情况

得到一个关于时间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;
}






  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值