PKU( 2191 Mersenne Composite Numbers )

spoiler posted @ 2011年5月01日 19:15 in 数论 , 1616 阅读

 题目大意:

就是求梅森组合数!
这题网上都是打表算出来的,在这里我先贴一下 我的打表过的,这根本不算是我写的,因为这个表不是我自己计算出来的,我表示心里很无助~代码贴完,再次保证随后肯定 附上我详细的 解答过程,不用打表的,我去膜拜大牛的思路!
#include<stdio.h>
int main()
{
 int n,i;
 int b[10]={11,23,29,37,41,43,47,53,59};
char a1[10][100] ={"23 * 89 = 2047 = ( 2 ^ 11 ) - 1",
"47 * 178481 = 8388607 = ( 2 ^ 23 ) - 1",
"233 * 1103 * 2089 = 536870911 = ( 2 ^ 29 ) - 1",
"223 * 616318177 = 137438953471 = ( 2 ^ 37 ) - 1",
"13367 * 164511353 = 2199023255551 = ( 2 ^ 41 ) - 1",
"431 * 9719 * 2099863 = 8796093022207 = ( 2 ^ 43 ) - 1",
"2351 * 4513 * 13264529 = 140737488355327 = ( 2 ^ 47 ) - 1",
"6361 * 69431 * 20394401 = 9007199254740991 = ( 2 ^ 53 ) - 1",
"179951 * 3203431780337 = 576460752303423487 = ( 2 ^ 59 ) - 1"};
 scanf("%d",&n);
 for(i=0;i<9;i++)
 {
    if(n>b[i])
    printf("%s\n",a1[i]);
    else break;
  }
 return 0;
}

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter