题解

191 条题解

  • 0
    @ 2014-12-06 09:57:38

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <stack>
    #include <cmath>
    #include <map>
    #define MAXN 1111111
    #define MAXM 400005
    #define INF 2000000007
    #define PI acos(-1.0)
    using namespace std;
    int x, y, num;
    int a[111111];
    bool isprime(int x)
    {
    int m = (int)sqrt(x * 1.0);
    for(int i = 2; i <= m; i++)
    if(x % i == 0) return false;
    return true;
    }
    int main()
    {
    scanf("%d%d", &x, &y);
    int cnt = 0;
    a[cnt++] = 2;
    a[cnt++] = 3;
    a[cnt++] = 5;
    a[cnt++] = 7;
    a[cnt++] = 11;
    for(int i = 1; i <= 9; i += 2)
    {
    if(i == 5) continue;
    for(int j = 0; j < 10; j++)
    {
    num = i * 100 + j * 10 + i;
    if(num >= x && num <= y)
    if(isprime(num))
    a[cnt++] = num;
    }
    }
    for(int i = 1; i <= 9; i += 2)
    {
    if(i == 5) continue;
    for(int j = 0; j < 10; j++)
    for(int k = 0; k < 10; k++)
    {
    num = i * 10000 + j * 1000 + k * 100 + j * 10 + i;
    if(num >= x && num <= y)
    if(isprime(num))
    a[cnt++] = num;
    }
    }
    for(int i = 1; i <= 9; i += 2)
    {
    if(i == 5) continue;
    for(int j = 0; j < 10; j++)
    for(int k = 0; k < 10; k++)
    for(int l = 0; l < 10; l++)
    {
    num = i * 1000000 + j * 100000 + k * 10000 + l * 1000 + k * 100 + j * 10 + i;
    if(num >= x && num <= y)
    if(isprime(num))
    a[cnt++] = num;
    }
    }
    for(int i = 0; i < cnt; i++)
    if(a[i] >= x && a[i] <= y)
    printf("%d\n", a[i]);
    system("pause");
    return 0;
    }

  • 0
    @ 2014-08-24 23:51:10

    主要是2个技巧,偶数位数的回文必定被11整除,还有尾数必须是1 3 7 9。

    所以复杂度再大也就=4000*(判断7位数素数的时间),所以放心大胆暴力dfs就是了

  • 0
    @ 2014-08-11 09:56:06

    打表万岁0-0不打表试了好几次都过不了打表就A了0-0
    #include<iostream>
    using namespace std;
    main()
    {
    int a[780]={0,5,7,11,101,131,151,181,191,313,353,373,383,727,757,787,797,919,929,10301,10501,10601,11311,11411,12421,12721,12821,13331,13831,13931,14341,14741,15451,15551,16061,16361,16561,16661,17471,17971,18181,18481,19391,19891,19991,30103,30203,30403,30703,30803,31013,31513,32323,32423,33533,34543,34843,35053,35153,35353,35753,36263,36563,37273,37573,38083,38183,38783,39293,70207,70507,70607,71317,71917,72227,72727,73037,73237,73637,74047,74747,75557,76367,76667,77377,77477,77977,78487,78787,78887,79397,79697,79997,90709,91019,93139,93239,93739,94049,94349,94649,94849,94949,95959,96269,96469,96769,97379,97579,97879,98389,98689,1003001,1008001,1022201,1028201,1035301,1043401,1055501,1062601,1065601,1074701,1082801,1085801,1092901,1093901,1114111,1117111,1120211,1123211,1126211,1129211,1134311,1145411,1150511,1153511,1160611,1163611,1175711,1177711,1178711,1180811,1183811,1186811,1190911,1193911,1196911,1201021,1208021,1212121,1215121,1218121,1221221,1235321,1242421,1243421,1245421,1250521,1253521,1257521,1262621,1268621,1273721,1276721,1278721,1280821,1281821,1286821,1287821,1300031,1303031,1311131,1317131,1327231,1328231,1333331,1335331,1338331,1343431,1360631,1362631,1363631,1371731,1374731,1390931,1407041,1409041,1411141,1412141,1422241,1437341,1444441,1447441,1452541,1456541,1461641,1463641,1464641,1469641,1486841,1489841,1490941,1496941,1508051,1513151,1520251,1532351,1535351,1542451,1548451,1550551,1551551,1556551,1557551,1565651,1572751,1579751,1580851,1583851,1589851,1594951,1597951,1598951,1600061,1609061,1611161,1616161,1628261,1630361,1633361,1640461,1643461,1646461,1654561,1657561,1658561,1660661,1670761,1684861,1685861,1688861,1695961,1703071,1707071,1712171,1714171,1730371,1734371,1737371,1748471,1755571,1761671,1764671,1777771,1793971,1802081,1805081,1820281,1823281,1824281,1826281,1829281,1831381,1832381,1842481,1851581,1853581,1856581,1865681,1876781,1878781,1879781,1880881,1881881,1883881,1884881,1895981,1903091,1908091,1909091,1917191,1924291,1930391,1936391,1941491,1951591,1952591,1957591,1958591,1963691,1968691,1969691,1970791,1976791,1981891,1982891,1984891,1987891,1988891,1993991,1995991,1998991,3001003,3002003,3007003,3016103,3026203,3064603,3065603,3072703,3073703,3075703,3083803,3089803,3091903,3095903,3103013,3106013,3127213,3135313,3140413,3155513,3158513,3160613,3166613,3181813,3187813,3193913,3196913,3198913,3211123,3212123,3218123,3222223,3223223,3228223,3233323,3236323,3241423,3245423,3252523,3256523,3258523,3260623,3267623,3272723,3283823,3285823,3286823,3288823,3291923,3293923,3304033,3305033,3307033,3310133,3315133,3319133,3321233,3329233,3331333,3337333,3343433,3353533,3362633,3364633,3365633,3368633,3380833,3391933,3392933,3400043,3411143,3417143,3424243,3425243,3427243,3439343,3441443,3443443,3444443,3447443,3449443,3452543,3460643,3466643,3470743,3479743,3485843,3487843,3503053,3515153,3517153,3528253,3541453,3553553,3558553,3563653,3569653,3586853,3589853,3590953,3591953,3594953,3601063,3607063,3618163,3621263,3627263,3635363,3643463,3646463,3670763,3673763,3680863,3689863,3698963,3708073,3709073,3716173,3717173,3721273,3722273,3728273,3732373,3743473,3746473,3762673,3763673,3765673,3768673,3769673,3773773,3774773,3781873,3784873,3792973,3793973,3799973,3804083,3806083,3812183,3814183,3826283,3829283,3836383,3842483,3853583,3858583,3863683,3864683,3867683,3869683,3871783,3878783,3893983,3899983,3913193,3916193,3918193,3924293,3927293,3931393,3938393,3942493,3946493,3948493,3964693,3970793,3983893,3991993,3994993,3997993,3998993,7014107,7035307,7036307,7041407,7046407,7057507,7065607,7069607,7073707,7079707,7082807,7084807,7087807,7093907,7096907,7100017,7114117,7115117,7118117,7129217,7134317,7136317,7141417,7145417,7155517,7156517,7158517,7159517,7177717,7190917,7194917,7215127,7226227,7246427,7249427,7250527,7256527,7257527,7261627,7267627,7276727,7278727,7291927,7300037,7302037,7310137,7314137,7324237,7327237,7347437,7352537,7354537,7362637,7365637,7381837,7388837,7392937,7401047,7403047,7409047,7415147,7434347,7436347,7439347,7452547,7461647,7466647,7472747,7475747,7485847,7486847,7489847,7493947,7507057,7508057,7518157,7519157,7521257,7527257,7540457,7562657,7564657,7576757,7586857,7592957,7594957,7600067,7611167,7619167,7622267,7630367,7632367,7644467,7654567,7662667,7665667,7666667,7668667,7669667,7674767,7681867,7690967,7693967,7696967,7715177,7718177,7722277,7729277,7733377,7742477,7747477,7750577,7758577,7764677,7772777,7774777,7778777,7782877,7783877,7791977,7794977,7807087,7819187,7820287,7821287,7831387,7832387,7838387,7843487,7850587,7856587,7865687,7867687,7868687,7873787,7884887,7891987,7897987,7913197,7916197,7930397,7933397,7935397,7938397,7941497,7943497,7949497,7957597,7958597,7960697,7977797,7984897,7985897,7987897,7996997,9002009,9015109,9024209,9037309,9042409,9043409,9045409,9046409,9049409,9067609,9073709,9076709,9078709,9091909,9095909,9103019,9109019,9110119,9127219,9128219,9136319,9149419,9169619,9173719,9174719,9179719,9185819,9196919,9199919,9200029,9209029,9212129,9217129,9222229,9223229,9230329,9231329,9255529,9269629,9271729,9277729,9280829,9286829,9289829,9318139,9320239,9324239,9329239,9332339,9338339,9351539,9357539,9375739,9384839,9397939,9400049,9414149,9419149,9433349,9439349,9440449,9446449,9451549,9470749,9477749,9492949,9493949,9495949,9504059,9514159,9526259,9529259,9547459,9556559,9558559,9561659,9577759,9583859,9585859,9586859,9601069,9602069,9604069,9610169,9620269,9624269,9626269,9632369,9634369,9645469,9650569,9657569,9670769,9686869,9700079,9709079,9711179,9714179,9724279,9727279,9732379,9733379,9743479,9749479,9752579,9754579,9758579,9762679,9770779,9776779,9779779,9781879,9782879,9787879,9788879,9795979,9801089,9807089,9809089,9817189,9818189,9820289,9822289,9836389,9837389,9845489,9852589,9871789,9888889,9889889,9896989,9902099,9907099,9908099,9916199,9918199,9919199,9921299,9923299,9926299,9927299,9931399,9932399,9935399,9938399,9957599,9965699,9978799,9980899,9981899,9989899},m,n,i;
    cin>>m>>n;
    for(i=1;i<=779;i++)
    {
    if(a[i]>=m&&a[i]<=n)
    cout<<a[i]<<endl;
    if(a[i]>n)
    return 0;
    }
    }

  • 0
    @ 2014-08-11 09:55:32

    #include<iostream>
    using namespace std;
    main()
    {
    int a[780]={0,5,7,11,101,131,151,181,191,313,353,373,383,727,757,787,797,919,929,10301,10501,10601,11311,11411,12421,12721,12821,13331,13831,13931,14341,14741,15451,15551,16061,16361,16561,16661,17471,17971,18181,18481,19391,19891,19991,30103,30203,30403,30703,30803,31013,31513,32323,32423,33533,34543,34843,35053,35153,35353,35753,36263,36563,37273,37573,38083,38183,38783,39293,70207,70507,70607,71317,71917,72227,72727,73037,73237,73637,74047,74747,75557,76367,76667,77377,77477,77977,78487,78787,78887,79397,79697,79997,90709,91019,93139,93239,93739,94049,94349,94649,94849,94949,95959,96269,96469,96769,97379,97579,97879,98389,98689,1003001,1008001,1022201,1028201,1035301,1043401,1055501,1062601,1065601,1074701,1082801,1085801,1092901,1093901,1114111,1117111,1120211,1123211,1126211,1129211,1134311,1145411,1150511,1153511,1160611,1163611,1175711,1177711,1178711,1180811,1183811,1186811,1190911,1193911,1196911,1201021,1208021,1212121,1215121,1218121,1221221,1235321,1242421,1243421,1245421,1250521,1253521,1257521,1262621,1268621,1273721,1276721,1278721,1280821,1281821,1286821,1287821,1300031,1303031,1311131,1317131,1327231,1328231,1333331,1335331,1338331,1343431,1360631,1362631,1363631,1371731,1374731,1390931,1407041,1409041,1411141,1412141,1422241,1437341,1444441,1447441,1452541,1456541,1461641,1463641,1464641,1469641,1486841,1489841,1490941,1496941,1508051,1513151,1520251,1532351,1535351,1542451,1548451,1550551,1551551,1556551,1557551,1565651,1572751,1579751,1580851,1583851,1589851,1594951,1597951,1598951,1600061,1609061,1611161,1616161,1628261,1630361,1633361,1640461,1643461,1646461,1654561,1657561,1658561,1660661,1670761,1684861,1685861,1688861,1695961,1703071,1707071,1712171,1714171,1730371,1734371,1737371,1748471,1755571,1761671,1764671,1777771,1793971,1802081,1805081,1820281,1823281,1824281,1826281,1829281,1831381,1832381,1842481,1851581,1853581,1856581,1865681,1876781,1878781,1879781,1880881,1881881,1883881,1884881,1895981,1903091,1908091,1909091,1917191,1924291,1930391,1936391,1941491,1951591,1952591,1957591,1958591,1963691,1968691,1969691,1970791,1976791,1981891,1982891,1984891,1987891,1988891,1993991,1995991,1998991,3001003,3002003,3007003,3016103,3026203,3064603,3065603,3072703,3073703,3075703,3083803,3089803,3091903,3095903,3103013,3106013,3127213,3135313,3140413,3155513,3158513,3160613,3166613,3181813,3187813,3193913,3196913,3198913,3211123,3212123,3218123,3222223,3223223,3228223,3233323,3236323,3241423,3245423,3252523,3256523,3258523,3260623,3267623,3272723,3283823,3285823,3286823,3288823,3291923,3293923,3304033,3305033,3307033,3310133,3315133,3319133,3321233,3329233,3331333,3337333,3343433,3353533,3362633,3364633,3365633,3368633,3380833,3391933,3392933,3400043,3411143,3417143,3424243,3425243,3427243,3439343,3441443,3443443,3444443,3447443,3449443,3452543,3460643,3466643,3470743,3479743,3485843,3487843,3503053,3515153,3517153,3528253,3541453,3553553,3558553,3563653,3569653,3586853,3589853,3590953,3591953,3594953,3601063,3607063,3618163,3621263,3627263,3635363,3643463,3646463,3670763,3673763,3680863,3689863,3698963,3708073,3709073,3716173,3717173,3721273,3722273,3728273,3732373,3743473,3746473,3762673,3763673,3765673,3768673,3769673,3773773,3774773,3781873,3784873,3792973,3793973,3799973,3804083,3806083,3812183,3814183,3826283,3829283,3836383,3842483,3853583,3858583,3863683,3864683,3867683,3869683,3871783,3878783,3893983,3899983,3913193,3916193,3918193,3924293,3927293,3931393,3938393,3942493,3946493,3948493,3964693,3970793,3983893,3991993,3994993,3997993,3998993,7014107,7035307,7036307,7041407,7046407,7057507,7065607,7069607,7073707,7079707,7082807,7084807,7087807,7093907,7096907,7100017,7114117,7115117,7118117,7129217,7134317,7136317,7141417,7145417,7155517,7156517,7158517,7159517,7177717,7190917,7194917,7215127,7226227,7246427,7249427,7250527,7256527,7257527,7261627,7267627,7276727,7278727,7291927,7300037,7302037,7310137,7314137,7324237,7327237,7347437,7352537,7354537,7362637,7365637,7381837,7388837,7392937,7401047,7403047,7409047,7415147,7434347,7436347,7439347,7452547,7461647,7466647,7472747,7475747,7485847,7486847,7489847,7493947,7507057,7508057,7518157,7519157,7521257,7527257,7540457,7562657,7564657,7576757,7586857,7592957,7594957,7600067,7611167,7619167,7622267,7630367,7632367,7644467,7654567,7662667,7665667,7666667,7668667,7669667,7674767,7681867,7690967,7693967,7696967,7715177,7718177,7722277,7729277,7733377,7742477,7747477,7750577,7758577,7764677,7772777,7774777,7778777,7782877,7783877,7791977,7794977,7807087,7819187,7820287,7821287,7831387,7832387,7838387,7843487,7850587,7856587,7865687,7867687,7868687,7873787,7884887,7891987,7897987,7913197,7916197,7930397,7933397,7935397,7938397,7941497,7943497,7949497,7957597,7958597,7960697,7977797,7984897,7985897,7987897,7996997,9002009,9015109,9024209,9037309,9042409,9043409,9045409,9046409,9049409,9067609,9073709,9076709,9078709,9091909,9095909,9103019,9109019,9110119,9127219,9128219,9136319,9149419,9169619,9173719,9174719,9179719,9185819,9196919,9199919,9200029,9209029,9212129,9217129,9222229,9223229,9230329,9231329,9255529,9269629,9271729,9277729,9280829,9286829,9289829,9318139,9320239,9324239,9329239,9332339,9338339,9351539,9357539,9375739,9384839,9397939,9400049,9414149,9419149,9433349,9439349,9440449,9446449,9451549,9470749,9477749,9492949,9493949,9495949,9504059,9514159,9526259,9529259,9547459,9556559,9558559,9561659,9577759,9583859,9585859,9586859,9601069,9602069,9604069,9610169,9620269,9624269,9626269,9632369,9634369,9645469,9650569,9657569,9670769,9686869,9700079,9709079,9711179,9714179,9724279,9727279,9732379,9733379,9743479,9749479,9752579,9754579,9758579,9762679,9770779,9776779,9779779,9781879,9782879,9787879,9788879,9795979,9801089,9807089,9809089,9817189,9818189,9820289,9822289,9836389,9837389,9845489,9852589,9871789,9888889,9889889,9896989,9902099,9907099,9908099,9916199,9918199,9919199,9921299,9923299,9926299,9927299,9931399,9932399,9935399,9938399,9957599,9965699,9978799,9980899,9981899,9989899},m,n,i;
    cin>>m>>n;
    for(i=1;i<=779;i++)
    {
    if(a[i]>=m&&a[i]<=n)
    cout<<a[i]<<endl;
    if(a[i]>n)
    return 0;
    }
    }

  • 0
    @ 2013-04-08 20:59:48

    编译成功

    测试数据 #0: Accepted, time = 0 ms
    测试数据 #1: Accepted, time = 15 ms
    测试数据 #2: Accepted, time = 154 ms
    测试数据 #3: Accepted, time = 168 ms
    测试数据 #4: Accepted, time = 15 ms
    测试数据 #5: Accepted, time = 14 ms
    测试数据 #6: Accepted, time = 517 ms
    测试数据 #7: Accepted, time = 460 ms
    测试数据 #8: Accepted, time = 15 ms
    测试数据 #9: Accepted, time = 519 ms

  • 0
    @ 2012-10-25 16:21:44

    初看此题,范围很大。

    不过仔细分析一下,就发现很简单了

    由于要求是素数,并且是小于1亿

    那么最多回文数是8位数

    由于前后对称,那么我们最多也就枚举前4位即可

    并且第一位是偶数和5的情况可以不考虑

    再加上判素数是sqrt(n),这时发现复杂度还是有点高

    这就需要一个比较重要的结论

    若一个数的奇数位的和与偶数位的和相差为11的倍数,则该数是11的倍数,这个结论不难证明

    此时可以看出偶数位的回文数一定是11的倍数,所以除了11外,偶数位的回文数都可以不考虑了

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #define MAXN 1111111

    #define MAXM 400005

    #define INF 2000000007

    #define PI acos(-1.0)

    using namespace std;

    int x, y, num;

    int a[111111];

    bool isprime(int x)

    {

    int m = (int)sqrt(x * 1.0);

    for(int i = 2; i

  • 0
    @ 2012-10-16 22:03:36

    强烈要求此题改时间!

    不打表必超时,什么烂题!什么烂测评机!

    • @ 2013-10-29 18:58:02

      傻逼!!
      编译成功

      测试数据 #0: Accepted, time = 15 ms, mem = 772 KiB, score = 10
      测试数据 #1: Accepted, time = 15 ms, mem = 772 KiB, score = 10
      测试数据 #2: Accepted, time = 0 ms, mem = 772 KiB, score = 10
      测试数据 #3: Accepted, time = 15 ms, mem = 776 KiB, score = 10
      测试数据 #4: Accepted, time = 15 ms, mem = 776 KiB, score = 10
      测试数据 #5: Accepted, time = 15 ms, mem = 776 KiB, score = 10
      测试数据 #6: Accepted, time = 62 ms, mem = 772 KiB, score = 10
      测试数据 #7: Accepted, time = 62 ms, mem = 776 KiB, score = 10
      测试数据 #8: Accepted, time = 0 ms, mem = 776 KiB, score = 10
      测试数据 #9: Accepted, time = 78 ms, mem = 772 KiB, score = 10
      Accepted, time = 277 ms, mem = 776 KiB, score = 100
      代码
      program p1042;
      var l,r:int64;
      a:array[1..4] of integer;
      b:array[0..10000] of longint;
      ////////////////////////////////////////
      procedure init;
      begin
      read(l,r);
      end;
      ////////////////////////////////////////
      procedure print1(n:integer);
      var j,k:int64;
      i:integer;
      begin
      k:=0;j:=1;
      for i:=n downto 1 do
      begin
      k:=a[i]+k*10;
      end;
      for i:=2 to n do
      begin
      k:=a[i]+k*10;
      end;
      if (k>r) or (k<l) then exit;
      for i:=2 to trunc(sqrt(k)) do
      if k mod i=0 then exit;
      inc(b[0]);b[b[0]]:=k;
      end;
      ////////////////////////////////////////
      procedure print2(n:integer);
      var j,k:int64;
      i:integer;
      begin
      k:=0;j:=1;
      for i:=n downto 1 do
      begin
      k:=a[i]+k*10;
      end;
      for i:=1 to n do
      begin
      k:=a[i]+k*10;
      end;
      if (k>r) or (k<l) then exit;
      for i:=2 to trunc(sqrt(k)) do
      if k mod i=0 then exit;
      inc(b[0]);b[b[0]]:=k;
      end;
      ////////////////////////////////////////
      procedure dfs1(j,n:integer);
      var i:integer;
      begin
      if j=n then
      begin
      for i:=1 to 9 do
      begin
      a[j]:=i;print1(n);
      end;
      exit;
      end;
      for i:=0 to 9 do
      begin
      a[j]:=i;dfs1(j+1,n);
      end;
      end;
      ////////////////////////////////////////
      procedure dfs2(j,n:integer);
      var i:integer;
      begin
      if j=n then
      begin
      for i:=1 to 9 do
      begin
      a[j]:=i;print2(n);
      end;
      exit;
      end;
      for i:=0 to 9 do
      begin
      a[j]:=i;dfs2(j+1,n);
      end;
      end;
      ////////////////////////////////////////
      procedure main;
      var i,j:integer;
      k:longint;
      begin
      for i:=1 to 4 do
      begin
      dfs1(1,i);
      dfs2(1,i);
      end;
      for i:=1 to b[0]-1 do
      for j:=i+1 to b[0] do
      if b[j]<b[i] then
      begin
      k:=b[i];b[i]:=b[j];b[j]:=k;
      end;
      end;
      ////////////////////////////////////////
      procedure print;
      var i:integer;
      begin
      for i:=1 to b[0] do writeln(b[i]);
      end;
      ////////////////////////////////////////
      begin
      init;
      main;
      print;
      end.

  • 0
    @ 2012-09-23 19:58:52

    ……

  • 0
    @ 2012-08-02 23:23:07

    先打素数表,然后利用素数表打解表~

    root [ ~/noi ]# ls vijos1042*

    vijos1042 vijos1042.cxx vijos1042-lv2tbl vijos1042-lv2tbl.cxx vijos1042-lv2tbl-src.cxx vijos1042-lv2tbl-src.o

    其中lv2tbl是2次打表机~

  • 0
    @ 2012-08-01 16:23:07

    点击这里查看

  • 0
    @ 2010-07-09 23:52:13

    #include

    using namespace std;

    int f[780]={0,5,7,11,101,131,151,181,191,313,353,373,383,727,757,787,797,919,929,10301,10501,10601,11311,11411,12421,12721,12821,13331,13831,13931,14341,14741,15451,15551,16061,16361,16561,16661,17471,17971,18181,18481,19391,19891,19991,30103,30203,30403,30703,30803,31013,31513,32323,32423,33533,34543,34843,35053,35153,35353,35753,36263,36563,37273,37573,38083,38183,38783,39293,70207,70507,70607,71317,71917,72227,72727,73037,73237,73637,74047,74747,75557,76367,76667,77377,77477,77977,78487,78787,78887,79397,79697,79997,90709,91019,93139,93239,93739,94049,94349,94649,94849,94949,95959,96269,96469,96769,97379,97579,97879,98389,98689,1003001,1008001,1022201,1028201,1035301,1043401,1055501,1062601,1065601,1074701,1082801,1085801,1092901,1093901,1114111,1117111,1120211,1123211,1126211,1129211,1134311,1145411,1150511,1153511,1160611,1163611,1175711,1177711,1178711,1180811,1183811,1186811,1190911,1193911,1196911,1201021,1208021,1212121,1215121,1218121,1221221,1235321,1242421,1243421,1245421,1250521,1253521,1257521,1262621,1268621,1273721,1276721,1278721,1280821,1281821,1286821,1287821,1300031,1303031,1311131,1317131,1327231,1328231,1333331,1335331,1338331,1343431,1360631,1362631,1363631,1371731,1374731,1390931,1407041,1409041,1411141,1412141,1422241,1437341,1444441,1447441,1452541,1456541,1461641,1463641,1464641,1469641,1486841,1489841,1490941,1496941,1508051,1513151,1520251,1532351,1535351,1542451,1548451,1550551,1551551,1556551,1557551,1565651,1572751,1579751,1580851,1583851,1589851,1594951,1597951,1598951,1600061,1609061,1611161,1616161,1628261,1630361,1633361,1640461,1643461,1646461,1654561,1657561,1658561,1660661,1670761,1684861,1685861,1688861,1695961,1703071,1707071,1712171,1714171,1730371,1734371,1737371,1748471,1755571,1761671,1764671,1777771,1793971,1802081,1805081,1820281,1823281,1824281,1826281,1829281,1831381,1832381,1842481,1851581,1853581,1856581,1865681,1876781,1878781,1879781,1880881,1881881,1883881,1884881,1895981,1903091,1908091,1909091,1917191,1924291,1930391,1936391,1941491,1951591,1952591,1957591,1958591,1963691,1968691,1969691,1970791,1976791,1981891,1982891,1984891,1987891,1988891,1993991,1995991,1998991,3001003,3002003,3007003,3016103,3026203,3064603,3065603,3072703,3073703,3075703,3083803,3089803,3091903,3095903,3103013,3106013,3127213,3135313,3140413,3155513,3158513,3160613,3166613,3181813,3187813,3193913,3196913,3198913,3211123,3212123,3218123,3222223,3223223,3228223,3233323,3236323,3241423,3245423,3252523,3256523,3258523,3260623,3267623,3272723,3283823,3285823,3286823,3288823,3291923,3293923,3304033,3305033,3307033,3310133,3315133,3319133,3321233,3329233,3331333,3337333,3343433,3353533,3362633,3364633,3365633,3368633,3380833,3391933,3392933,3400043,3411143,3417143,3424243,3425243,3427243,3439343,3441443,3443443,3444443,3447443,3449443,3452543,3460643,3466643,3470743,3479743,3485843,3487843,3503053,3515153,3517153,3528253,3541453,3553553,3558553,3563653,3569653,3586853,3589853,3590953,3591953,3594953,3601063,3607063,3618163,3621263,3627263,3635363,3643463,3646463,3670763,3673763,3680863,3689863,3698963,3708073,3709073,3716173,3717173,3721273,3722273,3728273,3732373,3743473,3746473,3762673,3763673,3765673,3768673,3769673,3773773,3774773,3781873,3784873,3792973,3793973,3799973,3804083,3806083,3812183,3814183,3826283,3829283,3836383,3842483,3853583,3858583,3863683,3864683,3867683,3869683,3871783,3878783,3893983,3899983,3913193,3916193,3918193,3924293,3927293,3931393,3938393,3942493,3946493,3948493,3964693,3970793,3983893,3991993,3994993,3997993,3998993,7014107,7035307,7036307,7041407,7046407,7057507,7065607,7069607,7073707,7079707,7082807,7084807,7087807,7093907,7096907,7100017,7114117,7115117,7118117,7129217,7134317,7136317,7141417,7145417,7155517,7156517,7158517,7159517,7177717,7190917,7194917,7215127,7226227,7246427,7249427,7250527,7256527,7257527,7261627,7267627,7276727,7278727,7291927,7300037,7302037,7310137,7314137,7324237,7327237,7347437,7352537,7354537,7362637,7365637,7381837,7388837,7392937,7401047,7403047,7409047,7415147,7434347,7436347,7439347,7452547,7461647,7466647,7472747,7475747,7485847,7486847,7489847,7493947,7507057,7508057,7518157,7519157,7521257,7527257,7540457,7562657,7564657,7576757,7586857,7592957,7594957,7600067,7611167,7619167,7622267,7630367,7632367,7644467,7654567,7662667,7665667,7666667,7668667,7669667,7674767,7681867,7690967,7693967,7696967,7715177,7718177,7722277,7729277,7733377,7742477,7747477,7750577,7758577,7764677,7772777,7774777,7778777,7782877,7783877,7791977,7794977,7807087,7819187,7820287,7821287,7831387,7832387,7838387,7843487,7850587,7856587,7865687,7867687,7868687,7873787,7884887,7891987,7897987,7913197,7916197,7930397,7933397,7935397,7938397,7941497,7943497,7949497,7957597,7958597,7960697,7977797,7984897,7985897,7987897,7996997,9002009,9015109,9024209,9037309,9042409,9043409,9045409,9046409,9049409,9067609,9073709,9076709,9078709,9091909,9095909,9103019,9109019,9110119,9127219,9128219,9136319,9149419,9169619,9173719,9174719,9179719,9185819,9196919,9199919,9200029,9209029,9212129,9217129,9222229,9223229,9230329,9231329,9255529,9269629,9271729,9277729,9280829,9286829,9289829,9318139,9320239,9324239,9329239,9332339,9338339,9351539,9357539,9375739,9384839,9397939,9400049,9414149,9419149,9433349,9439349,9440449,9446449,9451549,9470749,9477749,9492949,9493949,9495949,9504059,9514159,9526259,9529259,9547459,9556559,9558559,9561659,9577759,9583859,9585859,9586859,9601069,9602069,9604069,9610169,9620269,9624269,9626269,9632369,9634369,9645469,9650569,9657569,9670769,9686869,9700079,9709079,9711179,9714179,9724279,9727279,9732379,9733379,9743479,9749479,9752579,9754579,9758579,9762679,9770779,9776779,9779779,9781879,9782879,9787879,9788879,9795979,9801089,9807089,9809089,9817189,9818189,9820289,9822289,9836389,9837389,9845489,9852589,9871789,9888889,9889889,9896989,9902099,9907099,9908099,9916199,9918199,9919199,9921299,9923299,9926299,9927299,9931399,9932399,9935399,9938399,9957599,9965699,9978799,9980899,9981899,9989899};

    long long m,n;

    int init()

    {

    cin>>m>>n;

    for (int i=1;i=m&&f[i]

  • 0
    @ 2010-04-11 12:45:23

    TMD,SUSHU原来是.......,害我懵了好久都不知道在说啥

  • 0
    @ 2010-04-03 15:38:29

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    从输出数据看,结果不会大于8

  • 0
    @ 2010-03-18 13:50:17

    =.=为什么别人都是第10个点TLE 我是第7个点TLE…

  • 0
    @ 2010-03-10 12:56:29

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 571ms

    ├ 测试数据 06:答案正确... 493ms

    ├ 测试数据 07:答案正确... 649ms

    ├ 测试数据 08:答案正确... 618ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:内存溢出...

    var

    a:array[1..100000000] of boolean;

    n,m,i:longint;

    Function hui(x:longint):boolean;

    var

    s:string;

    i,j,len:longint;

    begin

    str(x,s);

    len:=length(s);

    i:=1;

    j:=len;

    hui:=true;

    while i

  • 0
    @ 2009-11-13 15:59:17

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 525ms

    ├ 测试数据 08:答案正确... 462ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 525ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:1512ms

    program p1042;

    var

    i,j,k,m,n:longint;

    s:string;

    flag:boolean;

    function sushu(x:longint):boolean;

    var i,j:longint;

    begin

    for j:=2 to trunc(sqrt(x)) do

    if x mod j=0 then exit(false);

    exit(true);

    end;

    begin

    readln(m,n);

    i:=1; flag:=false;

    for k:=m to n do

    begin

    str(k,s);

    j:=length(s);

    if j>=8 then halt;

    while ij then begin

    flag:=sushu(k);

    if flag=true then writeln(k);

    end;

    i:=1; flag:=false;

    end;

    end.

  • 0
    @ 2009-11-09 19:43:14

    用构造法全部秒杀 有疑问的请来我空间

    http://hi.baidu.com/xjlittlewhite/blog/item/18f79361c2cb184eeaf8f8bd.html

  • 0
    @ 2009-11-05 11:00:47

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    var

    m,n,i,j,h,t,len1,len2,p:longint;

    a,c:array[1..10000]of longint;

    x,y,x1:string;

    procedure make;

    var i:longint;bl:boolean;

    begin

    c[0]:=2;c[1]:=2;c[2]:=3;

    for i:=4 to 10000 do

    begin bl:=false;

    for j:=1 to c[0]do

    if i mod c[j]=0 then begin bl:=true;break;end;

    if not(bl)then begin inc(c[0]);c[c[0]]:=i;end;

    end;

    end;

    function check(x:longint):boolean;

    var i1,y:longint;

    begin

    i1:=1;

    y:=trunc(sqrt(x));

    while (x mod c[i1]0)and(c[i1]y then exit(true);

    exit(false);

    end;

    begin

    readln(n,m); str(n,x);str(m,y);

    h:=1;t:=1; if (n=2)then writeln(2);

    len1:=(length(x)+1)shr 1;

    len2:=(length(y)+1)shr 1;

    for i:=2 to len1 do h:=h*10;

    for i:=1 to len2 do t:=t*10;

    dec(t); make;

    for i:=h to t do

    begin

    str(i,x1);

    if(odd(ord(x1[1])-ord('0')))then

    begin

    len1:=length(x1);

    for j:=len1-1 downto 1do

    x1:=x1+x1[j];

    val(x1,p);

    if (p>=n)and(p

  • 0
    @ 2009-11-04 21:56:39

    怎么能不超时呢?

    总是超两个

    我先判断的回文数

    在判断是不是素数

信息

ID
1042
难度
7
分类
搜索 | 搜索与剪枝 点击显示
标签
(无)
递交数
6601
已通过
1521
通过率
23%
被复制
13
上传者