博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2012 Multi-University Training Contest 9 / hdu4389
阅读量:5888 次
发布时间:2019-06-19

本文共 17991 字,大约阅读时间需要 59 分钟。

打巨表,实为数位dp 还不太懂 先这样放着。。

对于打表,当然我们不能直接打,这里有技巧。我们可以这样:每隔100000我们统计一次,这样在10^9范围内,我们得到10000个数。

然后就很好解决了。。。

数位dp:

1 #include
2 #include
3 usingnamespace std; 4 int list[10001]={
0,11872,11166,10611,10042,9549,9104,8717,8433,8098,7836,11226,10597,10102,9573,9123,8704,8346,8116,7800,7546,10653,10105,9662,9161,8747,8384,8034,7815,7530,7312,10138,9647,9250,8778,8423,8066,7736,7558,7302,7061,9689,9230,8902,8452,8109,7797,7477,7327,7055,6834,9271,8869,8595,8175,7848,7568,7277,7093,6857,6640,8896,8548,8289,7906,7609,7342,7079,6861,6679,6469,8575,8230,8021,7661,7400,7115,6876,6699,6494,6290,8223,7935,7744,7430,7170,6931,6710,6499,6291,6136,7913,7675,7495,7183,6974,6746,6550,6325,6147,5991,11191,10626,10014,9579,9116,8727,8380,8101,7827,7572,10599,10131,9555,9131,8742,8362,8034,7811,7544,7320,10116,9673,9144,8760,8411,8038,7739,7555,7287,7071,9662,9269,8782,8419,8084,7757,7465,7310,7050,6849,9253,8932,8469,8111,7823,7502,7229,7067,6840,6645,8901,8613,8196,7831,7577,7294,7006,6863,6656,6435,8569,8302,7941,7600,7335,7077,6836,6676,6447,6270,8262,8050,7692,7381,7135,6906,6657,6475,6311,6110,7971,7763,7438,7138,6938,6708,6488,6286,6130,5957,7695,7514,7205,6935,6747,6526,6340,6142,5957,5804,10631,10033,9541,9142,8750,8400,8057,7831,7590,7341,10133,9551,9114,8754,8388,8063,7754,7543,7314,7101,9694,9163,8738,8420,8068,7782,7485,7293,7086,6884,9286,8802,8412,8076,7791,7492,7229,7059,6854,6666,8941,8497,8119,7809,7536,7241,6984,6846,6624,6457,8621,8218,7881,7558,7307,7056,6795,6643,6443,6293,8324,7959,7631,7334,7097,6855,6612,6472,6285,6100,8058,7702,7418,7115,6916,6672,6448,6297,6122,5931,7784,7444,7197,6907,6696,6514,6283,6120,5933,5786,7547,7240,6985,6706,6519,6362,6131,5943,5823,5681,10034,9545,9117,8764,8406,8097,7788,7584,7361,7158,9574,9121,8714,8404,8078,7800,7501,7317,7124,6908,9171,8754,8390,8084,7791,7503,7251,7082,6898,6689,8832,8421,8071,7809,7502,7254,7003,6840,6667,6505,8516,8162,7816,7534,7271,7029,6780,6620,6467,6301,8228,7902,7572,7311,7072,6814,6599,6449,6288,6116,7975,7651,7369,7095,6869,6632,6444,6278,6076,5948,7707,7446,7174,6885,6686,6495,6279,6121,5944,5813,7478,7206,6944,6681,6522,6307,6092,5953,5814,5630,7256,6978,6770,6502,6331,6131,5967,5800,5646,5522,9538,9112,8706,8419,8118,7813,7539,7370,7160,7026,9114,8709,8351,8077,7797,7532,7274,7130,6896,6812,8759,8388,8060,7790,7505,7301,7011,6879,6703,6596,8439,8089,7762,7509,7263,7035,6769,6646,6502,6378,8153,7824,7531,7284,7027,6802,6572,6447,6263,6195,7892,7574,7309,7061,6812,6631,6396,6235,6090,6035,7653,7377,7074,6852,6653,6448,6220,6086,5934,5856,7435,7170,6907,6676,6483,6269,6085,5945,5777,5728,7192,6951,6726,6468,6294,6116,5919,5784,5628,5598,6993,6781,6547,6273,6129,5966,5768,5629,5511,5454,9121,8722,8369,8120,7840,7583,7351,7164,7036,6809,8717,8374,8027,7800,7550,7308,7058,6939,6822,6574,8396,8049,7760,7527,7300,7056,6821,6701,6604,6382,8096,7770,7511,7261,7035,6835,6584,6471,6372,6210,7834,7529,7279,7033,6816,6639,6363,6245,6200,6013,7597,7301,7054,6829,6617,6427,6201,6077,6003,5855,7378,7083,6880,6643,6430,6249,6057,5895,5836,5728,7173,6915,6690,6455,6263,6099,5914,5757,5729,5615,6966,6736,6505,6268,6102,5917,5739,5615,5572,5456,6772,6544,6351,6124,5926,5774,5631,5475,5426,5342,8740,8376,8037,7881,7591,7360,7161,7060,6806,6566,8369,8038,7748,7565,7330,7102,6907,6825,6591,6406,8070,7774,7487,7298,7085,6877,6653,6606,6388,6224,7790,7503,7234,7048,6846,6639,6408,6393,6186,6017,7529,7276,7035,6831,6636,6437,6218,6167,5990,5855,7314,7056,6848,6607,6438,6271,6028,5983,5852,5733,7119,6857,6641,6441,6236,6084,5852,5833,5738,5589,6934,6696,6478,6276,6090,5901,5730,5693,5569,5491,6727,6522,6332,6084,5894,5777,5606,5532,5443,5380,6569,6369,6160,5927,5768,5627,5446,5397,5323,5258,8397,8064,7792,7619,7395,7199,7045,6814,6626,6409,8059,7763,7472,7354,7131,6943,6798,6606,6421,6210,7766,7493,7241,7102,6892,6692,6583,6393,6221,6037,7497,7257,7009,6845,6669,6494,6350,6176,6020,5906,7275,7043,6796,6616,6485,6300,6131,6014,5866,5733,7048,6827,6612,6431,6251,6083,5954,5859,5724,5592,6839,6636,6456,6242,6074,5907,5805,5690,5582,5499,6684,6486,6299,6068,5916,5781,5639,5571,5492,5395,6519,6309,6119,5923,5775,5612,5502,5439,5359,5276,6330,6139,5990,5769,5620,5474,5410,5308,5218,5164,8084,7798,7539,7402,7186,7070,6791,6598,6416,6179,7772,7498,7276,7134,6927,6847,6583,6384,6222,6036,7506,7263,7037,6891,6707,6633,6356,6195,6066,5868,7271,7008,6776,6679,6491,6396,6148,6007,5875,5717,7034,6821,6603,6465,6274,6216,5991,5847,5725,5607,6816,6635,6422,6244,6093,6021,5795,5712,5618,5505,6644,6439,6243,6064,5918,5847,5647,5584,5486,5383,6459,6272,6100,5917,5751,5691,5538,5454,5365,5290,6267,6117,5964,5734,5603,5583,5410,5310,5266,5174,6145,5974,5803,5607,5477,5439,5299,5215,5163,5064,7815,7567,7333,7181,7079,6827,6577,6373,6217,6025,7535,7296,7069,6940,6840,6621,6363,6222,6029,5848,7278,7036,6848,6736,6605,6421,6184,6032,5877,5727,7039,6811,6619,6485,6383,6238,5983,5845,5732,5601,6846,6617,6420,6286,6218,6036,5826,5718,5591,5477,6654,6422,6243,6103,6006,5854,5695,5597,5466,5396,6423,6250,6073,5921,5839,5719,5551,5453,5368,5285,6268,6100,5903,5740,5718,5577,5404,5337,5274,5194,6117,5909,5766,5617,5560,5430,5307,5257,5156,5073,5947,5797,5656,5463,5406,5352,5213,5139,5069,4986,11210,10580,10138,9564,9099,8711,8418,8075,7804,7550,10652,10078,9677,9162,8740,8368,8104,7804,7511,7286,10137,9635,9258,8794,8393,8047,7832,7540,7274,7033,9665,9241,8907,8471,8118,7782,7576,7312,7065,6834,9253,8855,8578,8178,7849,7537,7323,7101,6851,6596,8866,8520,8271,7923,7587,7319,7119,6890,6647,6400,8532,8218,8014,7671,7374,7143,6913,6687,6508,6227,8224,7930,7728,7445,7166,6936,6724,6527,6338,6065,7918,7646,7472,7233,6958,6730,6530,6349,6151,5933,7622,7400,7224,7020,6761,6576,6370,6159,6002,5806,10598,10100,9580,9128,8710,8362,8097,7787,7531,7308,10109,9666,9173,8764,8372,8031,7827,7514,7301,7069,9657,9257,8786,8431,8075,7742,7539,7272,7051,6833,9255,8899,8478,8135,7808,7478,7319,7066,6819,6616,8878,8594,8172,7872,7547,7263,7099,6845,6637,6429,8538,8296,7910,7604,7351,7050,6878,6668,6465,6219,8248,8019,7656,7384,7130,6867,6687,6502,6293,6037,7967,7753,7438,7190,6921,6700,6530,6326,6136,5889,7685,7526,7197,6965,6742,6542,6334,6143,5999,5763,7423,7264,6956,6775,6568,6355,6176,5997,5847,5624,10111,9560,9150,8734,8378,8054,7798,7534,7325,7106,9678,9141,8779,8393,8064,7750,7524,7294,7061,6861,9274,8784,8433,8101,7759,7463,7281,7040,6823,6634,8919,8484,8131,7827,7522,7240,7066,6819,6650,6420,8611,8192,7855,7585,7306,6997,6860,6652,6451,6225,8318,7928,7591,7343,7093,6810,6661,6471,6255,6057,8031,7707,7386,7127,6885,6660,6488,6288,6111,5880,7777,7480,7159,6933,6739,6478,6304,6153,5970,5710,7536,7229,6957,6750,6543,6313,6157,5990,5812,5608,7271,7010,6740,6547,6356,6197,5990,5825,5688,5496,9554,9104,8766,8394,8068,7768,7535,7326,7095,6933,9159,8741,8437,8073,7774,7496,7283,7062,6888,6693,8797,8413,8104,7786,7509,7232,7033,6829,6660,6447,8498,8114,7847,7532,7266,6999,6845,6637,6455,6241,8218,7866,7576,7322,7033,6806,6651,6431,6279,6069,7946,7636,7335,7088,6860,6607,6462,6261,6122,5866,7718,7412,7129,6907,6685,6432,6299,6129,5942,5709,7472,7214,6944,6725,6502,6290,6151,5962,5817,5582,7242,7009,6719,6534,6353,6143,5965,5823,5678,5438,7021,6794,6532,6349,6191,5985,5832,5708,5556,5325,9104,8721,8405,8072,7798,7498,7311,7112,6921,6843,8745,8363,8097,7790,7521,7235,7067,6870,6675,6613,8407,8071,7807,7502,7253,6999,6835,6651,6455,6385,8121,7803,7547,7271,7025,6791,6612,6440,6297,6160,7892,7556,7297,7069,6820,6579,6441,6259,6104,5969,7640,7331,7091,6863,6623,6407,6266,6081,5922,5820,7430,7152,6880,6682,6463,6265,6095,5919,5796,5657,7214,6962,6686,6515,6307,6096,5948,5799,5656,5510,7002,6764,6509,6349,6136,5940,5805,5670,5503,5400,6783,6593,6326,6152,5997,5828,5679,5536,5395,5302,8706,8349,8105,7812,7548,7285,7119,6916,6804,6638,8387,8051,7801,7529,7294,7035,6874,6696,6600,6417,8056,7771,7504,7263,7050,6769,6630,6486,6369,6176,7807,7509,7297,7023,6819,6567,6452,6271,6167,5989,7572,7304,7082,6828,6625,6390,6244,6075,6003,5849,7363,7083,6851,6643,6442,6225,6065,5920,5870,5661,7149,6890,6663,6479,6273,6035,5915,5772,5716,5526,6965,6708,6511,6290,6103,5917,5782,5618,5575,5421,6783,6567,6295,6135,5971,5778,5638,5502,5469,5296,6598,6384,6128,5974,5821,5639,5528,5396,5345,5178,8369,8034,7822,7572,7319,7097,6924,6815,6606,6406,8044,7739,7539,7315,7075,6823,6711,6606,6383,6224,7766,7483,7280,7041,6826,6602,6475,6377,6185,6040,7512,7266,7036,6819,6637,6389,6242,6184,6021,5840,7303,7056,6831,6627,6437,6188,6072,6011,5853,5694,7082,6854,6657,6433,6252,6031,5898,5820,5695,5581,6898,6688,6471,6254,6101,5903,5739,5688,5589,5427,6732,6505,6275,6120,5928,5740,5618,5550,5478,5301,6547,6352,6133,5945,5776,5603,5491,5414,5332,5209,6386,6194,5964,5804,5643,5509,5367,5324,5236,5099,8035,7734,7599,7348,7125,6927,6839,6601,6391,6259,7771,7467,7322,7089,6890,6696,6598,6396,6228,6060,7493,7223,7043,6866,6659,6423,6377,6209,6022,5887,7259,7007,6840,6639,6454,6219,6194,6004,5850,5749,7058,6839,6647,6443,6277,6038,5988,5838,5728,5604,6851,6639,6435,6264,6109,5851,5825,5727,5586,5440,6664,6467,6271,6104,5924,5717,5688,5572,5477,5344,6492,6308,6112,5918,5786,5592,5547,5436,5377,5247,6347,6155,5935,5779,5644,5474,5410,5325,5252,5125,6207,6004,5800,5654,5491,5338,5316,5225,5136,5037,7775,7490,7347,7125,6960,6824,6579,6428,6210,6039,7486,7233,7104,6901,6704,6588,6402,6210,6035,5902,7238,6996,6860,6647,6492,6354,6182,6018,5880,5746,7032,6784,6632,6457,6292,6140,5976,5863,5753,5593,6843,6611,6445,6283,6097,5952,5849,5712,5587,5473,6621,6449,6264,6088,5916,5808,5700,5570,5480,5361,6456,6285,6068,5912,5788,5664,5544,5470,5387,5245,6299,6107,5919,5772,5628,5515,5425,5372,5264,5140,6121,5972,5789,5635,5483,5403,5319,5236,5162,5039,5987,5847,5654,5485,5383,5304,5200,5135,5077,4939,7498,7278,7139,6929,6848,6604,6399,6208,6013,5902,7263,7020,6907,6697,6636,6383,6199,6050,5871,5751,7017,6778,6666,6500,6390,6142,6001,5890,5720,5589,6805,6587,6475,6278,6199,5974,5848,5717,5600,5479,6641,6424,6286,6096,6037,5823,5684,5589,5487,5368,6467,6224,6072,5934,5863,5656,5560,5481,5368,5235,6271,6078,5929,5774,5706,5528,5453,5365,5263,5172,6110,5940,5765,5607,5573,5428,5331,5239,5194,5070,5963,5801,5615,5474,5456,5286,5216,5155,5070,4984,5829,5676,5508,5373,5316,5185,5117,5049,4969,4867,10641,10122,9680,9142,8727,8421,8097,7782,7521,7291,10126,9646,9266,8784,8398,8115,7800,7513,7271,7051,9673,9234,8903,8476,8106,7843,7562,7292,7012,6827,9227,8872,8578,8173,7839,7620,7349,7077,6817,6654,8850,8523,8285,7882,7594,7383,7118,6887,6620,6451,8511,8198,8017,7655,7374,7160,6909,6720,6429,6264,8177,7917,7760,7430,7143,6957,6723,6525,6255,6111,7896,7644,7537,7211,6963,6780,6542,6350,6111,5949,7624,7356,7275,7004,6763,6571,6371,6191,5964,5807,7366,7106,7040,6819,6582,6389,6223,6039,5803,5705,10087,9685,9175,8745,8371,8095,7776,7512,7291,7057,9636,9277,8801,8419,8030,7818,7526,7244,7032,6819,9232,8917,8480,8121,7792,7566,7303,7021,6832,6618,8875,8598,8185,7854,7536,7340,7098,6853,6606,6436,8529,8272,7917,7600,7298,7114,6890,6667,6408,6251,8215,8020,7665,7383,7101,6920,6703,6473,6241,6090,7936,7748,7450,7150,6934,6712,6514,6334,6075,5907,7663,7485,7248,6977,6735,6548,6352,6190,5911,5766,7401,7234,7015,6772,6551,6386,6186,5994,5798,5669,7166,7000,6795,6572,6396,6217,6027,5883,5697,5539,9661,9191,8769,8395,8044,7807,7512,7272,7072,6870,9247,8805,8441,8080,7752,7526,7253,7038,6831,6630,8914,8477,8131,7827,7483,7305,7048,6825,6601,6424,8600,8200,7862,7561,7250,7106,6861,6626,6424,6256,8299,7927,7605,7338,7047,6877,6667,6452,6247,6058,8048,7661,7385,7147,6861,6678,6493,6301,6029,5914,7757,7448,7179,6938,6665,6522,6334,6133,5883,5765,7522,7222,6981,6757,6546,6350,6156,5998,5749,5627,7290,6976,6774,6566,6366,6170,6013,5869,5612,5496,7049,6761,6600,6390,6189,6027,5890,5733,5514,5418,9140,8784,8420,8066,7767,7509,7274,7073,6864,6706,8768,8449,8102,7775,7475,7286,7026,6824,6632,6473,8475,8152,7829,7508,7242,7066,6821,6635,6438,6247,8197,7879,7580,7295,7010,6849,6640,6467,6233,6051,7938,7605,7367,7080,6804,6662,6465,6269,6046,5889,7698,7405,7145,6897,6638,6500,6287,6110,5890,5734,7469,7179,6927,6721,6494,6303,6144,5964,5721,5584,7249,6966,6769,6557,6337,6159,6008,5848,5580,5468,7016,6768,6572,6371,6171,6008,5856,5704,5489,5366,6814,6578,6369,6193,6046,5853,5713,5614,5404,5251,8726,8439,8078,7783,7491,7293,7060,6857,6723,6633,8386,8108,7786,7496,7237,7021,6818,6637,6481,6381,8114,7826,7541,7257,6992,6819,6623,6441,6238,6182,7848,7591,7321,7039,6779,6647,6428,6272,6088,6003,7611,7353,7099,6837,6594,646638,5476,5424,5351,5210,5129,5063,5919,5819,5680,5502,5359,5327,5227,5091,5022,4961,5820,5697,5564,5410,5277,5224,5127,5020,4968,4882,5711,5575,5457,5365,5163,5114,5030,4937,4858,4771,5557,5471,5360,5251,5068,5038,4963,4837,4771,4684,5462,5374,5245,5137,4978,4942,4837,4740,4693,4588,5356,5242,5140,5066,4907,4825,4731,4649,4583,4500,6448,6246,6080,5878,5843,5720,5596,5436,5360,5251,6271,6069,5906,5755,5691,5563,5482,5349,5238,5168,6068,5905,5767,5605,5530,5443,5370,5216,5139,5079,5917,5782,5621,5453,5427,5324,5242,5112,5054,4974,5801,5656,5502,5367,5316,5196,5150,5040,4934,4896,5658,5552,5426,5268,5194,5127,5042,4948,4894,5614,5,5512,5380,5276,5154,5027,4903,4856,4752,4651,4587,5356,5257,5185,5027,4940,4829,4732,4634,4567,4474,6482,6276,6068,5946,5789,5726,5535,544。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。8,4977,5879,5706,5528,5435,5322,5181,5089,5042,4984,4875,5724,5591,5433,5331,5189,5089,5022,4934,4874,4792,5607,5508,5350,5213,5103,5007,4929,4854,4784,4687,5490,5396,5217,5122,5005,4927,4818,4750,4685,4587,5399,5270,5126,5035,4940,4840,4735,4658,4555,4462,5260,5174,5050,4931,4813,4771,4636,4550,4494,4380,5172,5072,4946,4840,4724,4641,4543,4447,4376,4296,6094,5926,5784,5611,5584,5421,5328,5235,5139,5073,5960,5783,5642,5474,5456,5285,5211,5162,5047,4959,5827,5638,5507,5396,5325,5175,5114,5043,4957,4884,5692,5541,5404,5296,5224,5092,5035,4947,4872,4787,5583,5456,5304,5173,5156,5001,4911,4879,4794,4686,5491,5339,5210,5111,5043,4910,4855,4776,4683,4608,5353,5254,5111,4998,4951,4809,4743,4677,4565,4502,5249,5176,5017,4898,4861,4741,4632,4567,4498,4405,5191,5059,4922,4832,4771,4619,4564,4488,4383,4317,5055,4974,4857,4715,4646,4545,4440,4390,4304,4207,7896,7662,7512,7221,6927,6765,6570,6329,6128,5961,7641,7419,7264,7008,6759,6573,6383,6207,5955,5812,7377,7165,7051,6826,6571,6402,6243,6070,5809,5673,7122,6928,6836,6609,6382,6253,6079,5930,5684,5563,6893,6688,6608,6388,6220,6058,5905,5797,5572,5455,6671,6415,6389,6213,6027,5894,5760,5660,5438,5340,6457,6215,6167,6015,5855,5741,5629,5494,5356,5262,6279,6037,5995,5837,5722,5603,5487,5378,5242,5165,6109,5859,5817,5721,5602,5452,5367,5287,5140,5047,5929,5717,5700,5591,5465,5341,5271,5172,5041,4984,7672,7503,7215,6981,6695,6534,6341,6160,5938,5773,7410,7273,7003,6787,6524,6375,6194,6003,5789,5671,7174,7054,6794,6579,6373,6213,6049,5883,5680,5543,6951,6822,6589,6413,6218,6036,5902,5779,5543,5431,6705,6589,6391,6216,6029,5893,5782,5647,5431,5341,6470,6357,6182,6008,5867,5741,5619,5508,5344,5227,6292,6136,5989,5858,5742,5586,5498,5400,5218,5112,6106,5942,5829,5729,5593,5469,5389,5288,5134,5024,5905,5794,5700,5577,5467,5366,5267,5150,5048,4951,5786,5652,5539,5459,5388,5237,5154,5077,4973,4854,7500,7220,6976,6727,6481,6349,6136,5968,5792,5637,7284,6994,6775,6561,6312,6170,5981,5847,5655,5500,7065,6778,6602,6412,6170,6019,5890,5744,5503,5404,6838,6590,6408,6222,6001,5901,5761,5618,5432,5310,6621,6381,6187,6040,5883,5733,5606,5508,5339,5212,6407,6151,5997,5870,5730,5599,5491,5393,5192,5100,6206,5962,5848,5716,5573,5495,5379,5271,5113,5026,6028,5826,5687,5594,5494,5375,5248,5176,5036,4931,5865,5634,5562,5467,5372,5248,5162,5075,4935,4833,5702,5518,5461,5361,5243,5158,5080,4978,4854,4767,7222,6969,6768,6534,6290,6127,5965,5810,5615,5483,6993,6768,6582,6364,6120,5995,5830,5664,5496,5374,6808,6594,6392,6193,6002,5869,5709,5557,5417,5260,6627,6375,6225,6079,5850,5720,5613,5485,5293,5161,6413,6176,6036,5887,5705,5602,5495,5363,5194,5101,6226,5998,5848,5721,5582,5487,5366,5257,5102,4983,6056,5823,5704,5594,5470,5334,5262,5165,4993,4885,5890,5661,5582,5479,5361,5247,5173,5074,4921,4825,5736,5556,5438,5352,5274,5163,5040,4959,4832,4721,5598,5425,5329,5245,5183,5062,4961,4881,4756,4619,6946,6788,6541,6349,6104,5946,5794,5646,5494,5427,6771,6578,6359,6196,5970,5818,5663,5555,5361,5303,6579,6380,6223,6038,5820,5716,5562,5441,5259,5204,6396,6212,6042,5885,5706,5602,5452,5338,5185,5124,6239,6025,5867,5764,5599,5472,5353,5249,5087,5022,6053,5843,5715,5606,5445,5363,5250,5137,4971,4937,5886,5705,5590,5463,5323,5253,5161,5028,4891,4859,5759,5584,5453,5374,5260,5148,5034,4967,4811,4735,5611,5434,5342,5271,5158,5041,4978,4863,4716,4646,5476,5326,5248,5153,5056,4974,4871,4766,4615,4557,6737,6548,6365,6171,5919,5778,5648,5487,5403,5345,6544,6368,6183,6009,5788,5666,5517,5370,5294,5220,6383,6209,6020,5859,5688,5557,5411,5308,5201,5110,6217,6020,5892,5755,5566,5433,5326,5208,5107,5016,6044,5865,5757,5600,5440,5350,5240,5110,5020,4957,5889,572123,4,677,4600,4501,5276,5114,5023,4943,4811,4718,4662,4566,4471,4414,5163,5057,4949,4822,4737,4624,4548,4481,4401,4325,5085,4942,4860,4727,4644,4537,4456,4365,4294,4226,4999,4872,4757,4647,4567,4429,4387,4304,4190,4129}; 5 int f(int x) 6 { 7 if(x==0) 8 return0; 9 int sum=0;10 while(x)11 {12 sum+=x%10;13 x/=10;14 }15 return sum;16 }17 int main()18 {19 int num,i,j,t,a,b;20 scanf("%d",&t);21 int k=0;22 while(t--)23 {24 scanf("%d%d",&a,&b);25 int sum=0;26 if(b-a>100000)27 {28 int x=(a+99999)/100000;29 int y=b/100000;30 for(i=x+1;i<=y;i++)31 sum+=list[i];32 x=x*100000;33 for(i=a;i<=x;i++)34 {35 if(i%f(i)==0)36 sum++;37 }38 //if(a%100000==0&&a%f(a)==0)39 // sum++;40 y=y*100000;41 for(i=y+1;i<=b;i++)42 {43 if(i%f(i)==0)44 sum++;45 }46 //if(b%100000==0&&b%f(b)==0)47 // sum--;48 //49 }50 else51 {52 for(i=a;i<=b;i++)53 if(i%f(i)==0)54 sum++;55 }56 printf("Case %d: %d\n",++k,sum);57 }58 return0;59 }

 

转载于:https://www.cnblogs.com/haohaooo/p/4035355.html

你可能感兴趣的文章
keystone 手动建立租户,用户,角色,服务,端口
查看>>
排序之快速排序
查看>>
Win32编程day07 学习笔记
查看>>
PYTHON2.day09
查看>>
PYTHON2.day05
查看>>
ocp题库更新,052最新考试题及答案整理-31
查看>>
Git-常用命令集合
查看>>
最近学习到的一些
查看>>
Windows环境下免安装版MySQL 5.6.11安装配置详解
查看>>
leetcode记录-反转整数
查看>>
matlab-画个拱桥和倒影?
查看>>
8.5 exit函数-进程控制
查看>>
安装SeleniumIDE(基于Ubuntu Desktop 12.04 LTS)
查看>>
效率和协作工具--OneNote
查看>>
在Ubuntu 14.04 64bit上安装numpy和matplotlib库
查看>>
JSK-61 二进制加法【大数】
查看>>
HDU1877 又一版 A+B
查看>>
@ 添加属性(属性注入)
查看>>
往sde中导入要素类报错000732
查看>>
sql基本运算
查看>>