2007-07-01ãã1ã¶æéã®è¨äºä¸è¦§
sequential access listã«ã©ã³ãã ã¢ã¯ã»ã¹ã¯ã§ããªãã®ã§ã ããã®é度ã調ã¹ãã const int m = 1000; // ã³ã³ããã®å¤§ãã const int n = (int)(1e10 / m); // ç¹°ãè¿ãåæ°void procVector() { vector v; for(int k = 0; k v.push_back(k); int sum = 0;â¦
ä»äºã§listã使ã£ã¦ããã¨ããããã£ã¦ã ãããªã¨ããã§ãªã«ãããããlistã使ããªãã¦ãã¨æã£ã¦ãããã æè¿å ¨é¨vectorã«ããããæ³å以ä¸ã«éããªã£ãã listã¯ã©ãããã¨ãã«ä½¿ãããèãã¦ã¿ãã 以ä¸ã®ãã³ããã¼ã¯ã¯ã VC2003ï¼Windows XPã§è¡ã£ã¦â¦
ä¾ãã°ãå®æ°ã§1åãã»ããã¨ããµã¤ãã¯ããæ¸ãã ãããã const int n = 100000000;ããããããã¨è¦ã§1åã¨ãããã ãããã ããããã¨ãã¯ãã³ã¡ã³ããæ¸ãã¨ããã«ãããã const int n = 100000000; // 1åããããä¾ãã°ä¸æ¡å¤ãã¦ã ã§ãããã«æ»ãâ¦
æå¾ å¤E(n)ãããä¸åº¦ä»£æ°çã«æ¤è¨ãã¦ã¿ããã (P(n, 1) + ... + P(n, n-1))E(n) = 1 + P(n, 1)E(n) + ... + P(n, n-1)E(n-1) ã®å·¦è¾ºã¯ã (2n - 2)/3nE(n) æ´çãã¦ã ããã§ã ã¨ããæ¯é¢æ°ãèããã¨ã ã¨ãªãã ããã解ãã®ã¯é£ãããã ãã ã¨ããããâ¦
å¹³åã¨åæ£ãæ±ããã®ã§ã ä»åº¦ã¯æ£ç¢ºãªåå¸ãæ±ãããã n人ã§måããã確çãp(n,m)ã¨ããã¨ã 1åã§1人ã«ãªãå ´åã2人ã«ãªãå ´åãâ¦ãããåããã¦ã p(n,m) = P(n,1)p(1,m-1) + ... + P(n,n)p(n,m-1) (m > 1) p(n,1) = P(n,1) ããã§ãP(k,l)ã¯k人ãã1â¦
åæ£ãåãããã«æ±ãããã¨ãèãããã äºè±¡iãpiã§èµ·ããã¨ãã¦ã ãã®äºè±¡ãèµ·ãã£ãã¨ãã®å¹³åã¨åæ£ãã mi, Ïi2ã ã¨ããã¨ãã«ã å ¨ä½ã§ã®å¹³åã¨åæ£ãèããã ni : äºè±¡iã®å ¨ä½ã®åæ° ã¨ããã¨ãå ¨ä½ã§ã¯ã ã ãããå¹³åã¯ã åæ£ãåæ§ã«èããã â¦
ååã®ã (P(n, 1) + ... + P(n, n-1))E(n) = 1 + P(n, 1)E(n) + ... + P(n, n-1)E(n-1) ã«ãããã£ã¦ããã°ã©ã ãæ¸ãã¨ã E(2) = 1.5 E(3) = 2.2500000000000004 E(4) = 3.214285714285715 E(5) = 4.485714285714287 E(6) = 6.219815668202768 E(7) = 8.64â¦
代æ°çã«æå¾ å¤ãæ±ãããã n人ã§ã¸ã£ã³ã±ã³ãã¦æ±ºçãã¤ãã¾ã§ã®åæ°ã®æå¾ å¤ãE(n)ã¨ããã 2人ã®å ´åã ã©ã¡ãããåã¤ç¢ºçã2/3ããããã®ç¢ºçã1/3ã ããã 1åã§æ±ºçãã¤ã確çã¯2/3ã 2åã§æ±ºçãã¤ã確çã¯1/3 * 2/3 = 2/9ã 3åã§æ±ºçãã¤ã確çã¯â¦
ã¸ã£ã³ã±ã³ã2ã10人ã§1ä¸åãè¡ãã 決çãã¤ãã¾ã§ã«ããã£ãåæ°ã®å¹³åã¨æ¨æºåå·®ã¯æ¬¡ã®ããã«ãªã£ãã9人ãè¶ ãããããããæ¥æ¿ã«å¢ããããã ã 以ä¸ãã½ã¼ã¹ã
ä¾ãã°ã10人ã§ã¸ã£ã³ã±ã³ããããä½åã§1人ãæ®ãã ãããã ã¾ããã¸ã£ã³ã±ã³ãã·ãã¥ã¬ã¼ããã¦ã¿ããã ã°ã¼ã1ããã§ãã2ããã¼ã4ã¨ããã ããªãã¡ããããç«ã¦ãã ä¹±æ°ã使ãJavaScriptã§ãããªå ·åã«å®è£ ããã // 2.8s for(var i = 0; i var a; â¦