Brian Warehouse

Some birds aren`t meant to be caged, their feathers are just too bright... ...
posts - 40, comments - 16, trackbacks - 0, articles - 1

这不是解题报告,只是偶然看到的,以此与君共勉!

#include<stdio.h>
unsigned short a[10002]={0,0,1,1,0,2,0,1,1,0,1,1,1,1,0,1,0,2,1,1,0,0,0,2,1,0,1,0,1,1,1,2,0,0,0,0,2,1,0,1,0,3,1,1,0,0,0,1,1,1,0,0,1,2,0,0,1,0,1,2,2,1,0,0,0,0,0,2,1,0,0,2,2,1,0,1,0,1,1,1,0,0,0,3,1,0,0,0,1,1,2,0,0,0,0,1,0,2,1,0,
2,2,1,1,0,0,0,1,0,2,0,0,2,1,0,0,0,0,0,2,2,1,0,0,1,0,0,2,1,1,0,2,1,0,0,0,0,1,2,2,0,0,0,2,1,0,0,0,0,1,1,1,2,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,1,2,0,0,0,0,0,1,2,2,0,0,1,0,1,2,0,0,0,1,1,1,0,1,0,3,1,3,
0,0,1,0,2,0,0,0,0,0,2,2,0,0,0,0,1,0,0,0,1,2,1,3,0,0,0,1,2,1,0,0,0,2,0,1,1,0,1,1,3,1,0,1,0,0,0,0,0,0,0,3,1,1,0,0,0,1,2,0,0,0,0,2,1,0,0,0,1,2,1,2,1,0,0,0,2,1,0,1,1,3,0,1,0,0,0,3,1,0,1,0,0,1,0,0,0,0,0,0,
2,1,0,0,2,0,1,1,1,0,0,5,0,1,0,0,0,1,1,1,1,0,0,2,1,0,1,0,1,1,2,2,0,0,0,0,0,1,0,0,3,1,0,0,0,0,0,1,1,2,0,1,1,2,0,0,0,0,1,1,1,0,0,1,1,0,0,1,0,0,1,3,2,2,0,0,1,0,0,2,0,1,1,1,2,0,0,0,0,1,2,0,0,0,0,2,1,1,0,1,
0,3,0,0,0,0,0,1,2,1,2,0,1,0,0,0,0,0,0,1,1,2,0,1,1,1,0,0,0,0,1,2,1,1,2,1,0,0,1,3,1,0,1,2,0,0,0,0,0,2,1,0,0,0,0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,1,0,1,0,2,2,2,0,1,0,0,0,0,0,0,0,0,0,1,1,0,2,2,1,1,1,0,0,0,1,0,0,2,0,2,1,2,0,0,2,0,0,1,0,1,1,0,1,0,0,0,0,2,1,1,0,0,0,0,0,0,0,0,1,1,2,0,1,0,2,1,1,2,0,1,
2,1,0,0,0,1,0,1,0,0,0,0,0,1,0,2,1,0,1,1,0,1,0,0,0,1,3,0,0,0,0,0,1,2,0,0,1,1,1,1,0,0,0,1,1,0,0,1,3,1,1,1,0,0,1,1,0,1,0,0,1,1,0,0,0,1,2,1,2,2,0,0,0,2,1,0,0,1,0,1,0,1,0,0,1,2,0,2,0,0,0,1,1,0,0,0,1,1,0,0,
2,0,0,1,1,1,0,0,1,2,1,1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,3,1,1,3,1,0,1,1,0,1,0,1,1,3,0,1,0,0,1,1,1,0,0,1,2,1,2,1,1,0,0,1,2,2,0,0,0,1,1,2,1,0,1,1,1,2,1,0,0,0,1,0,0,1,2,0,0,2,0,0,0,2,0,1,0,0,0,0,1,0,0,0,0,1,
0,2,0,0,0,1,0,3,1,0,1,0,2,0,1,2,0,0,0,0,2,1,1,1,2,0,0,0,0,2,0,1,0,0,0,1,1,1,0,1,0,1,1,0,0,0,0,0,3,2,0,0,0,1,0,2,0,1,1,1,1,0,0,0,1,0,0,1,2,0,2,2,0,1,1,0,1,0,1,1,1,0,0,2,1,0,1,0,1,0,0,0,1,0,1,0,0,0,0,1,
0};
       
int main()
{   
    int n;
    while(scanf("%d",&n),n)
    {
        printf("%d\n",a[n]);   
    }     
}

posted @ 2010-08-17 13:55 Brian 阅读(340) | 评论 (0)编辑 收藏

北大: http://acm.pku.edu.cn/JudgeOnline/
    浙大: http://acm.zju.edu.cn/
    同济: http://acm.tongji.edu.cn/
    吉林大学: http://acm.jlu.edu.cn/joj/
    杭州电子科技: http://acm.hdu.edu.cn/
    天津大学: http://acm.tju.edu.cn/toj/
    哈工大: http://acm.hit.edu.cn/
    武汉大学: http://acm.whu.edu.cn/
    哈尔滨工程: http://acm.hrbeu.edu.cn/
    福建师范: http://acm.fjnu.edu.cn/
    中科大: http://acm.ustc.edu.cn
    厦门大学: http://acm.xmu.edu.cn/JudgeOnline/
    合肥工大: http://acm.tdzl.net/JudgeOnline/
    北大内部: http://ai.pku.cn/JudgeOnline
    华中科技: http://acm.hust.edu.cn/JudgeOnline
    宁波理工: http://acm.nit.net.cn
   浙江工业: http://acm.zjut.edu.cn
    南开大学: http://nkacm.cn
    VIJOS: http://www.vijos.cn
    MyOJ: http://tzoi.dynserv.com
    Ural State University: http://acm.timus.ru
    Saratov State University : http://acm.sgu.ru
    美国官方USACO: http://ace.delos.com/usacogate/
    安徽师范大学 : 不好意思, 过于强大, 仅供内部使用 

   这是本人个人整理的,如想复制,请随便。

posted @ 2010-08-17 13:51 Brian 阅读(481) | 评论 (0)编辑 收藏

求n的平方根,先假设一猜测值DE>X0 = 1DE>,然后根据以下公式求出DE>X1DE>,再将DE>X1DE>代入公式右边,继续求出DE>X2DE>…通过有效次迭代后即可求出n的平方根,DE>Xk+1DE>

x_(k+1)=1/2(x_k+n/(x_k))

先让我们来验证下这个巧妙的方法准确性,来算下2的平方根 (Computed by Mathomatic)

1-> x_new = ( x_old + y/x_old )/2
y
(x_old + -----)
x_old
#1: x_new = ---------------
2
1-> calculate x_old 1
Enter y: 2
Enter initial x_old: 1
 x_new = 1.5
1-> calculate x_old 2
Enter y: 2
Enter initial x_old: 1
 x_new = 1.4166666666667
1-> calculate x_old 3
Enter y: 2
Enter initial x_old: 1
 x_new = 1.4142156862745
1-> calculate x_old 10
Enter y: 2
Enter initial x_old: 1
Convergence reached after 6 iterations.
 x_new = 1.4142135623731
...

可见,随着迭代次数的增加,运算值会愈发接近真实值。很神奇的算法,可是怎么来的呢? 查了下wikipediawolfram,原来算法的名字叫Newton’s Iteration (牛顿迭代法)。

下面是数理介绍,不喜欢数学的言下之意也就是绝大部分人可以略过了。

简单推导

假设DE>f(x)DE>是关于DE>XDE>的函数:

An illustration of on<wbr>e iteration of Newton's method

求出DE>f(x)DE>的一阶导,即斜率:

f'(x_{n}) = frac{ mathrm{rise} }{ mathrm{run} } = frac{ mathrm{Delta y} }{ mathrm{Delta x} } = frac{ f( x_{n} ) - 0 }{ x_{n} - x_{n+1} } = frac{0 - f(x_{n})}{(x_{n+1} - x_{n})},!

简化等式得到:

x_(n+1)=x_n-(f(x_n))/(f^'(x_n))

然后利用得到的最终式进行迭代运算直至求到一个比较精确的满意值,为什么可以用迭代法呢?理由是中值定理(Intermediate Value Theorem):

如果DE>fDE>函数在闭区间DE>[a,b]DE>内连续,必存在一点DE>xDE>使得DE>f(x) = cDE>,DE>cDE>是函数DE>fDE>在闭区间DE>[a,b]DE>内的一点

我们先猜测一DE>XDE>初始值,例如1,当然地球人都知道除了1本身之外任何数的平方根都不会是1。然后代入初始值,通过迭代运算不断推进,逐步靠近精确值,直到得到我们主观认为比较满意的值为止。例如要求768的平方根,因为DE>252 = 625DE>,而DE>302 = 900DE>,我们可先代入一猜测值26,然后迭代运算,得到较精确值:27.7128。

回到我们最开始的那个”莫名其妙”的公式,我们要求的是DE>NDE>的平方根,令DE>x2 = nDE>,假设一关于DE>XDE>的函数DE>f(x)DE>为:

DE>f(X) = X2 - nDE>

DE>f(X)DE>的一阶导为:

DE>f'(X) = 2XDE>

代入前面求到的最终式中:

DE>Xk+1 = Xk - (Xk2 - n)/2XkDE>

化简即得到我们最初提到的那个求平方根的神奇公式了:

x_(k+1)=1/2(x_k+n/(x_k))

用泰勒公式推导

我之前介绍过在The Art and Science of C一书中有用到泰勒公式求平方根的算法,其实牛顿迭代法也可以看作是泰勒公式(Taylor Series)的简化,先回顾下泰勒公式:

f(x_0+epsilon)=f(x_0)+f^'(x_0)epsilon+1/2f^('')(x_0)epsilon^2+....

仅保留等式右边前两项:

f(x_0+epsilon) approx f(x_0)+f^'(x_0)epsilon.

DE>f(X0+ε) = 0DE>,得到:

epsilon_0=-(f(x_0))/(f^'(x_0))

再令DE>X1 = X0 + ε0DE>,得到DE>ε1DE>…依此类推可知:

epsilon_n=-(f(x_n))/(f^'(x_n))

转化为:

x_(n+1)=x_n-(f(x_n))/(f^'(x_n))

posted @ 2010-08-17 13:49 Brian 阅读(709) | 评论 (0)编辑 收藏

好几个人问我校内OJ的回文数那道题,我去年没做,现在看了,怪不错的一道题:

Description

若一个数(首位不为零)从左向右读与从右向左读都一样,我们就将其称之为回文数。例如121就是一个回文数。
对于任意一个数,可以进行如下变换,可以得到一个回文数。
例如:
给定一个10进制数56,将56加65(即把56从右向左读),得到121是一个回文数。
又如:
对于10进制数87:
STEP1:87+78 = 165
STEP2:165+561 = 726
STEP3:726+627 = 1353
STEP4:1353+3531 = 4884
在这里的一步是指进行了一次N进制的加法,上例最少用了4步得到回文数4884。

写一个程序,给定一个N(2<=N<=10,N=16)进制数M,求最少经过几步可以得到回文数。如果在30步以内(包含30步)不可能得到回文数,则输出“Impossible!”

Input

第一行为N
第二行为M

Output

STEP=步数

Impossible!

Sample Input

9
87

 

 

Sample Output

STEP=6
#include<stdio.h>
#include
<string.h>
char M[20];
int N,len;// 进制、字符串长度
int a[20]={0},b[20]={0};

void Format(char a[],int b[])
{
    
int i=0;
    
for (; i<len; i++)
        
if(N>10 && a[i]>='A')
            b[i]
=a[i]-'A'+10;
        
else b[i]=a[i]-'0';


void Step()
{
    
int i=0;
    a[len]
=0;
    
for (; i<len; i++)
        b[i]
=a[len-i-1];
    
for (i=0; i<len; i++//核心代码
    {
        a[i]
+=b[i];
        
if (a[i]>N-1)
        {
            a[i
+1]+=a[i]/N;
            a[i]
=a[i]%N;
        }
    }
    
if(a[len]) len++;       
}

int IsPalindrome() //判断是否是回文数
{
    
int i=0;
    
for (; i<=len/2; i++)
        
if (a[i]!=a[len-1-i])
            
return 0;
    
return 1;


int main()
{
    
int STEPS=0;
    scanf(
"%d",&N);
    scanf(
"%s",M);
    
    len
=strlen(M);
    Format(M,a); 
//将字符转化为对应进制数字
    while(1)
    {
        
if(STEPS>30)
        {
            printf(
"Impossible!\n");
            
return 0;
        }
        
if(STEPS && IsPalindrome())
            
break;
        Step();
        STEPS
++;
    }
    
    printf(
"STEP=%d\n",STEPS);
    
return 0;
}
我的是任意进制都可以的, 192MS 0K

posted @ 2010-08-17 13:48 Brian 阅读(858) | 评论 (0)编辑 收藏

约瑟夫环实在是太奇妙啦(我很高兴我的这篇原创文章被不少人转载了,虽然他们都没有引用出处... ...)!
1012 Joseph
Description

The Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, . . ., n, standing in circle every mth is going to be executed and only the life of the last remaining person will be saved. Joseph was smart enough to choose the position of the last remaining person, thus saving his life to give us the message about the incident. For example when n = 6 and m = 5 then the people will be executed in the order 5, 4, 6, 2, 3 and 1 will be saved.

Suppose that there are k good guys and k bad guys. In the circle the first k are good guys and the last k bad guys. You have to determine such minimal m that all the bad guys will be executed before the first good guy.

Input

The input file consists of separate lines containing k. The last line in the input file contains 0. You can suppose that 0 < k < 14.

Output

The output file will consist of separate lines containing m corresponding to k in the input file.
2244 Eeny Meeny Moo

Description

Surely you have made the experience that when too many people use the Internet simultaneously, the net becomes very, very slow.
To put an end to this problem, the University of Ulm has developed a contingency scheme for times of peak load to cut off net access for some cities of the country in a systematic, totally fair manner. Germany's cities were enumerated randomly from 1 to n. Freiburg was number 1, Ulm was number 2, Karlsruhe was number 3, and so on in a purely random order.
Then a number m would be picked at random, and Internet access would first be cut off in city 1 (clearly the fairest starting point) and then in every mth city after that, wrapping around to 1 after n, and ignoring cities already cut off. For example, if n=17 and m=5, net access would be cut off to the cities in the order [1,6,11,16,5,12,2,9,17,10,4,15,14,3,8,13,7]. The problem is that it is clearly fairest to cut off Ulm last (after all, this is where the best programmers come from), so for a given n, the random number m needs to be carefully chosen so that city 2 is the last city selected.

Your job is to write a program that will read in a number of cities n and then determine the smallest integer m that will ensure that Ulm can surf the net while the rest of the country is cut off.

Input

The input will contain one or more lines, each line containing one integer n with 3 <= n < 150, representing the number of cities in the country.
Input is terminated by a value of zero (0) for n.

Output

For each line of the input, print one line containing the integer m fulfilling the requirement specified above.
 
1012打表做法 C :
#include<stdio.h>
int a[14]={2,7,5,30,169,441,1872,7632,1740,93313,459901,1358657,2504881,13482720};
int main()
{
 int i;
 while ( scanf("%d",&i), i != 0 )
  printf("%d\n",a[i-1]);
 return 0;
} // 这是从网上找的做法,号称打表法,这些数据依旧要通过建立循环链表或是别的模拟法来求出。但是单纯为了AC,这种做法真的是相当有效,讲白了就是有目的的穷举结果。
1012模拟法 C: 可惜呀可惜!这个总是 超时!我不知道是什么原因。但是思路是正确的,可能有些地方我没有考虑到,看到这篇日志的人请指点。
#include<stdio.h>
int main()
{
 int i,m,k,cur,rest;
 
 while(1)
 {
  i=0; // the use ... sort of m in the question
  m=0;
  scanf("%d",&k);
  if (k == 0) break;
  while (1)
  {
   i++;
   rest=2*k; // good + bad guys
   cur=0;
   while (1)
   {
    cur=(cur+i-1)%rest; // find next from ZERO!
    if (cur >= k)
     rest--;
    else break;
   }
   if (rest == k)
   {
    m=i;
    break;
   }
  }
  printf("%d\n",m);
 }
 return 0;
}
对于 2244,建议看一个牛人的ACM博客: www.cppblog.com/AClayton/archive/2007/11/06/35964.html
我就是看这篇博文的,很牛的一个人 AClayton ,写的日期刚好是我生日,下面是其全部博文:
--------------------------------------------------------------------------------------------------------------------------------------------

 在没有明白约瑟夫问题之前,只能用模拟来做.
      约瑟夫问题是这样的:
      假设n个人,编号为1到n,排成一个圈,顺时针从1开始数字m,数到m的人杀了,剩下的人继续游戏.活到最后的一个人是胜利者.一般来说需要编程求解最后一个人的编号.
      思路是这样的:
     假设当前剩下i个人(i<=n),显然这一轮m要挂(因为总是从1开始数).经过这一轮,剩下的人是:1 2 3 ... m- 1 m + 1 ... i, 我们将从m+1开始的数映射成1, 则m+2对应2, n对应i - m, 1对应成i - m + 1  m - 1对应i - 1,那么现在的问题变成了已知i - 1个人进行循环报数m,求出去的人的序号。假设已经求出了i- 1个人循环报数下最后一个出去的人的序号X0,那么它在n个人中的序号X1=(X0+ m - 1) % n + 1,  最初的X0=1 ,反复迭代X0和X1可以求出.
     简单约瑟夫问题的解法:
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse#include <stdio.h >
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehousemain()
POJ 1012 2244 Joseph 问题详解 - Icho - Brian WarehousePOJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse{
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
int n, m,i, s=0
;
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    printf( 
"N  M  =  "); scanf("%d%d ",&n,&
m);
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
for(i=2;i<=n;i++)s=(s+m)%
i;
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    printf(
"The winner is %d\n ", s+1
);
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse}
  

      这倒题其实不是完全的约瑟夫问题,而是稍微变了形.呵呵,聪明的读者自己发现!这一点费了我很久的时间,还害我逃了课被点名...
    这道题的我解法是这样的.

POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse#include   <stdio.h >
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse
int y(int n,int m)
POJ 1012 2244 Joseph 问题详解 - Icho - Brian WarehousePOJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse
{
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
int s=1
,i;
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
for(i=2;i<=n-1;i++
)
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse        s
=(s+m-1)%i+1
;
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
return s+1
;
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse}

POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehousemain()
POJ 1012 2244 Joseph 问题详解 - Icho - Brian WarehousePOJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse{
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
int
 m,n;
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
while(1
)
POJ 1012 2244 Joseph 问题详解 - Icho - Brian WarehousePOJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse
{
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    scanf(
"%d",&
n);
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
if(n==0)break
;
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse     
for(m=1
;;)
POJ 1012 2244 Joseph 问题详解 - Icho - Brian WarehousePOJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse     
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse
{
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse         
if(y(n,m)==2)break
;
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse         m
++
;
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse     }

POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse   
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    printf(
"%d\n",m);
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    
POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse    }

POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse}

POJ 1012 2244 Joseph 问题详解 - Icho - Brian Warehouse

       读一个数处理一个数, Memory 68K,时间31MS,如果觉得效率不高. 优化的办法是打表~

-----------------------------------------------------------------------------------------------------------------------------
由此可见,将问题化归为数学问题,用初等高等或是数论来解决的能力是多么重要。
下面是我根据AClayton的思路简化后的代码,可直接AC: 注意,题目让你先让City 1 挂掉
2244  编译器 C :
#include<stdio.h>
void main()
{
 
int i,r,m,n;
 
while (scanf("%d",&n) && n)
 {
    
for (m=1; ; m++)
    {
     
for (r=1,i=2; i<=n-1; i++)
      r
=(r+m-1)%+ 1;
     
if(r==1break;
    }
    printf(
"%d\n",m);
 }
// 164K  16MS
 

posted @ 2010-08-17 13:42 Brian 阅读(2036) | 评论 (3)编辑 收藏

DS理论也被认为是信度函数理论,是主观概率(subjective probability)的贝叶斯理论的扩展。信度函数允许我们基于信度使用一个问题的概率来推导一个相关问题的概率。这些信度值可能有也可能没有概率的数学性质;他们与概率的差异大小将取决于这两个问题有多相关。

       History..

       DS理论基于两个思想:1. the idea of obtaining degrees of belief for one question from subjective probabilities for a related question 获取一个问题对于另一个问题的信度值。2. Dempster's rule for combining such degrees of belief when they are based on independent items of evidence 当这些信度值都基于独立的证据时,把他们结合起来的D规则。

       为了描述第一个思想,考虑我知道我的朋友Betty是否可靠的主观概率。我认为她可靠的概率是0.9,不可靠的概率是0.1。假设她告诉我一个树枝掉在了我的车上。当她可靠的时候,这个论断一定是真的,当她不可靠的时候这个论断却不一定是假的。所以当仅有她的证词的时候justifies0.9的信度有一个树枝掉在了我的车上了,但仅仅有0的信度值保证没有树枝掉在我的车上。这个零并不意味着我可以肯定没有树枝掉在我的车上,而概率零可以保证;它仅仅表示了Betty的证词没有给我任何理由相信没有树枝掉在我的车上。这个0.9和0在一起构成了一个信度函数(belief function)。

       假设,从另外一个方面,Betty和Sally互相矛盾——Betty说一个树枝掉在了我的车上,Sally说没有树枝掉在了我的车上。在这种情况下,他们不能都对,因为不可能两个人都是可靠的——只有可能有一个人是可靠的或者都不可靠。三种情况,只有Betty可靠,只有Sally可靠,或都不可靠,概率分别为0.09,0.09,0.01,给定不是都可靠的情况下,后验概率是9/19,9/19,1/19。( 0.09/(0.09+0.09+0.01) )所以我们有9/19的信度对于有一个树枝掉在了我的车上(Betty可靠)以及9/19的信度对于没有树枝掉在了我的车上(Sally可靠)。

       总的来说,我们要从另一个问题(证人是否可靠)的概率获取一个问题的信度(是否有树枝掉在了我的车上?)。Dempster规则首先有一个假设我们知道概率的问题都是独立的对于我们主观的概率判断,但这个独立性仅仅是一个priori;当在证据的不同部分发现冲突的时候就不在需要了(?)。

       在一个具体问题中实现DS理论大致包括两个相关的问题。首先,我们必须把问题的不确定性分成证据的先验独立的部分。然后我们再运行Dempster规则。这两个问题和他们的解决方法都是非常相关的。把不确定性s分成独立的部分产生包含了证据(其中有不同但相关的问题)不同部分的结构,使用这个结构可以让计算可行。例如,假设Betty和Sally相互独立的作证他们听到了有贼到我的房间。他们可能都会把一只狗的噪声误以为成是一个贼,由于这种公共的不确定性,我不能直接使用D规则来把他们的信度结合起来。但是如果我知道到狗存在的可能性,然后我能确定证据的三个独立部分:我另一个支持或反对狗存在的证据,我对Betty可靠的证据,以及我对Sally可靠的证据。我能通过D规则把证据的三个部分结合起来,在包含了这些不同问题的结构被考虑的时候,计算就可以施行了。

posted @ 2010-08-17 13:38 Brian 阅读(348) | 评论 (0)编辑 收藏

这是个初学JAVA必要头疼的问题。集合我找来的资料和亲身实践,我的这种方法应该是万无一失的了。我用的是JDK 1.7.0。

第一步 右击我的电脑,点击属性

第二步:选择高级选项卡,点击环境变量

第三步:在下方的系统变量中,设置3项属性,JAVA_HOME, PATH, CLASSPATH(大小写无所谓),若已存在则点击编辑,不存在则点击新建  

第四步JAVA_HOME设为JDK的安装路径(D:\program files\Java\jdk1.7.0),此路径下包括libbinjre等文件夹(此变量最好设置,因为以后运行tomcateclipse等都需要依靠此变量);

Path使得系统可以在任何路径下识别java命令,设为:

%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin (可直接复制过去,如果添加在末尾,需在最前面加个 ; )

CLASSPATHjava加载类(class or lib)路径,只有类在classpath中,java命令才能识别,设为:

.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar  (注意最前面有个 .  表示当前路径,可直接复制)

%JAVA_HOME%就是引用前面指定的JAVA_HOME

 第五步开始”->“运行键入“cmd ”后打开了命令提示符窗口:

 编写一个简单的java实例来测试一下

记事本中输入以下代码:

public class Hello
{
 public static void main(String[ ] args)
  {
    System.out.println("Hello World");
  }
}

 

把文件另存为D:\,再重命名为“Hello.java” 在命令提示符下

输入cd D:\回车;

再输入“D:\ ”  回车;

再输入“javac Hello.java”回车;

如果命令提示窗口没有任何反映那么表示编译成功,javac会在D盘下生成一个Hello.class的文件,叫类文件

然后执行这个类文件 在命令提示符下

输入“java Hello” 回车;

出现 “Hello World” ,就说明全部都成功了。

posted @ 2010-08-17 13:28 Brian 阅读(680) | 评论 (0)编辑 收藏

For given number N you must output amount of N-digit numbers, such, that last digits of their square is equal to 987654321.

Input

Input contains integer number N (1<=N<=106)
首先想到的是枚举,我确实也这么做了,5~8无果,对于9,我的05年方正 Pentium M  上跑了足足1分半钟之久,我一开始还以为死循环了,后来出来八个结果,也去网上核对了一下,确实满足的只有这八个:
   111111111
   119357639
   380642361
   388888889
   611111111
   619357639
   880642361
   888888889
我没有学过数论,找到一篇博文,对于数论解法讲的还算清楚,不过用pascal写就,我自己用C写了一下,第三次AC了。博文链接如下:http://blog.csdn.net/Skyprophet/archive/2009/10/05/4634801.aspx

#include <stdio.h>
int main()
{
    
int N,i=0;
    scanf(
"%d",&N);
    
if (N<=8)
        printf(
"0\n");
    
else if (N==9)
        printf(
"8\n");
    
else
    {
        printf(
"72");
        
for (; i<N-10; i++)
            printf(
"0");
        printf(
"\n");
    }
    
return 0;
}
336MS  0K

posted @ 2010-08-17 13:27 Brian 阅读(303) | 评论 (0)编辑 收藏

There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine amount of numbers in it that are divisible by 3. (找出这个数列1-N号元素中能被3整除的有多少个)

Input

Input contains N (1<=N<=231 - 1).

一个数乘以10以后,模3后结果不变,第2,5,8,11,14,17........项满足要求

#include <stdio.h>
int main()
{
    
int N;
    scanf(
"%d",&N);
    N
--;
    printf(
"%d\n", N-(N/3));
    
return 0;
}  
// 0K  0MS

posted @ 2010-08-17 13:26 Brian 阅读(269) | 评论 (0)编辑 收藏

题目简单翻译:对于给出的整数 N (1<=N<=104) ,找出所有不大于N且与N互质的正整数个数
两个正整数A和B互质的意思是它们的最大公约数是1。现看一下百度百科上关于质数的定义吧。
当我采用直接数的办法AC后,我发现跟质数完全没有关系。
#include<stdio.h>

int gcd(int m,int n) // greatest common divisor
{
    
int r=m%n;
    
while(r)         // 辗转相除法,TAOCP的第一个算法
    {
        m
=n;
        n
=r;
        r
=m%n;
    }
    
return n;
}

int main()
{
    
int N,c=0,i=1// must start with 1 !
    scanf("%d",&N);
    
for (; i<=N; i++)
        
if (gcd(N,i)==1// question hint
            c++;
    printf(
"%d",c);
    
return 0;
}
//  102  .C Accepted 0 ms 0 kb 

posted @ 2010-08-17 13:24 Brian 阅读(191) | 评论 (0)编辑 收藏

仅列出标题
共4页: 1 2 3 4