这题如果全部打表的话,文件大小会有65kb,超了,所以只打出一半,前一半用程序算就可以了,并不会超时。
如果算法优化的好,其实可以打的更少。
#include
using namespace std;
const int maxn=1e5+10;
// const int N=1e4+10;
const int N=5e3+10;
int vis[maxn],p[maxn],cnt=0,f[maxn];
int a[maxn]={94353,94353,94353,94623,94623,94623,94623,94623,94623,94865,94865,95111,95111,95111,95111,95111,95111,95111,95111,95111,95111,95336,95336,95620,95620,95620,95620,95620,95620,95620,95620,95620,95620,95620,95620,95620,95620,95620,95620,95818,95818,95818,95818,95818,95818,95818,95818,95818,95818,95818,95818,96074,96074,96074,96074,96074,96074,96074,96074,96321,96321,96321,96321,96321,96321,96321,96321,96321,96321,96321,96321,96321,96321,96321,96321,96321,96321,96585,96585,96585,96585,96819,96819,96819,96819,96819,96819,97088,97088,97088,97088,97088,97088,97088,97088,97088,97088,97088,97088,97352,97352,97570,97570,97570,97570,97570,97570,97862,97862,97862,97862,97862,97862,98163,98163,98163,98163,98163,98163,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98394,98663,98663,98663,98663,98663,98663,98932,98932,98932,98932,98932,98932,98932,98932,98932,98932,98932,98932,98932,98932,99218,99218,99218,99218,99475,99475,99475,99475,99475,99475,99475,99475,99706,99706,99706,99706,99706,99706,99706,99706,99706,99706,99968,99968,99968,99968,99968,99968,99968,99968,100275,100275,100275,100275,100275,100275,100275,100275,100275,100275,100275,100275,100558,100558,100558,100558,100558,100558,100558,100558,100558,100558,100558,100558,100558,100558,100558,100558,100558,100558,100798,100798,100798,100798,101019,101019,101336,101336,101336,101336,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101610,101895,101895,101895,101895,101895,101895,101895,101895,101895,101895,101895,101895,102194,102194,102194,102194,102194,102194,102420,102420,102687,102687,102687,102687,102687,102687,102687,102687,102687,102687,102687,102687,102687,102687,102687,102687,102969,102969,102969,102969,102969,102969,103249,103249,103249,103249,103249,103249,103502,103502,103502,103502,103502,103502,103502,103502,103502,103502,103502,103502,103502,103502,103801,103801,103801,103801,103801,103801,103801,103801,103801,103801,104089,104089,104089,104089,104089,104089,104089,104089,104089,104089,104089,104089,104089,104089,104370,104370,104370,104370,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104613,104865,104865,104865,104865,104865,104865,105195,105195,105195,105195,105195,105195,105536,105536,105536,105536,105536,105536,105803,105803,105803,105803,105803,105803,105803,105803,106104,106104,106104,106104,106104,106104,106399,106399,106399,106399,106644,106644,106871,106871,106871,106871,106871,106871,106871,106871,106871,106871,106871,106871,107143,107143,107143,107143,107143,107143,107484,107484,107484,107484,107702,107702,108016,108016,108016,108016,108016,108016,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108311,108597,108597,108597,108597,108597,108597,108924,108924,109154,109154,109154,109154,109456,109456,109456,109456,109456,109456,109456,109456,109456,109456,109456,109456,109456,109456,109456,109456,109456,109456,109694,109694,109993,109993,109993,109993,110284,110284,110284,110284,110284,110284,110284,110284,110284,110284,110284,110284,110572,110572,110838,110838,110838,110838,110838,110838,111194,111194,111194,111194,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111421,111699,111699,111699,111699,111699,111699,112002,112002,112002,112002,112002,112002,112282,112282,112282,112282,112583,112583,112583,112583,112583,112583,112583,112583,112825,112825,112825,112825,112825,112825,112825,112825,112825,112825,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113077,113376,113376,113376,113376,113376,113376,113376,113376,113376,113376,113376,113376,113376,113376,113376,113376,113669,113669,113925,113925,113925,113925,113925,113925,114245,114245,114245,114245,114501,114501,114802,114802,114802,114802,115107,115107,115373,115373,115373,115373,115373,115373,115373,115373,115373,115373,115613,115613,115613,115613,115613,115613,115613,115613,115613,115613,115613,115613,115613,115613,115870,115870,115870,115870,115870,115870,116108,116108,116108,116108,116397,116397,116397,116397,116397,116397,116397,116397,116712,116712,116712,116712,116712,116712,116712,116712,116712,116712,116978,116978,116978,116978,116978,116978,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117317,117675,117675,117675,117675,117927,117927,118268,118268,118268,118268,118268,118268,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118523,118804,118804,118804,118804,119082,119082,119082,119082,119082,119082,119082,119082,119341,119341,119341,119341,119341,119341,119341,119341,119341,119341,119593,119593,119593,119593,119593,119593,119917,119917,119917,119917,119917,119917,120235,120235,120235,120235,120235,120235,120235,120235,120522,120522,120522,120522,120522,120522,120870,120870,120870,120870,120870,120870,120870,120870,120870,120870,120870,120870,121123,121123,121123,121123,121424,121424,121424,121424,121424,121424,121734,121734,121997,121997,121997,121997,121997,121997,122279,122279,122279,122279,122526,122526,122526,122526,122526,122526,122801,122801,123081,123081,123081,123081,123081,123081,123081,123081,123081,123081,123362,123362,123617,123617,123617,123617,123617,123617,123617,123617,123617,123617,123617,123617,123617,123617,123617,123617,123937,123937,123937,123937,123937,123937,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124237,124546,124546,124546,124546,124850,124850,124850,124850,124850,124850,124850,124850,124850,124850,124850,124850,125123,125123,125123,125123,125123,125123,125123,125123,125123,125123,125123,125123,125123,125123,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125475,125774,125774,125774,125774,125774,125774,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126099,126428,126428,126428,126428,126687,126687,126687,126687,126687,126687,126687,126687,126687,126687,126687,126687,126687,126687,126687,126687,126687,126687,126970,126970,126970,126970,126970,126970,126970,126970,127294,127294,127294,127294,127294,127294,127597,127597,127597,127597,127916,127916,127916,127916,127916,127916,128204,128204,128204,128204,128204,128204,128204,128204,128204,128204,128204,128204,128204,128204,128532,128532,128532,128532,128532,128532,128868,128868,128868,128868,128868,128868,129151,129151,129151,129151,129151,129151,129151,129151,129151,129151,129433,129433,129708,129708,129708,129708,129708,129708,129708,129708,129708,129708,130014,130014,130014,130014,130014,130014,130014,130014,130014,130014,130014,130014,130351,130351,130351,130351,130351,130351,130351,130351,130636,130636,130636,130636,130636,130636,130636,130636,130636,130636,130913,130913,131242,131242,131242,131242,131242,131242,131242,131242,131242,131242,131561,131561,131561,131561,131561,131561,131561,131561,131850,131850,131850,131850,131850,131850,131850,131850,131850,131850,131850,131850,132201,132201,132201,132201,132201,132201,132201,132201,132201,132201,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132534,132847,132847,133131,133131,133131,133131,133449,133449,133449,133449,133449,133449,133449,133449,133726,133726,133726,133726,133726,133726,134053,134053,134053,134053,134325,134325,134325,134325,134325,134325,134325,134325,134609,134609,134609,134609,134609,134609,134609,134609,134609,134609,134609,134609,134609,134609,134609,134609,134609,134609,134946,134946,134946,134946,134946,134946,134946,134946,134946,134946,135265,135265,135265,135265,135265,135265,135613,135613,135613,135613,135613,135613,135906,135906,136183,136183,136183,136183,136183,136183,136477,136477,136477,136477,136477,136477,136477,136477,136477,136477,136798,136798,136798,136798,136798,136798,136798,136798,136798,136798,136798,136798,137080,137080,137326,137326,137326,137326,137326,137326,137326,137326,137326,137326,137656,137656,137656,137656,137656,137656,138009,138009,138009,138009,138009,138009,138310,138310,138310,138310,138310,138310,138575,138575,138575,138575,138575,138575,138575,138575,138872,138872,138872,138872,138872,138872,139191,139191,139191,139191,139191,139191,139191,139191,139191,139191,139515,139515,139515,139515,139515,139515,139801,139801,140104,140104,140104,140104,140104,140104,140478,140478,140478,140478,140478,140478,140849,140849,140849,140849,140849,140849,141141,141141,141141,141141,141141,141141,141141,141141,141141,141141,141432,141432,141432,141432,141432,141432,141432,141432,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,141767,142055,142055,142055,142055,142055,142055,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142382,142665,142665,143001,143001,143001,143001,143001,143001,143001,143001,143001,143001,143001,143001,143001,143001,143001,143001,143001,143001,143269,143269,143269,143269,143600,143600,143600,143600,143600,143600,143600,143600,143872,143872,143872,143872,143872,143872,143872,143872,143872,143872,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144166,144486,144486,144486,144486,144486,144486,144486,144486,144786,144786,144786,144786,144786,144786,144786,144786,144786,144786,144786,144786,144786,144786,144786,144786,144786,144786,145101,145101,145101,145101,145367,145367,145699,145699,145699,145699,145699,145699,145699,145699,145699,145699,146051,146051,146051,146051,146051,146051,146353,146353,146649,146649,146649,146649,146649,146649,147021,147021,147021,147021,147321,147321,147321,147321,147321,147321,147321,147321,147321,147321,147321,147321,147321,147321,147321,147321,147321,147321,147610,147610,147610,147610,147610,147610,147610,147610,147914,147914,147914,147914,147914,147914,147914,147914,147914,147914,147914,147914,148231,148231,148231,148231,148231,148231,148231,148231,148231,148231,148231,148231,148231,148231,148231,148231,148231,148231,148552,148552,148552,148552,148552,148552,148552,148552,148552,148552,148552,148552,148552,148552,148552,148552,148946,148946,148946,148946,148946,148946,149220,149220,149539,149539,149539,149539,149539,149539,149539,149539,149539,149539,149539,149539,149879,149879,149879,149879,149879,149879,150197,150197,150197,150197,150197,150197,150197,150197,150197,150197,150514,150514,150817,150817,150817,150817,150817,150817,150817,150817,150817,150817,151104,151104,151480,151480,151480,151480,151480,151480,151776,151776,151776,151776,151776,151776,151776,151776,151776,151776,152067,152067,152067,152067,152067,152067,152067,152067,152067,152067,152067,152067,152067,152067,152415,152415,152415,152415,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,152804,153101,153101,153452,153452,153452,153452,153452,153452,153452,153452,153452,153452,153452,153452,153452,153452,153452,153452,153784,153784,154085,154085,154085,154085,154085,154085,154085,154085,154085,154085,154374,154374,154726,154726,154726,154726,154726,154726,154726,154726,154726,154726,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155054,155431,155431,155431,155431,155744,155744,156062,156062,156062,156062,156407,156407,156407,156407,156407,156407,156407,156407,156718,156718,156718,156718,156718,156718,156718,156718,156718,156718,156718,156718,156718,156718,156718,156718,157086,157086,157086,157086,157086,157086,157440,157440,157440,157440,157440,157440,157724,157724,158045,158045,158045,158045,158045,158045,158045,158045,158045,158045,158045,158045,158409,158409,158409,158409,158409,158409,158409,158409,158409,158409,158409,158409,158409,158409,158409,158409,158725,158725,158725,158725,158725,158725,158725,158725,159049,159049,159049,159049,159345,159345,159345,159345,159345,159345,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,159696,160076,160076,160376,160376,160376,160376,160376,160376,160376,160376,160376,160376,160687,160687,161011,161011,161011,161011,161011,161011,161360,161360,161360,161360,161693,161693,161693,161693,161693,161693,162055,162055,162055,162055,162055,162055,162428,162428,162428,162428,162428,162428,162428,162428,162732,162732,162732,162732,162732,162732,163118,163118,163118,163118,163426,163426,163426,163426,163426,163426,163426,163426,163426,163426,163426,163426,163767,163767,163767,163767,163767,163767,164030,164030,164030,164030,164030,164030,164030,164030,164387,164387,164387,164387,164387,164387,164387,164387,164387,164387,164387,164387,164698,164698,164698,164698,165076,165076,165076,165076,165076,165076,165076,165076,165076,165076,165076,165076,165076,165076,165406,165406,165406,165406,165406,165406,165406,165406,165406,165406,165406,165406,165728,165728,165728,165728,165728,165728,165728,165728,165728,165728,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166023,166410,166410,166410,166410,166410,166410,166762,166762,166762,166762,166762,166762,166762,166762,166762,166762,166762,166762,167091,167091,167091,167091,167091,167091,167463,167463,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,167769,168087,168087,168087,168087,168087,168087,168087,168087,168361,168361,168361,168361,168361,168361,168361,168361,168361,168361,168361,168361,168361,168361,168361,168361,168361,168361,168708,168708,168708,168708,168708,168708,168708,168708,168708,168708,169051,169051,169051,169051,169051,169051,169441,169441,169441,169441,169441,169441,169441,169441,169441,169441,169441,169441,169441,169441,169814,169814,169814,169814,170137,170137,170518,170518,170518,170518,170518,170518,170843,170843,170843,170843,170843,170843,170843,170843,170843,170843,171132,171132,171132,171132,171132,171132,171132,171132,171470,171470,171470,171470,171470,171470,171819,171819,171819,171819,172177,172177,172177,172177,172177,172177,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172546,172970,172970,172970,172970,172970,172970,172970,172970,172970,172970,172970,172970,172970,172970,173344,173344,173344,173344,173344,173344,173344,173344,173344,173344,173747,173747,174057,174057,174057,174057,174057,174057,174057,174057,174057,174057,174057,174057,174364,174364,174364,174364,174364,174364,174364,174364,174364,174364,174673,174673,175038,175038,175038,175038,175038,175038,175038,175038,175038,175038,175038,175038,175038,175038,175038,175038,175332,175332,175649,175649,175649,175649,175649,175649,175649,175649,175649,175649,175649,175649,175649,175649,175649,175649,175649,175649,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,175972,176331,176331,176331,176331,176331,176331,176331,176331,176331,176331,176331,176331,176331,176331,176331,176331,176331,176331,176642,176642,176642,176642,176642,176642,177055,177055,177055,177055,177055,177055,177055,177055,177055,177055,177055,177055,177055,177055,177055,177055,177450,177450,177450,177450,177450,177450,177450,177450,177450,177450,177450,177450,177450,177450,177450,177450,177450,177450,177771,177771,177771,177771,177771,177771,178094,178094,178456,178456,178456,178456,178456,178456,178456,178456,178456,178456,178456,178456,178456,178456,178456,178456,178456,178456,178828,178828,178828,178828,179150,179150,179150,179150,179150,179150,179564,179564,179877,179877,179877,179877,179877,179877,179877,179877,179877,179877,180210,180210,180210,180210,180210,180210,180210,180210,180623,180623,180623,180623,180623,180623,180623,180623,180623,180623,180985,180985,180985,180985,180985,180985,181337,181337,181337,181337,181337,181337,181671,181671,181671,181671,181671,181671,181671,181671,182056,182056,182056,182056,182380,182380,182380,182380,182380,182380,182754,182754,183103,183103,183103,183103,183103,183103,183103,183103,183103,183103,183414,183414,183724,183724,183724,183724,183724,183724,183724,183724,183724,183724,183724,183724,184086,184086,184086,184086,184477,184477,184477,184477,184477,184477,184840,184840,184840,184840,184840,184840,185150,185150,185481,185481,185481,185481,185481,185481,185481,185481,185481,185481,185481,185481,185849,185849,185849,185849,186201,186201,186201,186201,186201,186201,186201,186201,186201,186201,186201,186201,186201,186201,186536,186536,186536,186536,186536,186536,186536,186536,186536,186536,186536,186536,186536,186536,186536,186536,186536,186536,186849,186849,186849,186849,187198,187198,187198,187198,187198,187198,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187514,187854,187854,187854,187854,188231,188231,188231,188231,188231,188231,188231,188231,188563,188563,188563,188563,188563,188563,188939,188939,188939,188939,189254,189254,189254,189254,189254,189254,189254,189254,189596,189596,189596,189596,190041,190041,190041,190041,190041,190041,190041,190041,190041,190041,190041,190041,190041,190041,190434,190434,190434,190434,190434,190434,190802,190802,190802,190802,191160,191160,191160,191160,191160,191160,191160,191160,191160,191160,191160,191160,191160,191160,191502,191502,191502,191502,191502,191502,191502,191502,191502,191502,191502,191502,191931,191931,191931,191931,192287,192287,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192631,192943,192943,192943,192943,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193343,193725,193725,193725,193725,193725,193725,194146,194146,194146,194146,194146,194146,194542,194542,194542,194542,194542,194542,194542,194542,194542,194542,194542,194542,194856,194856,194856,194856,194856,194856,194856,194856,194856,194856,194856,194856,195239,195239,195239,195239,195239,195239,195239,195239,195239,195239,195239,195239,195239,195239,195604,195604,195604,195604,195604,195604,195989,195989,195989,195989,196374,196374,196746,196746,196746,196746,197113,197113,197113,197113,197113,197113,197113,197113,197113,197113,197113,197113,197113,197113,197113,197113,197113,197113,197469,197469,197469,197469,197469,197469,197883,197883,197883,197883,197883,197883,197883,197883,197883,197883,197883,197883,198209,198209,198209,198209,198209,198209,198209,198209,198650,198650,198650,198650,198650,198650,199056,199056,199056,199056,199430,199430,199430,199430,199430,199430,199430,199430,199430,199430,199430,199430,199791,199791,200102,200102,200102,200102,200102,200102,200102,200102,200102,200102,200102,200102,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200503,200901,200901,200901,200901,200901,200901,200901,200901,200901,200901,200901,200901,200901,200901,200901,200901,201209,201209,201590,201590,201590,201590,201590,201590,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,201965,202311,202311,202311,202311,202311,202311,202311,202311,202311,202311,202311,202311,202311,202311,202760,202760,202760,202760,202760,202760,203124,203124,203124,203124,203124,203124,203124,203124,203124,203124,203436,203436,203436,203436,203436,203436,203436,203436,203436,203436,203436,203436,203791,203791,203791,203791,203791,203791,204176,204176,204534,204534,204534,204534,204925,204925,204925,204925,204925,204925,204925,204925,205232,205232,205232,205232,205232,205232,205232,205232,205232,205232,205575,205575,205575,205575,205575,205575,205981,205981,205981,205981,205981,205981,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206411,206801,206801,206801,206801,206801,206801,206801,206801,206801,206801,206801,206801,206801,206801,207133,207133,207133,207133,207133,207133,207528,207528,207528,207528,207869,207869,207869,207869,207869,207869,207869,207869,208229,208229,208229,208229,208229,208229,208229,208229,208229,208229,208229,208229,208561,208561,208561,208561,208561,208561,208561,208561,208561,208561,208561,208561,208561,208561,208561,208561,208561,208561,208931,208931,208931,208931,208931,208931,208931,208931,208931,208931,209256,209256,209618,209618,209618,209618,209618,209618,209618,209618,209618,209618,209950,209950,210334,210334,210334,210334,210736,210736,210736,210736,210736,210736,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211174,211572,211572,211572,211572,211572,211572,211915,211915,211915,211915,212303,212303,212303,212303,212303,212303,212303,212303,212303,212303,212303,212303,212303,212303,212685,212685,212685,212685,213111,213111,213500,213500,213500,213500,213925,213925,213925,213925,213925,213925,213925,213925,213925,213925,213925,213925,213925,213925,214258,214258,214258,214258,214258,214258,214655,214655,214655,214655,214655,214655,214655,214655,214655,214655,214655,214655,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,214980,215356,215356,215356,215356,215356,215356,215356,215356,215356,215356,215789,215789,215789,215789,215789,215789,216196,216196,216196,216196,216196,216196,216196,216196,216604,216604,216604,216604,216604,216604,216604,216604,216604,216604,216986,216986,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217358,217733,217733,217733,217733,218158,218158,218158,218158,218158,218158,218543,218543,218911,218911,218911,218911,218911,218911,218911,218911,218911,218911,218911,218911,219305,219305,219305,219305,219706,219706,219706,219706,219706,219706,219706,219706,219706,219706,219706,219706,219706,219706,220055,220055,220055,220055,220055,220055,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220509,220863,220863,220863,220863,220863,220863,220863,220863,220863,220863,220863,220863,221247,221247,221247,221247,221247,221247,221247,221247,221576,221576,221576,221576,221576,221576,221983,221983,221983,221983,221983,221983,221983,221983,221983,221983,222453,222453,222818,222818,222818,222818,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223267,223666,223666,223666,223666,223666,223666,223666,223666,223666,223666,224079,224079,224079,224079,224079,224079,224079,224079,224437,224437,224437,224437,224437,224437,224437,224437,224437,224437,224437,224437,224437,224437,224437,224437,224818,224818,225215,225215,225215,225215,225215,225215,225215,225215,225215,225215,225569,225569,225569,225569,225569,225569,225569,225569,225569,225569,225569,225569,225569,225569,225993,225993,225993,225993,226449,226449,226816,226816,226816,226816,226816,226816,226816,226816,226816,226816,226816,226816,227185,227185,227185,227185,227185,227185,227576,227576,227576,227576,227576,227576,227576,227576,227576,227576,227576,227576,227576,227576,227576,227576,228027,228027,228027,228027,228027,228027,228390,228390,228390,228390,228390,228390,228390,228390,228829,228829,228829,228829,229184,229184,229184,229184,229184,229184,229184,229184,229520,229520,229520,229520,229905,229905,229905,229905,229905,229905,230263,230263,230263,230263,230263,230263,230263,230263,230702,230702,230702,230702,230702,230702,231089,231089,231089,231089,231089,231089,231474,231474,231474,231474,231474,231474,231474,231474,231474,231474,231474,231474,231846,231846,231846,231846,231846,231846,232296,232296,232296,232296,232643,232643,232643,232643,232643,232643,233053,233053,233053,233053,233053,233053,233520,233520,233520,233520,233520,233520,233520,233520,233890,233890,233890,233890,233890,233890,233890,233890,233890,233890,233890,233890,233890,233890,233890,233890,233890,233890,234246,234246,234246,234246,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,234663,235127,235127,235127,235127,235526,235526,235526,235526,235526,235526,235526,235526,235526,235526,235526,235526,235900,235900,236229,236229,236229,236229,236229,236229,236229,236229,236229,236229,236602,236602,236602,236602,236602,236602,237063,237063,237390,237390,237390,237390,237390,237390,237390,237390,237390,237390,237732,237732,237732,237732,237732,237732,237732,237732,237732,237732,237732,237732,238079,238079,238509,238509,238509,238509,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,238899,239323,239323,239323,239323,239323,239323,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,239770,240155,240155,240155,240155,240155,240155,240577,240577,240577,240577,240980,240980,240980,240980,240980,240980,240980,240980,241356,241356,241356,241356,241356,241356,241356,241356,241356,241356,241736,241736,241736,241736,241736,241736,241736,241736,241736,241736,241736,241736,242173,242173,242173,242173,242173,242173,242506,242506,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,242875,243255,243255,243593,243593,243593,243593,243593,243593,244008,244008,244008,244008,244343,244343,244811,244811,244811,244811,244811,244811,244811,244811,244811,244811,244811,244811,244811,244811,244811,244811,245153,245153,245153,245153,245153,245153,245153,245153,245153,245153,245153,245153,245574,245574,245978,245978,245978,245978,245978,245978,246309,246309,246309,246309,246309,246309,246309,246309,246309,246309,246674,246674,246674,246674,246674,246674,246674,246674,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247120,247466,247466,247466,247466,247466,247466,247466,247466,247466,247466,247466,247466,247959,247959,247959,247959,247959,247959,248334,248334,248334,248334,248334,248334,248334,248334,248334,248334,248334,248334,248334,248334,248334,248334,248334,248334,248785,248785,248785,248785,248785,248785,249211,249211,249211,249211,249606,249606,249606,249606,249606,249606,249606,249606,249606,249606,249606,249606,249606,249606,249965,249965,249965,249965,249965,249965,250392,250392,250392,250392,250770,250770,250770,250770,250770,250770,250770,250770,250770,250770,250770,250770,251231,251231,251231,251231,251231,251231,251231,251231,251655,251655,251655,251655,251655,251655,252109,252109,252109,252109,252109,252109,252109,252109,252109,252109,252109,252109,252501,252501,252501,252501,252903,252903,252903,252903,252903,252903,253284,253284,253284,253284,253284,253284,253284,253284,253284,253284,253284,253284,253670,253670,253670,253670,253670,253670,254100,254100,254100,254100,254100,254100,254100,254100,254100,254100,254100,254100,254479,254479,254846,254846,254846,254846,254846,254846,254846,254846,254846,254846,254846,254846,254846,254846,254846,254846,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255331,255745,255745,255745,255745,256132,256132,256541,256541,256541,256541,256541,256541,256541,256541,256541,256541,257020,257020,257020,257020,257020,257020,257020,257020,257020,257020,257020,257020,257020,257020,257020,257020,257020,257020,257409,257409,257409,257409,257409,257409,257409,257409,257783,257783,257783,257783,258204,258204,258204,258204,258204,258204,258204,258204,258204,258204,258204,258204,258204,258204,258631,258631,258631,258631,259027,259027,259436,259436,259436,259436,259436,259436,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,259854,260196,260196,260196,260196,260196,260196,260675,260675,260675,260675,260675,260675,260675,260675,260675,260675,260675,260675,260675,260675,261083,261083,261083,261083,261083,261083,261554,261554,261554,261554,261554,261554,261973,261973,261973,261973,261973,261973,261973,261973,261973,261973,262445,262445,262445,262445,262445,262445,262872,262872,263250,263250,263250,263250,263250,263250,263250,263250,263250,263250,263612,263612,264080,264080,264080,264080,264497,264497,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,264916,265324,265324,265742,265742,265742,265742,266217,266217,266217,266217,266217,266217,266646,266646,266646,266646,266646,266646,267037,267037,267037,267037,267037,267037,267037,267037,267037,267037,267037,267037,267426,267426,267426,267426,267426,267426,267852,267852,267852,267852,267852,267852,267852,267852,267852,267852,267852,267852,267852,267852,268223,268223,268223,268223,268223,268223,268223,268223,268223,268223,268598,268598,268598,268598,268598,268598,268598,268598,268598,268598,268598,268598,269021,269021,269021,269021,269021,269021,269418,269418,269418,269418,269418,269418,269418,269418,269849,269849,269849,269849,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270308,270764,270764,270764,270764,270764,270764,270764,270764,270764,270764,270764,270764,270764,270764,271141,271141,271141,271141,271141,271141,271141,271141,271141,271141,271141,271141,271587,271587,271587,271587,271587,271587,271971,271971,271971,271971,272415,272415,272415,272415,272415,272415,272824,272824,273206,273206,273206,273206,273206,273206,273206,273206,273206,273206,273206,273206,273695,273695,273695,273695,273695,273695,274136,274136,274136,274136,274136,274136,274136,274136,274136,274136,274136,274136,274526,274526,274526,274526,274526,274526,274526,274526,274526,274526,274526,274526,274526,274526,274526,274526,275007,275007,275410,275410,275410,275410,275410,275410,275410,275410,275410,275410,275789,275789,275789,275789,275789,275789,275789,275789,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276237,276656,276656,277076,277076,277076,277076,277076,277076,277076,277076,277076,277076,277076,277076,277542,277542,277542,277542,277542,277542,277917,277917,277917,277917,278373,278373,278373,278373,278373,278373,278777,278777,278777,278777,278777,278777,278777,278777,278777,278777,278777,278777,278777,278777,278777,278777,278777,278777,279225,279225,279659,279659,279659,279659,279659,279659,279659,279659,279659,279659,279659,279659,280056,280056,280056,280056,280056,280056,280499,280499,280499,280499,280872,280872,280872,280872,280872,280872,280872,280872,280872,280872,280872,280872,281366,281366,281366,281366,281366,281366,281366,281366,281771,281771,281771,281771,281771,281771,282212,282212,282212,282212,282212,282212,282212,282212,282212,282212,282212,282212,282586,282586,282586,282586,283042,283042,283042,283042,283042,283042,283463,283463,283463,283463,283463,283463,283463,283463,283463,283463,283463,283463,283881,283881,283881,283881,283881,283881,284321,284321,284723,284723,284723,284723,284723,284723,284723,284723,284723,284723,284723,284723,285096,285096,285096,285096,285096,285096,285096,285096,285096,285096,285096,285096,285548,285548,285548,285548,286055,286055,286055,286055,286055,286055,286055,286055,286055,286055,286055,286055,286055,286055,286458,286458,286458,286458,286458,286458,286903,286903,286903,286903,286903,286903,286903,286903,286903,286903,286903,286903,286903,286903,286903,286903,287364,287364,287364,287364,287364,287364,287792,287792,288196,288196,288196,288196,288196,288196,288196,288196,288196,288196,288588,288588,288588,288588,288588,288588,288588,288588,288975,288975,288975,288975,288975,288975,288975,288975,288975,288975,288975,288975,288975,288975,288975,288975,288975,288975,289417,289417,289417,289417,289417,289417,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,289843,290408,290408,290769};
void euler_prime() {
vis[0]=1;
vis[1]=1;
for (int i=2;i<N;i++) {
if (!vis[i]) {
p[cnt++]=i;
}
for (int j=0;j<cnt&&p[j]*i<N;j++) {
vis[p[j]*i]=1;
if (i%p[j]==0) {
break;
}
}
}
}
bool isprime( int num )
{
if(num ==2|| num==3 )
return 1 ;
if(num %6!= 1&&num %6!= 5)
return 0 ;
int tmp =sqrt(num);
for(int i= 5; i <=tmp; i+=6 )
if(num %i== 0||num %(i+ 2)==0)
return 0 ;
return 1 ;
}
bool isyltx(int x,int y) {
int index=x*y-3*(x-y);
index=(index>=0?index:0);
if (index<N) {
return !vis[index];
}
else {
return isprime(index);
}
return false;
}
int main()
{
euler_prime();
for (int i=0;i<cnt;i++) {
for (int j=i+1;j<cnt;j++) {
int x=p[i];
int y=p[j];
if (isyltx(x,y)) {
f[y]++;
}
swap(x,y);
if (isyltx(x,y)) {
f[x]++;
}
}
}
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
for (int i=1;i<N;i++) {
f[i]+=f[i-1];
}
// for (int i=5000;i
// printf("%d,",f[i]);
// }
int T,Q;
scanf("%d",&T);
while (T--) {
scanf("%d",&Q);
if (Q<5000) {
printf("%d\n",f[Q]);
}
else {
printf("%d\n",a[Q-5000]);
}
}
return 0;
}