青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

SRM459

Posted on 2010-01-20 19:24 rikisand 閱讀(355) 評論(0)  編輯 收藏 引用 所屬分類: TopcoderAlgorithm

幾次沒寫了,這兩天給補上~~

晚上果然不清醒,250的就卡了很久,然后直接看1000,算概率的,有個樣例沒看明白,其實早上一下就想明白了···500的十分鐘基本寫對了,沒來得及交~ 倆字 杯具~~

250pt

Problem Statement

Draw a square with side length sideLength on a plane. Then, inscribe a circle in the square. Inscribe another square in that circle, and yet another circle in the second square. Continue this process until K circles appear on the plane.
For example, if K=3, the picture would look like this:

For each circle, compute the area within the circle that does not belong to any other figure inside that circle. Return the sum of those areas. In the example above, the area to compute is colored in stripes.

Definition

Class:
RecursiveFigures

Method:
getArea

Parameters:
int, int

Returns:
double

Method signature:
double getArea(int sideLength, int K)

(be sure your method is public)

Notes

-
Your return value must have an absolute or relative error less than 1e-9.

-
The area of square with side length A is A*A.

-
The area of circle with radius R is pi*R*R.

-
The length of diameter of the circle inscribed in a square is equal to the square's side length.

-
The side length of the square inscribed in circle with radius R is equal to R*sqrt(2).

Constraints

-
sideLength will be between 1 and 100, inclusive.

-
K will be between 1 and 10, inclusive.

Examples

0)

10
1
Returns: 78.53981633974483

1)

10
2
Returns: 67.80972450961724

2)

10
3
Returns: 62.444678594553444

        double getArea(int side, int K)
        {
            double ans = 0.;int n=side;double r=side;
            for(int i=0;i<K;i++){
                ans += r*r*(1-acos(-1.)/4.); //正方形面積減去圓面積
                r /= pow(2.,0.5);
            }
            return n*n - ans;
        }

 

500pt

You are given six integers, minx, maxx, miny, maxy, minz and maxz. Return the number of triplets of integers (x,y,z) that satisfy the following three conditions:

  • x is between minx and maxx, inclusive.
  • y is between miny and maxy, inclusive.
  • z is between minz and maxz, inclusive.
  • x * y = z
Definition

Class:
ProductTriplet

Method:
countTriplets

Parameters:
int, int, int, int, int, int

Returns:
long long

Method signature:
long long countTriplets(int minx, int maxx, int miny, int maxy, int minz, int maxz)

(be sure your method is public)

Constraints

-
maxx will be between 1 and 1,000,000,000, inclusive.

-
maxy will be between 1 and 1,000,000,000, inclusive.

-
maxz will be between 1 and 1,000,000,000, inclusive.

-
minx will be between 1 and maxx, inclusive.

-
miny will be between 1 and maxy, inclusive.

-
minz will be between 1 and maxz, inclusive.

Examples

0)

2
2
3
3
6
6
Returns: 1

2 * 3 = 6.

1)

2
2
3
3
7
7
Returns: 0

2 * 3 is not 7.

2)

6
8
4
5
27
35
Returns: 4

(x,y,z) = (6,5,30), (7,4,28), (7,5,35) and (8,4,32) satisfy all conditions.

3)

1
458
1
458
1
458
Returns: 2877

4)

8176
184561
1348
43168
45814517
957843164
Returns: 2365846085
        int maximumSubset(vector <string> in)
        {
             vector<int> vec(2010,0); 
             int mx=0;
             for(int j=0;j<in.size();j++){
                stringstream ss(in[j]);string str1,str;int s;
                ss>>str1>>str>>s;double k=-1;
                for(int i=0;i<2008;i++){
                    k+=0.5;
                    bool tag=false;
                    if(str=="="){
                        if(s==k)tag=true;
                    }
                    else if(str==">="){
                        if(k>=s)tag=true;
                    }
                    else if(str==">"){
                        if(k>s)tag=true;
                    }
                    else if(str=="<="){
                        if(k<=s)tag=true;
                    }
                    else if(str=="<"){
                        if(k<s)tag=true;
                    } 
                    if(tag)vec[i]++;
                }
             }
                for(int i=0;i<2008;i++)if(vec[i]>mx)mx=vec[i];
             //for(int i=0;i<2008;i++){
                //k+=0.5;
                //for(int j=0;j<in.size();j++){
                //    stringstream ss(in[j]);string str1,str;int s;
                //    ss>>str1>>str>>s;
                //    bool tag=false;
                //    if(str=="="){
                //        if(s==k)tag=true;
                //    }
                //    else if(str==">="){
                //        if(k>=s)tag=true;
                //    }
                //    else if(str==">"){
                //        if(k>s)tag=true;
                //    }
                //    else if(str=="<="){
                //        if(k<=s)tag=true;
                //    }
                //    else if(str=="<"){
                //        if(k<s)tag=true;
                //    } 
                //    if(tag)vec[i]++;
                //}
                //if(vec[i]>mx)mx=vec[i];
             //}
             return mx;
        }

