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

SRM459

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

幾次沒(méi)寫了,這兩天給補(bǔ)上~~

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

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;
        }

要計(jì)算最多能滿足的不等式,其實(shí)只需要枚舉所有0到1000的數(shù)看看每一個(gè)能滿足的最多不等式數(shù)量,由于k可以是小數(shù),所以以步長(zhǎng)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;
        }

要求從某個(gè)出發(fā)安全完成的概率,應(yīng)該等于從這里出發(fā)安全完成的概率比上從各個(gè)點(diǎn)出發(fā)安全完成概率和。因此要求從每一個(gè)點(diǎn)出發(fā)安全到達(dá)的概率。由于計(jì)算中可能出現(xiàn)重復(fù)計(jì)算,因此使用備忘錄memo[i][j] 計(jì)算從i出發(fā)經(jīng)過(guò)j步驟安全到達(dá)的概率,而此點(diǎn)概率即為此點(diǎn)到其各個(gè)鄰接點(diǎn)的安全概率和除以鄰接點(diǎn)個(gè)數(shù),所以很簡(jiǎn)單,一遍就ac了,可惜晚上沒(méi)想明白~

 

 

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美视频在线观看一区| 欧美日韩精品欧美日韩精品| 亚洲电影免费在线观看| 午夜精品影院| 欧美 日韩 国产一区二区在线视频 | 亚洲一级二级在线| 国产精品免费看久久久香蕉| 亚洲手机成人高清视频| 老鸭窝毛片一区二区三区| 亚洲激情国产精品| 欧美性猛交xxxx乱大交蜜桃| 久久裸体艺术| 久热成人在线视频| 老司机一区二区三区| 欧美激情一区二区| 久久久精品国产99久久精品芒果| 亚洲日本一区二区| 国产综合色在线视频区| 国产精品麻豆欧美日韩ww| 国产欧美日韩| 欧美xart系列高清| 亚洲欧美春色| 一个色综合导航| 亚洲国产高清一区二区三区| 久久久久成人精品免费播放动漫| 久久男人av资源网站| 欧美激情中文不卡| 美女尤物久久精品| 久久米奇亚洲| 欧美三区不卡| 一区二区视频免费在线观看| 国产日韩在线不卡| 国产精品久久久久久影院8一贰佰| 国产精品一区二区三区久久久| 欧美日韩国产精品自在自线| 国产亚洲在线| 精品福利免费观看| 亚洲特级毛片| 亚洲欧美日韩国产成人| 亚洲最新视频在线| 亚洲精品国产品国语在线app| 亚洲欧美精品一区| 亚洲日本成人| 日韩亚洲不卡在线| 99国产精品国产精品久久| 亚洲精品视频免费观看| 亚洲高清电影| 久久av一区二区三区漫画| 亚洲摸下面视频| 欧美精品一区二区视频| 欧美高清视频一二三区| 欧美剧在线免费观看网站| 国内精品伊人久久久久av影院| 在线视频亚洲一区| 久久精品亚洲乱码伦伦中文| 久久一区二区三区四区| 免费观看亚洲视频大全| 国产综合自拍| 欧美成人精品在线播放| 亚洲国产黄色| 亚洲系列中文字幕| 麻豆精品一区二区综合av| 国产日韩一级二级三级| 亚洲欧美成人网| 亚洲美女中文字幕| 欧美精品在线视频| 99热免费精品在线观看| 亚洲精选中文字幕| 久久久亚洲国产天美传媒修理工 | 亚洲黄色毛片| 欧美岛国在线观看| 亚洲第一偷拍| 久久男女视频| 最新日韩中文字幕| 一本色道久久综合亚洲精品不卡| 欧美成人免费播放| 欧美1区2区| 欧美日韩午夜在线| 国产精品素人视频| 好吊日精品视频| 正在播放欧美一区| 亚洲久色影视| 国产精品久久一区主播| 午夜欧美大片免费观看| 亚洲福利在线视频| 欧美日韩高清在线观看| 亚洲综合激情| 亚洲片区在线| 欧美日韩在线一区二区| 亚洲欧美日韩在线高清直播| 欧美一区二区高清在线观看| 欧美国产视频在线观看| 一区二区日韩| 性做久久久久久久免费看| 狠狠综合久久av一区二区小说| 免费亚洲电影在线| 国产精品99一区| 久久综合久色欧美综合狠狠| 欧美91大片| 午夜一区在线| 亚洲毛片在线观看.| 国产精品视频一区二区三区| 久久亚洲私人国产精品va| 欧美不卡在线视频| 午夜精品短视频| 久久婷婷国产综合尤物精品| 一区二区不卡在线视频 午夜欧美不卡'| 亚洲性感美女99在线| 亚洲电影免费在线观看| 在线一区免费观看| 欧美激情视频一区二区三区在线播放| 亚洲一区二区三区在线看| 亚洲永久在线| 久久久噜噜噜久久中文字幕色伊伊| 日韩午夜中文字幕| 久久精品99无色码中文字幕| 国产区二精品视| 亚洲国产欧洲综合997久久| 久久亚洲精品一区| 亚洲欧美成aⅴ人在线观看| 女仆av观看一区| 久久久久国色av免费看影院| 欧美午夜不卡影院在线观看完整版免费| 久久综合婷婷| 国产一级久久| 午夜视频精品| 欧美亚洲视频| 国产精品xxxxx| 亚洲欧洲在线视频| 国产精品老牛| 亚洲另类一区二区| 亚洲日本欧美日韩高观看| 欧美在线啊v一区| 午夜精品视频网站| 欧美日精品一区视频| 91久久国产综合久久| 亚洲国产成人久久| 日韩午夜视频在线观看| 亚洲乱码国产乱码精品精可以看| 亚洲裸体视频| 99精品免费视频| 欧美国产激情| 亚洲欧洲日本一区二区三区| 最新国产乱人伦偷精品免费网站 | 亚洲欧洲日本专区| 久久嫩草精品久久久精品| 老司机精品久久| 在线国产欧美| 欧美成人国产一区二区 | 亚洲免费在线观看| 亚洲欧美中文日韩在线| 国产精品久久久久永久免费观看 | 久久精品国产一区二区三区免费看| 亚洲第一精品在线| 久久久久久电影| 老司机67194精品线观看| 怡红院精品视频| 一区二区三区精品久久久| 99国产精品99久久久久久粉嫩| 欧美成人在线免费视频| 日韩视频在线观看免费| 亚洲一区二三| 国产欧美日韩亚洲一区二区三区 | 亚洲精品乱码久久久久久蜜桃91| 日韩亚洲欧美综合| 欧美性久久久| 久久成人av少妇免费| 欧美激情四色| 亚洲一区图片| 伊人久久噜噜噜躁狠狠躁| 亚洲人www| 亚洲欧美视频| 在线播放视频一区| 欧美日韩国产在线一区| 午夜视频一区在线观看| 欧美福利一区| 午夜久久资源| 亚洲人成艺术| 国产精品天美传媒入口| 免费视频久久| 性视频1819p久久| 亚洲日本无吗高清不卡| 欧美一区二区女人| 欧美午夜精品久久久久久浪潮| 亚洲欧美日韩电影| 亚洲一区观看| 亚洲国产精品v| 国产欧美日韩亚洲| 欧美国产日韩一区二区在线观看| 亚洲图片在线观看| 美女黄毛**国产精品啪啪| 亚洲一区二区三区精品在线| 在线观看国产成人av片| 国产精品免费一区二区三区观看| 老色鬼久久亚洲一区二区| 免费黄网站欧美| 亚洲欧美不卡| 亚洲视频在线一区| 亚洲精品偷拍| 1024国产精品|