锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲成年网站在线观看,色婷婷六月亚洲婷婷丁香,一本色道久久88亚洲综合http://m.tkk7.com/FinalFantasy/category/3676.html涓栫晫鐨勫皬涓栫晫錛屾垜鐨勫ぇ涓栫晫^_^zh-cnSat, 03 Mar 2007 09:06:44 GMTSat, 03 Mar 2007 09:06:44 GMT60Google緙栫▼鎸戞垬璧?50鍒嗛鐩強(qiáng)絳旀http://m.tkk7.com/FinalFantasy/archive/2005/12/14/23893.htmlFinalFantasyFinalFantasyWed, 14 Dec 2005 08:32:00 GMThttp://m.tkk7.com/FinalFantasy/archive/2005/12/14/23893.htmlhttp://m.tkk7.com/FinalFantasy/comments/23893.htmlhttp://m.tkk7.com/FinalFantasy/archive/2005/12/14/23893.html#Feedback5http://m.tkk7.com/FinalFantasy/comments/commentRss/23893.htmlhttp://m.tkk7.com/FinalFantasy/services/trackbacks/23893.html

Problem Statement

 

    

When a stone is thrown across water, sometimes it will land on the water and bounce rather than falling in right away. Suppose that a stone is thrown a distance of n. On each successive bounce it will travel half the distance as the previous bounce (rounded down to the nearest integer). When it can not travel any further, it falls into the water. If, at any point, the stone lands on an obstruction rather than water, it will not bounce, but will simply deflect and fall into the water. Please look at the figure for further clarification (with black, red and green cells representing banks, obstructions and free water respectively). So, if the stone is thrown a distance 7, it will bounce and travel a distance of 3, then finally a distance of 1, having travelled a total distance of 11 (the green path in the figure). If a stone is thrown a distance of 8, it will reach the opposite bank, and if thrown at distances of 2 or 6 it will hit an obstruction during its travel. These are the three red paths in the figure.



You are given a String water. An 'X' represents an obstruction, while a '.' represents water free from obstruction. You are to return an int representing the maximum distance a stone can travel and finally fall in the water, without hitting any obstructions, and without reaching the opposite bank (going beyond the end of the string). You may choose any initial distance for the throw, which starts from the left side of the string. A distance of 1 is the first character of the string, etc. If no initial throw will result in the stone landing in the water without hitting an obstruction, return 0.

Definition

    

Class:

SkipStones

Method:

maxDistance

Parameters:

String

Returns:

int

Method signature:

int maxDistance(String water)

(be sure your method is public)

    

 

 

 

Notes

-

Obstructions are at water level, so the stone will not hit any obstructions while it's in the air.

Constraints

-

water will contain between 1 and 50 elements, inclusive.

-

Each element of water will contain between 1 and 50 characters, inclusive.

-

Each character of each element of water will be 'X' or '.'.

Examples

0)

 

    

"..X.....X..."

Returns: 11

This is the example from the problem statement.

1)

 

    

"...X..."

Returns: 3

If it weren't for the obstruction, we could start with a throw of distance 4, and go a total of 7. But, the best we can do is to throw the stone a distance of 2, and have it skip a distance of 1.

2)

 

    

"....X....X...XXXX.X....."

Returns: 22

12 + 6 + 3 + 1 = 22, is the best case.

3)

 

    

"XXXXXXX.XXX.X.."

Returns: 15

Here, an initial throw of 8 is the only way to avoid hitting an obstruction. Notice that the stone finally falls in the water just before reaching the opposite bank.

 

 


榪欐鐨勯鐩彲浠ヨ騫朵笉鏄お闅撅紝涔熻寰堝浜鴻鍏ㄨ嫳鏂囩殑棰樼洰緇欓毦浣忎簡(jiǎn)錛屽叾瀹炲茍涓嶅簲璇ャ傚儚鎴戣繖涓繕娌¤繃CET4鐨勪漢閮借兘鐪嬪緱鎳傦紝浣曞喌鏄ぇ瀹跺憿錛氾級(jí)濂戒簡(jiǎn)錛屽簾璇濅笉澶氳浜?jiǎn)锛屼笅闈㈡槸鎴戝啓鐨劷{旀錛?BR>
public class SkipStones
{
 public int sum;
 public int total;
 public int maxDistance(String water)
 {
  for(int i=water.length();i>0;i--)
  {
   total=0;
   sum=0;
   int j=i;
   do
   {
    sum+=j;
    j/=2;
    }while(j!=0);
   if(sum>water.length()) continue;
   else
   {
    j=i;
    int b=j-1;
    while(j!=0)
    {
     if(water.charAt(b)=='X') break;
     else
     {
      total+=j;
      j/=2;
      b+=j;
      }
     }
    }
    if(total==sum) break;
   }
   if(total==sum) return sum;
   else return 0;
  }
  
  
 public static void main(String[] args)
 {
  SkipStones a=new SkipStones();
  System.out.println("The maxdistance is "+a.maxDistance("..X.....X..."));
  }
 }

FinalFantasy 2005-12-14 16:32 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 日韩免费一区二区三区| 含羞草国产亚洲精品岁国产精品| 亚洲精品人成网线在线播放va| 久久午夜伦鲁片免费无码| 亚洲一区二区三区无码中文字幕 | 亚洲性色高清完整版在线观看| 两个人看的www免费视频中文| 亚洲精品国产V片在线观看| 麻豆91免费视频| 亚洲AV无码一区二区三区在线观看 | 日韩色日韩视频亚洲网站| 日日噜噜噜噜夜夜爽亚洲精品| 国产黄色片免费看| 亚洲精品一品区二品区三品区| www在线观看免费视频| 国产成人精品日本亚洲专区| 久久电影网午夜鲁丝片免费| 亚洲国产亚洲片在线观看播放| 国产精品怡红院永久免费| 亚洲日韩乱码中文无码蜜桃臀| 好吊妞在线新免费视频| 亚洲私人无码综合久久网| 国产美女无遮挡免费网站| 成在线人直播免费视频| 国产亚洲精品美女久久久| 看全色黄大色大片免费久久| 色噜噜狠狠色综合免费视频| 亚洲国产精品VA在线看黑人 | 四虎国产精品免费久久| 国产亚洲综合久久| 亚洲午夜福利在线观看| 好吊妞视频免费视频| 久久w5ww成w人免费| 亚洲字幕AV一区二区三区四区| 国产亚洲人成无码网在线观看| 国产裸模视频免费区无码| 国产91免费在线观看| 亚洲视频在线观看免费| 亚洲色少妇熟女11p| 久久精品国产精品亚洲毛片| 午夜视频免费观看|