要計算最多能滿足的不等式,其實只需要枚舉所有0到1000的數看看每一個能滿足的最多不等式數量,由于k可以是小數,所以以步長0.5遞增即可

1000pt

A new ride is opened in an amusement park. It consists of N landings numbered from 0 to N-1. Some of the landings are connected with pipes. All of the landings are at different heights, so the pipes are all inclined and can only be traversed downwards.
A ride-taker begins his ride at some landing. The pipes are long enough that he cannot see where they lead before entering them. Therefore, at each landing, any descending pipe adjacent to it has an equal probability of being used by a ride-taker who reached this landing.
A ride is finished when a ride-taker reaches a landing which has no adjacent descending pipes. There are two types of such landings: exits and crocodile ponds. If the ride-taker reaches the exit landing, his ride is over and he safely returns home. If one reaches the crocodile pond, his trip is also over, but he never returns home.
You're given a vector <string> landings describing the ride. Element i of landings describes the i-th landing. If the landing is an exit, the i-th character of landings[i] will be 'E' and the rest of the characters will be '0's (zeroes). If it is a crocodile pond, the i-th character will be 'P' and the rest will be '0's. If the landing has at least one adjacent descending pipe, the j-th character of landings[i] will be '1' (one) if a pipe descends from the i-th landing to the j-th, and '0' (zero) otherwise.
A ride-taker began his ride at a randomly chosen landing, used a total of K pipes throughout his descent and safely returned home afterwards. Each of the landings has the same probability of being chosen as the initial landing of the ride. Compute the probability that he started the ride at landingstartLanding.

Definition

Class:
ParkAmusement

Method:
getProbability

Parameters:
vector <string>, int, int

Returns:
double

Method signature:
double getProbability(vector <string> landings, int startLanding, int K)

(be sure your method is public)

Notes

-
Your return value must have an absolute or relative error less than 1e-9.

Constraints

-
landings will contain exactly N elements, where N is between 2 and 50, inclusive.

-
Each element of landings will contain exactly N characters.

-
Each character in landings will be '0' (zero), '1' (one), 'E', or 'P'.

-
If the i-th element of landings contains an 'E', it will contain only one 'E' as its i-th character, and all other characters in that element will be '0'.

-
If the i-th element of landings contains a 'P', it will contain only one 'P' as its i-th character, and all other characters in that element will be '0'.

-
If the i-th element of landings doesn't contain an 'E' or a 'P', it will contain at least one '1' character. The i-th character of such element will always be '0'.

-
K will be between 1 and N-1, inclusive.

-
startLanding will be between 0 and N-1, inclusive.

-
There will be no cycles in landings, i.e. it's never possible to return to the same landing after descending through several pipes.

-
There will be at least one landing from which it is possible to reach an exit using exactly K pipes.

Examples

0)

{"E000",
 "1000",
 "1000",
 "1000"}
1
1
Returns: 0.3333333333333333

The ride contains 4 landings, one of which is an exit. Each of the other landings has a single pipe descending to the exit landing. Therefore, each of them could be the starting landing with equal probability of 1/3.

1)

{"E000",
 "1000",
 "1001",
 "000P"}
1
1
Returns: 0.6666666666666666

This time, there is an exit landing and a crocodile pond. Of the other two landings, the first has a descending pipe only to the exit, while the second is connected both to the exit and to the pond. So, the probability of reaching an exit starting from landing 2 is lower and the chances of ground 1 being the start of the journey increase.

2)

{"01000100",
 "00111000",
 "00001010",
 "000E0000",
 "0000E000",
 "00000P00",
 "000000P0",
 "01000000"}
1
2
Returns: 0.14285714285714288

