zoukankan      html  css  js  c++  java
  • (数学+打表)POJ 2192

    原题链接:http://poj.org/problem?id=2191


    题意:定义2^p-1(p为素数)的合数为梅森合数。

    求求p<=k的梅森合数


    分析:实力打一波表


    代码:

     1 #include<iostream>  
     2 #include<cstring>  
     3 #include<cstdio>  
     4 using namespace std;  
     5 int main()  
     6 {  
     7     int s[10]={ 11, 23, 29, 37, 41, 43, 47, 53, 59 };  
     8     char st[10][100] ={ "23 * 89 = 2047 = ( 2 ^ 11 ) - 1",  
     9             "47 * 178481 = 8388607 = ( 2 ^ 23 ) - 1",  
    10             "233 * 1103 * 2089 = 536870911 = ( 2 ^ 29 ) - 1",  
    11             "223 * 616318177 = 137438953471 = ( 2 ^ 37 ) - 1",  
    12             "13367 * 164511353 = 2199023255551 = ( 2 ^ 41 ) - 1",  
    13             "431 * 9719 * 2099863 = 8796093022207 = ( 2 ^ 43 ) - 1",  
    14             "2351 * 4513 * 13264529 = 140737488355327 = ( 2 ^ 47 ) - 1",  
    15             "6361 * 69431 * 20394401 = 9007199254740991 = ( 2 ^ 53 ) - 1",  
    16             "179951 * 3203431780337 = 576460752303423487 = ( 2 ^ 59 ) - 1" };  
    17     int n;  
    18     while(scanf("%d",&n)!=EOF)  
    19     {  
    20         for (int i=0;i<9;i++)  
    21             if(s[i]<=n)  
    22                 printf("%s
    ",st[i]);  
    23     }  
    24     return 0;  
    25 }  
  • 相关阅读:
    Apollo 配置中心
    Sentinel 限流
    soul 网关
    xxl-job 任务管理
    java Young GC排查
    bitmap(位图)
    RabbitMQ一个简单可靠的方案(.Net Core实现)
    从技术角度讨论微服务
    你可能不知道的.Net Core Configuration
    浅谈开发模式及架构发展
  • 原文地址:https://www.cnblogs.com/tak-fate/p/5915856.html
Copyright © 2011-2022 走看看