Third_Training

来源:互联网 发布:淘宝卖家帐号在那登陆 编辑:程序博客网 时间:2024/06/01 17:11

HNAU Third Training Problem

考查知识点     题号    problem_name         难度系数   解题思路        First Blood

A.数学题        zoj2625   Rearrange Them     ★☆     递推+大数加法         -
B.多项式        zoj3001   Password                                                             -
C.方程求根    ZOJ-2351  Litmus Test                                                        -
D.字符串处理 HDU2609   How many                                                         -
E.图论+并查集HDU1598   find the most comfortable road                    钟雄辉
F.计算几何    poj 2318  TOYS                                                                    wj
G.高精度       poj2325   Persistent Numbers       
H.动态规划    poj2385   Apple Catching                                                     wj



#include <cstdio>#include <cstring>int f[101][202];void add(int a,int b,int c){    int i,car=0,k;    for(i=0;i<=200;i++){        k=b*f[b][i]+c*f[c][i]+car;        f[a][i]=k%10;        car=k/10;    }}void DP(){    int i;    memset(f,0,sizeof(f));    f[0][0]=0;    f[1][0]=0;    f[2][0]=1;    f[3][0]=3;    for(i=4;i<=100;i++){        add(i,i-1,i-2);    }}int main(){    int i,j,n;    DP();    while(scanf("%d",&n)!=EOF){        if(n==0 || n==1){            printf("0\n");            continue;        }        for(i=200;i>=0;i--)            if(f[n][i]) break;        for(j=i;j>=0;j--)            printf("%d",f[n][j]);        printf("\n");    }    return 0;}









#include <iostream>

#include <cstdio>
#include <cstring>


using namespace std;
#define M 5002
#define INF 1e8
struct point{
  int x1,x2;
  int num;
}graph[M];
int n;
int x1,y1,x2,y2;
void show()
{
    for(int i=0;i<=n;i++)
        printf("%d: %d\n",i, graph[i].num);
}
int crossMulti(int a1,int b1,int a2,int b2)
{
    return a1*b2-a2*b1;
}
void Insert(int x,int y)
{


    if(crossMulti(graph[1].x2-graph[1].x1,y2-y1,x-graph[1].x1,y-y1)<0)
    { graph[0].num++;return;}
    if(crossMulti(graph[n].x2-graph[n].x1,y2-y1,x-graph[n].x1,y-y1)>0)
    { graph[n].num++;return;}
    int low=0,high=n;
    int i=0;
    //((graph[i].x1,y1) ((graph[i].x2,y2)   (graph[i].x1,y1)  (x,y))
    while(high-low>1)
    {
        i=(low+high)/2;
        if(crossMulti(graph[i].x2-graph[i].x1,y2-y1,x-graph[i].x1,y-y1)>0)
         low=i;
        else
         high=i;
    }
    graph[low].num++;
}
int main()
{
    int i,x,y,m;
    int first=0;
    while(~scanf("%d",&n)&&n)
    {
        if(first)cout<<endl;
        first=1;
        scanf("%d%d%d%d%d",&m,&x1,&y1,&x2,&y2);
        graph[0].num=0;
        for(i=1;i<=n;i++)
        {
            scanf("%d%d",&graph[i].x1,&graph[i].x2);
            graph[i].num=0;
        }
        for(int i=1;i<=m;i++)
         {
            scanf("%d%d",&x,&y);
            Insert(x,y);
         }
        show();
    }
    return 0;
}
原创粉丝点击