Analyzing the graph above, we can see that landings 0, 1 and 7 could be the starting landings. One can reach an exit from landing 0 using 2 pipes with probability 2/6, from landing 1 with probability 1/6 and from landing 7 with probability 2/3. Therefore, the probability that the ride-taker began from landing 1 is equal to (1/6)/(2/3+2/6+1/6)=1/7.

3)

{"0100",
 "0010",
 "0001",
 "000E"}
0
2
Returns: 0.0

Obviously, the only way to get to the exit landing using 2 pipes is from ground 1. Therefore there is no chance that landing 0 was the initial ground.

4)

{"E00",
 "0E0",
 "010"}
0
1
Returns: 0.0

Note that some sections of the ride might be disconnected.

#define REP(i, n) for (int i = 0; i < (n); ++i)  
double dp[55][55];
vector<string> A ; int N;
int mp[55];
double cacl(int now,int steps){
    if(dp[now][steps]!=-1)return dp[now][steps];
    double& t = dp[now][steps];
    t=0.;int cnt=0;
    REP(i,N){
        if(A[now][i]=='1'){
            cnt++;t+=cacl(i,steps-1);
        }
    }
    t /= cnt;
    return t;
}
class ParkAmusement
{
        public:
        double getProbability(vector <string> land, int start, int K)
        {
            A=land;      N=land.size();
            REP(i,N+1)REP(j,N+1)dp[i][j]=-1;
            memset(mp,0,sizeof(mp));// 0 
            REP(i,N) 
                REP(j,N){
                    if(A[i][j]=='E'){
                        mp[i]=1;
                        REP(k,N+1)dp[i][k]=0.;
                        dp[i][0]=1.;
                    }
                    else if(A[i][j]=='P')
                    {
                        mp[i]=2;
                        REP(k,N+1)dp[i][k]=0.;
                    }
                } 
            for(int i=0;i<N;i++) 
                cacl(i,K); 
            double ans=0.;
            REP(i,N)ans+=dp[i][K];
            return dp[start][K]/ans;
        }

要求從某個出發安全完成的概率,應該等于從這里出發安全完成的概率比上從各個點出發安全完成概率和。因此要求從每一個點出發安全到達的概率。由于計算中可能出現重復計算,因此使用備忘錄memo[i][j] 計算從i出發經過j步驟安全到達的概率,而此點概率即為此點到其各個鄰接點的安全概率和除以鄰接點個數,所以很簡單,一遍就ac了,可惜晚上沒想明白~

 

 

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产精品www994| 欧美日韩一区国产| 午夜在线不卡| av成人动漫| 国产欧美精品日韩精品| 午夜亚洲视频| 久久精品国产综合| 亚洲国产视频a| 欧美一区二区播放| 亚洲电影免费观看高清完整版在线| 欧美大片国产精品| 欧美日韩成人综合| 久久中文欧美| 欧美日韩一区二区三区在线 | 午夜精品福利一区二区蜜股av| 亚洲精选久久| 久久久亚洲国产美女国产盗摄| 久久久亚洲午夜电影| 亚洲尤物在线| 在线成人中文字幕| 日韩西西人体444www| 伊人久久婷婷色综合98网| 亚洲精品乱码视频| 国产麻豆精品theporn| 欧美一区二区三区在线看| 在线午夜精品| 亚洲人成人99网站| 欧美电影电视剧在线观看| 欧美r片在线| 亚洲人成精品久久久久| 久久综合九色九九| 制服诱惑一区二区| 国产精品成人v| 国产日韩亚洲欧美综合| 欧美日韩国产小视频在线观看| 欧美www视频在线观看| 亚洲区一区二区三区| 欧美激情第二页| 亚洲一区成人| 一本大道久久精品懂色aⅴ| 久久九九精品| 久久久水蜜桃| 狼狼综合久久久久综合网| 欧美网站在线观看| 欧美亚一区二区| 91久久综合| 亚洲精品视频中文字幕| 国产日韩欧美在线一区| 国产日韩一区二区三区| 国产一区二区三区在线观看精品 | 亚洲永久免费| 91久久精品网| 日韩一级裸体免费视频| 久久综合久久88| 欧美成人乱码一区二区三区| 午夜精品在线看| 亚洲欧洲99久久| 久久免费视频网| 亚洲一区日本| 久久精品国产精品亚洲综合| 欧美亚韩一区| 国产欧美91| 国产精品va在线| 国产精品视频精品视频| 国产欧美日韩麻豆91| 亚洲在线中文字幕| 久久色在线观看| 欧美一区二区三区免费视频| 久久国产日本精品| 在线综合亚洲| 欧美一区二区三区精品电影| 亚洲午夜精品国产| av成人免费在线| 亚洲国产精品久久久久秋霞蜜臀| 好吊妞这里只有精品| 激情一区二区三区| 久久av老司机精品网站导航 | 欧美成人高清| 欧美激情综合色| 欧美国产日韩a欧美在线观看| 欧美日韩成人精品| 在线视频一区二区| 欧美成人情趣视频| 香港成人在线视频| 欧美精品免费播放| 很黄很黄激情成人| 亚洲国产精品久久久久久女王| 99精品欧美一区二区三区综合在线| 欧美日韩麻豆| 黄色在线一区| 亚洲精品久久视频| 久热这里只精品99re8久| 欧美一级视频精品观看| 亚洲国产精品久久久久久女王| 欧美伊人久久久久久午夜久久久久| 久久精品动漫| 国产精品少妇自拍| 欧美99久久| 久久久精品国产一区二区三区 | 激情综合在线| 亚洲高清在线观看| 久久精品视频在线播放| 亚洲靠逼com| 久久综合婷婷| 欧美精品二区三区四区免费看视频| 精品不卡在线| 久久久久久久久综合| 欧美极品影院| 亚洲精品中文字| 久久爱www久久做| 国产伦精品一区二区三区高清版 | 久久国产精品一区二区三区| 夜夜嗨av一区二区三区网站四季av| 国产一区二区三区的电影| 午夜精品999| 欧美精品少妇一区二区三区| 亚洲美女一区| 日韩亚洲在线| 欧美成人国产| 欧美好骚综合网| 亚洲第一综合天堂另类专| 久久亚洲综合色| 亚洲国产视频直播| 久久综合国产精品| 亚洲高清一区二区三区| 欧美亚洲系列| 国内久久精品| 欧美夜福利tv在线| 一区二区三区在线高清| 欧美国产日韩视频| 欧美另类在线播放| 亚洲国内高清视频| 亚洲国内欧美| 国产精品卡一卡二| 久久一区二区三区四区| 欧美黄色一区| 欧美精品一区二区久久婷婷| 一区二区三区欧美在线观看| 久久免费视频在线观看| 国产婷婷色一区二区三区在线| 六月天综合网| 黄色av一区| 99国产精品99久久久久久| aa亚洲婷婷| 国产一区二区无遮挡| 性欧美video另类hd性玩具| 亚洲福利视频二区| 久久深夜福利| 亚洲一区二区三区四区中文| 欧美日韩一级大片网址| 乱人伦精品视频在线观看| 国内精品视频久久| 欧美在线免费视屏| 亚洲精品久久在线| 欧美片在线播放| 久久精品卡一| 黄色一区二区三区| 亚洲视频 欧洲视频| 欧美一区二区在线视频| 欧美大秀在线观看| 一区二区三区不卡视频在线观看| 黄色一区二区三区| 欧美国产高潮xxxx1819| 久久久精品国产免大香伊| 欧美另类视频在线| 欧美成年人在线观看| 久久国产精品99国产| 国产一区二区三区奇米久涩| 一区二区三区日韩精品| 国产综合色产| 一区二区三区视频在线看| 欧美一区二区三区四区在线| 欧美激情五月| 亚洲欧美另类在线观看| 99精品视频一区| 国产欧美精品一区aⅴ影院| 亚洲裸体视频| 欧美一区二区免费观在线| 欧美刺激性大交免费视频| 亚洲性图久久| 亚洲乱码一区二区| 一区二区日韩| 亚洲老司机av| 欧美激情一区二区三区不卡| 国产精品爽黄69| 久久亚裔精品欧美| 久久资源在线| 亚洲免费在线观看| 欧美三级欧美一级| 久久久久久久一区| 久久久久免费视频| 在线一区视频| 欧美精品www| 久久精品国产一区二区三区免费看| 欧美一区二区在线免费观看| 亚洲免费电影在线| 欧美激情精品久久久久久蜜臀| 亚洲摸下面视频| 亚洲午夜高清视频| 91久久国产综合久久|