题目:X mod f(x)
题意:问在区间[A,B]之间,有多少个数满足,x%f(x)=0,f(x)代表x的各位数字之和。
解析:本题一是可以通过打表来计算,二是可以通过数位DP来求解。
我们先来说打表吧。。。
对于打表,当然我们不能直接打,这里有技巧。我们可以这样:每隔100000我们统计一次,这样在10^9范围内,我们得到10000个数。
然后就很好解决了。。。
#include <iostream> #include <string.h> #include <stdio.h> using namespace std; int f(int x) { if(x==0) return 0; return f(x/10)+x%10; } int t,a,b; int r[]={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,6466,6235,6090,5900,5818,7399,7114,6902,6673,6420,6274,6104,5926,5713,5662,7187,6909,6722,6496,6261,6136,5951,5782,5571,5534,6993,6748,6537,6354,6126,5997,5818,5676,5459,5384,6795,6530,6351,6191,5972,5817,5703,5574,5343,5285,6603,6355,6194,6023,5832,5711,5568,5441,5238,5221,8368,8094,7801,7533,7262,7051,6889,6678,6615,6427,8056,7814,7515,7266,6989,6840,6648,6445,6379,6222,7803,7561,7266,7039,6780,6607,6444,6261,6190,6018,7553,7323,7062,6825,6586,6410,6263,6095,5977,5844,7333,7091,6882,6642,6386,6246,6088,5911,5812,5699,7131,6897,6679,6460,6236,6104,5902,5755,5675,5543,6945,6689,6484,6305,6090,5933,5780,5634,5511,5390,6767,6509,6348,6149,5927,5806,5671,5509,5394,5316,6606,6336,6180,5991,5797,5682,5526,5404,5302,5215,6436,6173,5992,5859,5697,5539,5432,5318,5199,5102,8038,7824,7539,7297,7055,6900,6690,6597,6434,6231,7752,7535,7268,7061,6798,6628,6475,6369,6209,6030,7498,7294,7043,6838,6571,6428,6276,6165,6000,5894,7291,7101,6833,6627,6383,6253,6076,5984,5847,5735,7083,6887,6632,6461,6216,6051,5902,5853,5677,5564,6883,6668,6468,6284,6045,5919,5771,5704,5526,5452,6704,6507,6296,6090,5889,5772,5624,5572,5406,5331,6553,6316,6145,5960,5776,5644,5486,5468,5291,5190,6394,6147,5967,5837,5639,5512,5396,5340,5188,5111,6221,5996,5850,5702,5532,5405,5285,5227,5098,5050,7735,7554,7328,7089,6855,6716,6631,6393,6233,6090,7462,7293,7082,6830,6622,6487,6374,6187,6056,5912,7263,7048,6835,6642,6402,6267,6161,6011,5885,5744,7037,6851,6635,6475,6198,6061,6014,5851,5709,5609,6841,6659,6469,6264,6036,5909,5848,5700,5568,5495,6684,6483,6264,6098,5886,5745,5691,5585,5444,5375,6499,6293,6105,5931,5744,5602,5559,5467,5305,5241,6323,6135,5978,5799,5604,5483,5452,5339,5213,5156,6184,5990,5832,5660,5519,5381,5312,5223,5119,5041,6042,5823,5688,5564,5391,5269,5217,5136,5015,4944,7472,7328,7085,6881,6710,6613,6397,6212,6064,5913,7209,7062,6852,6661,6440,6369,6184,6009,5886,5750,6993,6826,6651,6453,6216,6174,6002,5840,5730,5626,6814,6645,6465,6263,6045,5997,5828,5699,5596,5495,6647,6451,6261,6116,5856,5817,5698,5582,5464,5356,6461,6281,6112,5942,5695,5668,5600,5457,5346,5261,6300,6120,5939,5777,5568,5538,5440,5364,5246,5168,6144,5950,5774,5663,5474,5413,5316,5259,5131,5033,5993,5796,5667,5551,5339,5309,5222,5147,5021,4970,5871,5683,5546,5411,5272,5225,5110,5042,4949,4872,7231,7102,6891,6719,6594,6385,6220,6027,5887,5783,6980,6869,6673,6469,6375,6191,6023,5849,5741,5626,6784,6639,6460,6286,6160,5984,5842,5737,5599,5480,6584,6439,6275,6113,5951,5820,5712,5577,5475,5378,6425,6282,6114,5919,5782,5695,5564,5445,5373,5280,6293,6109,5932,5793,5650,5549,5447,5374,5256,5157,6116,5922,5776,5659,5507,5417,5355,5268,5139,5070,5950,5785,5663,5497,5382,5319,5237,5159,5042,4987,5829,5658,5518,5392,5306,5211,5124,5048,4953,4872,5732,5529,5396,5293,5205,5104,5053,5005,4854,4791,10141,9644,9260,8771,8436,8102,7799,7487,7267,7032,9683,9235,8900,8452,8166,7846,7541,7269,7055,6821,9267,8864,8580,8159,7908,7601,7323,7055,6843,6642,8865,8527,8263,7906,7644,7370,7134,6849,6638,6468,8484,8222,7994,7636,7446,7161,6927,6642,6475,6298,8174,7923,7732,7404,7221,6945,6722,6484,6287,6113,7866,7647,7508,7205,6993,6766,6549,6307,6124,5962,7583,7417,7271,6985,6780,6587,6391,6115,5986,5850,7326,7163,7052,6777,6607,6406,6196,5999,5868,5708,7082,6902,6830,6619,6378,6209,6058,5862,5718,5597,9666,9267,8793,8382,8111,7795,7492,7278,7030,6814,9252,8921,8479,8099,7834,7541,7278,7039,6823,6601,8871,8598,8193,7832,7592,7337,7079,6801,6642,6436,8545,8285,7907,7582,7386,7117,6874,6623,6460,6250,8215,8011,7650,7371,7166,6901,6710,6454,6251,6087,7909,7756,7418,7146,6947,6728,6533,6259,6102,5935,7636,7529,7202,6943,6781,6547,6349,6089,5963,5788,7393,7277,6996,6766,6606,6357,6192,5961,5797,5662,7116,7053,6815,6578,6386,6224,6048,5813,5708,5563,6871,6837,6606,6383,6231,6055,5887,5682,5590,5459,9289,8815,8421,8057,7799,7510,7247,7038,6828,6646,8922,8504,8128,7778,7555,7293,7019,6815,6633,6437,8610,8188,7873,7530,7332,7074,6820,6630,6430,6231,8301,7921,7617,7312,7095,6894,6658,6411,6240,6088,8018,7672,7385,7099,6914,6714,6494,6245,6086,5908,7758,7438,7154,6913,6728,6512,6326,6077,5920,5755,7509,7216,6965,6737,6538,6352,6181,5908,5756,5651,7258,7031,6781,6571,6377,6211,6018,5777,5652,5518,7012,6815,6584,6398,6239,6030,5884,5679,5551,5415,6779,6583,6399,6218,6037,5892,5757,5569,5425,5317,8839,8448,8080,7756,7524,7239,7031,6845,6635,6478,8500,8146,7823,7499,7291,7022,6817,6632,6413,6293,8203,7889,7578,7263,7085,6855,6620,6419,6251,6075,7929,7623,7352,7045,6885,6650,6459,6247,6077,5897,7692,7387,7139,6849,6686,6485,6299,6071,5892,5739,7457,7175,6938,6672,6507,6327,6143,5894,5752,5613,7241,6990,6748,6523,6356,6182,5992,5741,5628,5473,7015,6780,6571,6376,6205,6002,5883,5631,5473,5360,6787,6588,6411,6203,6027,5891,5758,5506,5372,5297,6570,6423,6210,6045,5908,5760,5623,5404,5308,5181,8456,8106,7781,7487,7251,7030,6807,6642,6485,6408,8145,7848,7503,7243,7056,6808,6610,6444,6280,6201,7879,7587,7300,7004,6853,6615,6439,6266,6069,6013,7612,7354,7090,6796,6632,6452,6261,6066,5889,5836,7382,7147,6886,6612,6484,6282,6094,5899,5763,5676,7176,6928,6708,6459,6309,6116,5936,5754,5589,5537,6964,6730,6552,6304,6143,5985,5831,5598,5453,5422,6766,6582,6372,6150,6014,5865,5701,5479,5354,5308,6577,6378,6191,6030,5876,5712,5585,5397,5262,5185,6368,6197,6029,5885,5729,5596,5495,5287,5163,5137,8130,7791,7511,7253,7031,6822,6634,6477,6406,6202,7853,7527,7281,7010,6807,6610,6445,6262,6177,6043,7590,7318,7058,6783,6625,6450,6237,6069,6018,5858,7359,7102,6837,6596,6444,6236,6087,5912,5840,5704,7128,6893,6690,6410,6267,6075,5925,5742,5674,5577,6923,6715,6510,6240,6112,5946,5776,5573,5556,5444,6739,6536,6328,6100,5970,5807,5659,5448,5411,5311,6548,6345,6188,5980,5826,5698,5567,5336,5289,5189,6359,6177,6039,5827,5704,5591,5450,5234,5207,5117,6201,6020,5874,5711,5576,5456,5330,5163,5123,5012,7829,7523,7296,7016,6823,6667,6458,6382,6220,6066,7573,7292,7033,6800,6621,6451,6241,6198,6028,5877,7342,7063,6836,6604,6410,6240,6097,5992,5852,5753,7112,6866,6654,6392,6236,6084,5916,5816,5697,5620,6912,6691,6467,6236,6074,5900,5753,5682,5568,5468,6707,6502,6286,6086,5930,5749,5616,5528,5417,5337,6519,6333,6157,5923,5792,5662,5523,5387,5302,5232,6350,6180,5979,5802,5679,5545,5397,5294,5201,5124,6185,5995,5850,5681,5554,5428,5289,5198,5105,5015,6008,5849,5730,5564,5418,5331,5210,5075,4997,4951,7545,7297,7055,6817,6660,6472,6380,6225,6037,5906,7301,7060,6855,6584,6436,6267,6174,6027,5882,5780,7100,6855,6649,6392,6271,6100,5974,5861,5761,5635,6895,6657,6458,6223,6064,5894,5832,5704,5601,5507,6693,6487,6301,6057,5900,5747,5706,5535,5454,5388,6510,6321,6132,5878,5763,5640,5553,5421,5330,5271,6351,6156,5954,5766,5650,5496,5446,5325,5224,5144,6150,5993,5851,5646,5528,5385,5374,5198,5103,5066,6002,5852,5716,5517,5416,5293,5230,5100,5020,4975,5854,5725,5587,5418,5321,5177,5127,5006,4943,4863,7290,7075,6846,6615,6485,6396,6182,6032,5919,5777,7056,6847,6626,6409,6266,6176,5984,5878,5750,5617,6837,6638,6459,6212,6053,5998,5843,5718,5607,5504,6644,6461,6293,6027,5888,5851,5678,5559,5497,5400,6500,6290,6119,5867,5749,5685,5541,5458,5369,5284,6303,6104,5958,5743,5595,5543,5445,5335,5241,5147,6127,5965,5810,5594,5464,5440,5355,5196,5151,5069,5995,5855,5679,5480,5385,5319,5230,5144,5056,4979,5839,5709,5566,5397,5272,5229,5143,5021,4960,4882,5692,5573,5443,5287,5167,5126,5044,4919,4846,4791,7068,6842,6641,6484,6374,6186,6015,5893,5747,5655,6832,6657,6452,6218,6156,6011,5843,5717,5621,5531,6638,6456,6274,6034,5996,5833,5684,5600,5489,5390,6471,6266,6102,5868,5811,5680,5555,5475,5363,5278,6274,6115,5966,5704,5663,5575,5459,5329,5256,5192,6120,5959,5799,5557,5530,5434,5340,5234,5166,5062,5985,5786,5663,5457,5407,5308,5240,5147,5061,4975,5819,5672,5546,5367,5288,5213,5166,5034,4971,4884,5686,5569,5429,5249,5217,5123,5053,4953,4899,4797,5578,5438,5313,5163,5126,5020,4945,4849,4772,4686,9670,9227,8899,8513,8126,7834,7524,7278,7040,6765,9248,8855,8580,8237,7888,7593,7313,7051,6846,6595,8865,8514,8261,7978,7647,7378,7071,6868,6663,6429,8522,8188,7981,7738,7415,7165,6902,6688,6489,6268,8175,7911,7709,7489,7187,6953,6701,6493,6300,6130,7898,7658,7475,7234,7006,6773,6506,6332,6161,5957,7605,7391,7252,7033,6808,6568,6313,6196,5973,5824,7348,7151,7041,6817,6600,6425,6169,6004,5854,5719,7096,6929,6823,6583,6417,6237,5987,5885,5747,5600,6878,6682,6614,6391,6223,6066,5840,5756,5619,5494,9241,8909,8467,8142,7828,7525,7269,7035,6812,6570,8884,8566,8177,7906,7586,7312,7052,6847,6611,6378,8536,8272,7894,7650,7355,7113,6849,6632,6454,6232,8223,7997,7634,7434,7165,6926,6670,6464,6309,6075,7951,7717,7387,7210,6948,6718,6475,6296,6118,5900,7662,7487,7183,7010,6747,6547,6318,6114,5953,5792,7404,7277,6976,6797,6593,6404,6132,5971,5828,5675,7172,7054,6775,6609,6427,6215,5992,5853,5716,5563,6910,6808,6591,6395,6238,6044,5845,5732,5566,5451,6666,6604,6401,6201,6033,5917,5718,5585,5501,5365,8907,8489,8105,7841,7530,7260,7040,6824,6593,6394,8600,8194,7839,7587,7327,7062,6824,6616,6431,6204,8288,7923,7593,7371,7118,6851,6629,6462,6251,6032,8031,7642,7367,7159,6915,6702,6447,6287,6087,5892,7753,7434,7138,6953,6703,6533,6267,6089,5936,5749,7525,7212,6930,6763,6564,6351,6102,5945,5798,5609,7288,6990,6754,6599,6373,6198,5956,5808,5649,5496,7056,6806,6579,6426,6215,6064,5830,5681,5548,5425,6815,6622,6372,6231,6069,5917,5674,5561,5463,5330,6612,6398,6199,6054,5917,5759,5563,5473,5344,5232,8502,8134,7792,7542,7292,7015,6831,6620,6450,6210,8205,7863,7541,7320,7073,6812,6644,6443,6243,6033,7925,7623,7308,7101,6866,6652,6429,6240,6071,5874,7676,7409,7098,6898,6709,6487,6257,6089,5935,5724,7455,7165,6899,6726,6523,6310,6081,5924,5759,5589,7225,6961,6730,6545,6340,6178,5930,5760,5630,5467,7018,6784,6556,6373,6197,6051,5781,5623,5521,5343,6843,6601,6391,6240,6065,5898,5672,5530,5405,5258,6607,6384,6213,6072,5899,5766,5570,5429,5294,5179,6392,6231,6053,5889,5759,5646,5433,5323,5230,5107,8152,7809,7499,7283,7010,6817,6647,6451,6273,6148,7884,7574,7259,7066,6818,6623,6436,6248,6108,5974,7624,7351,7019,6874,6655,6430,6259,6087,5909,5792,7394,7127,6855,6685,6471,6272,6096,5922,5755,5685,7168,6936,6659,6500,6302,6129,5892,5763,5631,5531,6970,6755,6475,6334,6168,5968,5753,5634,5483,5390,6773,6558,6343,6186,5995,5855,5634,5501,5354,5293,6599,6389,6200,6043,5887,5768,5524,5382,5275,5215,6410,6220,6018,5883,5763,5621,5410,5310,5168,5121,6215,6033,5866,5759,5620,5489,5319,5200,5094,5025,7840,7538,7254,7038,6818,6604,6443,6298,6223,5938,7596,7284,7026,6837,6614,6421,6277,6091,6015,5805,7361,7092,6806,6635,6440,6258,6068,5891,5859,5687,7151,6903,6613,6476,6277,6100,5902,5753,5715,5530,6926,6709,6441,6316,6118,5920,5762,5614,5543,5410,6733,6534,6305,6118,5971,5808,5611,5480,5426,5311,6556,6371,6139,5981,5849,5708,5474,5360,5320,5180,6391,6210,5995,5861,5736,5573,5388,5273,5211,5077,6204,6021,5875,5729,5590,5483,5304,5169,5116,5006,6025,5896,5729,5589,5495,5382,5184,5077,5048,4941,7548,7289,7046,6808,6610,6445,6289,6206,6044,5819,7332,7058,6810,6623,6433,6253,6073,6023,5896,5668,7101,6852,6599,6445,6248,6064,5898,5849,5724,5525,6908,6661,6432,6270,6068,5912,5751,5680,5575,5435,6718,6520,6255,6115,5929,5790,5595,5537,5458,5315,6544,6329,6072,5976,5816,5642,5461,5427,5335,5202,6347,6178,5945,5817,5672,5531,5352,5298,5214,5116,6194,6033,5842,5698,5560,5466,5249,5192,5116,5025,6036,5892,5687,5584,5463,5337,5144,5124,5029,4917,5863,5728,5592,5473,5340,5253,5078,5007,4935,4857,7315,7074,6810,6634,6462,6247,6213,6058,5908,5684,7076,6842,6608,6436,6260,6062,6032,5887,5740,5575,6875,6657,6425,6228,6085,5912,5823,5704,5623,5455,6712,6485,6223,6079,5932,5762,5678,5580,5486,5328,6523,6300,6074,5943,5758,5607,5564,5439,5348,5218,6338,6157,5921,5792,5637,5497,5427,5307,5247,5143,6193,6009,5778,5665,5535,5391,5298,5217,5141,5024,6049,5875,5678,5575,5415,5298,5205,5122,5039,4950,5869,5732,5568,5450,5329,5205,5110,5000,4948,4885,5751,5607,5446,5322,5253,5115,4983,4929,4865,4767,7056,6853,6607,6429,6267,6169,6026,5886,5778,5578,6850,6658,6406,6239,6095,5974,5845,5758,5638,5437,6650,6460,6206,6071,5911,5802,5704,5617,5489,5323,6463,6297,6058,5884,5752,5696,5553,5453,5392,5235,6319,6146,5883,5747,5625,5563,5407,5333,5275,5136,6174,5973,5742,5626,5490,5426,5298,5250,5157,5032,5994,5850,5649,5517,5359,5339,5204,5112,5066,4963,5854,5737,5537,5405,5298,5229,5116,5024,4959,4879,5734,5597,5419,5318,5200,5121,4998,4975,4875,4767,5584,5484,5333,5226,5102,5039,4946,4843,4764,4700,6854,6637,6425,6283,6176,5974,5865,5758,5636,5456,6639,6462,6225,6071,5985,5834,5736,5604,5510,5362,6453,6289,6044,5873,5830,5698,5572,5484,5398,5243,6296,6103,5856,5729,5684,5537,5437,5388,5266,5124,6118,5952,5747,5591,5531,5427,5334,5252,5171,5046,5970,5828,5626,5460,5415,5335,5203,5146,5069,4965,5844,5691,5485,5357,5334,5221,5098,5060,4987,4854,5722,5558,5398,5286,5205,5134,5025,4963,4892,4782,5577,5470,5293,5176,5122,5042,4945,4850,4785,4678,5483,5364,5188,5072,5059,4959,4843,4779,4692,4601,9242,8856,8630,8213,7875,7584,7308,7072,6776,6630,8836,8510,8338,7940,7622,7362,7086,6854,6618,6453,8509,8191,8071,7698,7418,7146,6896,6669,6470,6298,8178,7901,7803,7485,7206,6931,6706,6526,6290,6134,7875,7614,7549,7269,6969,6727,6553,6335,6132,5991,7581,7398,7296,7028,6804,6538,6369,6175,5986,5846,7352,7146,7058,6823,6625,6341,6205,6048,5873,5697,7091,6912,6829,6615,6421,6164,6033,5890,5727,5589,6859,6710,6612,6392,6229,6016,5879,5745,5623,5466,6632,6484,6374,6187,6051,5845,5733,5630,5510,5343,8856,8582,8210,7864,7587,7310,7060,6825,6590,6437,8532,8270,7964,7619,7367,7090,6843,6658,6408,6246,8206,7981,7718,7414,7134,6900,6674,6480,6248,6104,7906,7712,7498,7198,6948,6716,6495,6281,6116,5950,7650,7464,7258,6987,6781,6519,6324,6137,5962,5790,7401,7216,7031,6804,6571,6343,6172,6000,5822,5663,7151,7023,6820,6616,6396,6159,6027,5840,5695,5563,6916,6823,6611,6412,6257,6005,5866,5724,5604,5437,6707,6598,6396,6239,6075,5833,5740,5618,5482,5338,6437,6376,6206,6033,5899,5704,5597,5491,5367,5228,8603,8172,7879,7589,7297,7053,6849,6639,6362,6266,8280,7903,7635,7352,7085,6855,6643,6434,6198,6080,8008,7647,7422,7143,6914,6656,6465,6276,6066,5915,7741,7393,7208,6966,6745,6482,6281,6131,5899,5774,7497,7164,7011,6759,6539,6322,6132,5949,5768,5650,7259,6969,6800,6581,6380,6156,5972,5813,5678,5512,7068,6769,6600,6420,6235,5972,5825,5717,5548,5410,6839,6575,6432,6263,6053,5846,5720,5574,5430,5324,6606,6398,6221,6057,5923,5724,5596,5458,5365,5228,6380,6194,6009,5898,5772,5569,5476,5369,5234,5107,8207,7860,7568,7311,7053,6837,6632,6430,6213,6078,7938,7593,7351,7103,6867,6624,6446,6257,6029,5887,7667,7357,7153,6911,6683,6457,6282,6087,5860,5762,7429,7155,6950,6713,6534,6296,6095,5930,5742,5612,7212,6938,6753,6547,6368,6106,5941,5800,5618,5460,7003,6730,6603,6370,6194,5953,5821,5668,5482,5376,6805,6579,6434,6223,6053,5827,5672,5535,5395,5267,6616,6396,6233,6070,5940,5687,5555,5438,5315,5149,6421,6196,6063,5933,5781,5554,5468,5334,5204,5081,6189,6009,5888,5773,5640,5467,5361,5224,5119,4992,7885,7530,7326,7057,6803,6642,6451,6271,6026,5985,7612,7308,7097,6865,6625,6471,6252,6081,5869,5822,7402,7094,6875,6685,6484,6277,6090,5931,5729,5688,7165,6883,6707,6520,6315,6093,5940,5784,5566,5541,6954,6701,6545,6325,6151,5941,5782,5642,5460,5434,6769,6547,6358,6182,6017,5798,5638,5516,5375,5314,6579,6374,6215,6051,5893,5656,5534,5410,5254,5203,6397,6196,6075,5895,5755,5564,5423,5309,5156,5114,6212,6042,5899,5764,5632,5474,5330,5202,5095,5015,6037,5857,5724,5628,5511,5323,5225,5131,4996,4934,7583,7295,7069,6828,6621,6457,6262,6112,5963,5830,7350,7036,6857,6640,6434,6254,6082,5923,5803,5679,7145,6833,6677,6466,6255,6113,5937,5758,5640,5562,6938,6668,6491,6295,6112,5940,5786,5626,5531,5426,6760,6482,6322,6159,5975,5759,5639,5507,5394,5311,6557,6307,6175,6009,5833,5625,5516,5377,5292,5219,6383,6177,6033,5867,5735,5535,5381,5265,5195,5121,6228,6021,5880,5759,5642,5416,5293,5197,5119,4994,6042,5852,5756,5616,5511,5308,5212,5103,5015,4928,5866,5717,5611,5466,5377,5227,5105,4982,4940,4850,7297,7055,6854,6628,6431,6263,6115,6052,5781,5700,7087,6822,6653,6425,6243,6105,5913,5857,5674,5552,6915,6638,6451,6270,6096,5914,5757,5726,5551,5435,6721,6442,6293,6124,5923,5771,5633,5562,5399,5339,6538,6288,6145,5950,5784,5633,5480,5430,5301,5225,6371,6131,5980,5840,5693,5498,5350,5323,5198,5119,6209,5985,5850,5734,5584,5381,5275,5224,5072,5032,6016,5863,5738,5586,5476,5305,5179,5114,5010,4953,5886,5723,5595,5474,5389,5197,5072,5036,4941,4867,5731,5590,5458,5358,5244,5094,4977,4944,4834,4735,7090,6841,6625,6442,6259,6107,6023,5901,5688,5565,6871,6625,6441,6269,6069,5900,5877,5756,5531,5432,6679,6435,6289,6072,5903,5771,5717,5595,5425,5357,6534,6262,6114,5921,5770,5618,5544,5466,5326,5243,6358,6090,5961,5811,5645,5474,5433,5348,5192,5120,6183,5926,5835,5680,5532,5363,5324,5210,5115,5038,6047,5829,5693,5565,5465,5273,5210,5105,5031,4961,5908,5702,5578,5468,5354,5159,5120,5043,4937,4872,5753,5586,5478,5365,5225,5085,5043,4936,4862,4793,5600,5474,5368,5223,5138,4988,4937,4825,4737,4694,6852,6617,6437,6266,6066,6016,5890,5753,5553,5481,6657,6434,6235,6058,5901,5844,5710,5618,5458,5355,6501,6239,6062,5919,5748,5673,5568,5495,5331,5244,6307,6072,5911,5766,5615,5530,5453,5357,5209,5145,6156,5932,5793,5628,5482,5432,5318,5238,5126,5058,6010,5785,5643,5535,5394,5308,5205,5135,5020,4945,5869,5658,5538,5428,5284,5199,5128,5046,4932,4852,5756,5569,5447,5328,5187,5119,5032,4937,4881,4787,5638,5469,5337,5242,5119,5002,4929,4876,4778,4694,5491,5325,5220,5151,5002,4922,4840,4765,4665,4588,6667,6416,6244,6093,5981,5858,5737,5655,5461,5357,6468,6228,6069,5908,5798,5684,5602,5505,5332,5257,6274,6064,5904,5735,5662,5559,5467,5377,5229,5158,6150,5902,5739,5604,5546,5412,5338,5282,5137,5041,5999,5740,5607,5491,5430,5306,5222,5181,5017,4956,5840,5619,5502,5360,5312,5222,5138,5053,4962,4875,5737,5530,5395,5269,5238,5103,5011,4977,4866,4776,5618,5415,5309,5182,5141,5011,4943,4896,4776,4671,5502,5324,5239,5095,5031,4940,4875,4776,4681,4620,5367,5244,5116,4999,4962,4817,4749,4663,4590,4496,8851,8565,8320,7930,7637,7352,7073,6831,6651,6459,8486,8265,8048,7681,7390,7141,6900,6650,6465,6288,8146,7967,7796,7450,7178,6953,6705,6473,6328,6136,7888,7709,7557,7250,6973,6762,6544,6331,6175,6003,7585,7434,7296,7039,6740,6577,6369,6177,6010,5849,7327,7195,7064,6833,6534,6388,6220,5999,5870,5749,7088,6952,6837,6624,6368,6211,6035,5880,5724,5610,6875,6710,6612,6433,6180,6033,5915,5779,5583,5491,6615,6484,6378,6203,5973,5867,5768,5620,5456,5378,6419,6270,6187,6002,5833,5741,5612,5510,5356,5247,8498,8329,7935,7603,7353,7088,6864,6571,6438,6274,8180,8064,7683,7382,7154,6888,6666,6444,6281,6085,7893,7783,7472,7181,6934,6702,6496,6280,6108,5937,7610,7550,7255,6991,6737,6553,6340,6127,5969,5836,7362,7310,7034,6774,6544,6364,6166,5973,5842,5689,7135,7063,6835,6617,6362,6183,6006,5860,5697,5551,6896,6818,6625,6438,6153,6024,5903,5718,5574,5446,6685,6641,6408,6246,6018,5876,5749,5607,5484,5360,6479,6390,6179,6033,5854,5722,5608,5510,5356,5233,6259,6165,6010,5886,5692,5582,5499,5388,5220,5151,8279,7940,7616,7357,7100,6855,6649,6404,6245,6065,7984,7701,7403,7142,6877,6678,6478,6229,6072,5933,7700,7485,7193,6930,6701,6504,6300,6072,5942,5784,7481,7264,6991,6767,6542,6325,6140,5954,5804,5650,7226,7021,6802,6586,6344,6169,5997,5801,5664,5553,6997,6825,6634,6400,6153,6036,5834,5670,5558,5434,6799,6613,6415,6255,6002,5859,5715,5573,5455,5301,6617,6400,6253,6086,5836,5734,5617,5480,5332,5224,6373,6204,6056,5908,5681,5603,5477,5367,5245,5132,6173,6014,5872,5758,5572,5481,5368,5269,5143,5028,7915,7628,7350,7093,6857,6671,6456,6178,6077,5918,7655,7419,7123,6895,6684,6463,6282,6048,5916,5754,7421,7179,6946,6723,6481,6281,6135,5886,5749,5626,7182,7002,6768,6557,6314,6138,5969,5752,5636,5508,6965,6815,6575,6384,6177,5968,5821,5649,5532,5380,6764,6605,6419,6241,5991,5832,5708,5537,5405,5271,6571,6404,6260,6067,5827,5708,5580,5419,5292,5186,6405,6254,6091,5939,5716,5600,5453,5330,5229,5086,6203,6042,5899,5780,5589,5455,5367,5226,5124,4996,6017,5848,5766,5652,5437,5352,5271,5140,5013,4933,7599,7335,7089,6843,6665,6450,6270,6064,5899,5836,7370,7134,6897,6659,6460,6291,6099,5868,5758,5699,7137,6946,6698,6494,6294,6123,5939,5724,5623,5545,6934,6764,6526,6352,6136,5958,5805,5616,5473,5438,6721,6569,6372,6199,5966,5816,5682,5486,5354,5343,6536,6422,6206,6029,5840,5707,5545,5387,5278,5241,6370,6239,6048,5915,5700,5550,5433,5305,5162,5114,6190,6060,5926,5805,5565,5435,5357,5212,5068,5040,5996,5899,5778,5635,5429,5358,5221,5117,4996,4940,5854,5742,5605,5527,5343,5256,5143,5036,4916,4830,7323,7101,6870,6615,6463,6293,6089,5849,5823,5691,7103,6904,6673,6454,6287,6097,5927,5735,5687,5545,6889,6686,6518,6284,6106,5935,5781,5584,5540,5447,6699,6523,6357,6141,5936,5812,5648,5436,5420,5328,6529,6363,6164,6004,5825,5658,5526,5363,5320,5203,6345,6191,6030,5888,5684,5538,5438,5263,5203,5128,6167,6047,5901,5737,5549,5436,5317,5145,5119,5043,6019,5909,5764,5628,5458,5333,5195,5082,5022,4948,5876,5740,5617,5516,5335,5211,5125,5001,4918,4829,5698,5589,5518,5383,5214,5128,5041,4922,4850,4738,7075,6872,6638,6447,6273,6082,5958,5800,5670,5578,6850,6689,6489,6254,6106,5941,5782,5649,5540,5472,6670,6499,6299,6090,5937,5794,5615,5528,5437,5331,6490,6326,6138,5966,5781,5647,5510,5388,5306,5221,6306,6159,6017,5831,5647,5531,5409,5279,5185,5145,6166,6018,5857,5725,5542,5431,5284,5193,5131,5029,6010,5861,5727,5630,5421,5293,5187,5102,5011,4954,5858,5745,5630,5513,5311,5205,5095,5019,4922,4868,5701,5614,5509,5378,5218,5115,4989,4929,4843,4766,5595,5475,5364,5278,5133,5010,4902,4872,4733,4664,6866,6672,6450,6250,6113,5949,5877,5650,5540,5467,6658,6486,6278,6100,5933,5763,5735,5541,5428,5347,6454,6293,6122,5935,5788,5619,5588,5404,5328,5251,6288,6149,5967,5778,5645,5515,5436,5298,5224,5148,6152,5986,5821,5673,5520,5386,5325,5199,5129,5018,5983,5844,5734,5583,5399,5284,5247,5095,5019,4962,5857,5726,5608,5458,5302,5199,5128,4984,4952,4880,5736,5622,5485,5375,5214,5103,5048,4922,4863,4789,5576,5469,5381,5268,5106,4969,4954,4838,4738,4663,5443,5366,5287,5162,4991,4917,4865,4708,4671,4590,6640,6443,6251,6066,5897,5857,5744,5529,5449,5368,6440,6286,6098,5906,5753,5711,5598,5404,5337,5262,6266,6110,5922,5754,5622,5567,5465,5326,5244,5148,6099,5946,5781,5638,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,4861,4777,5537,5447,5322,5180,5111,5035,4963,4844,4779,4690,5460,5331,5218,5113,5026,4937,4859,4786,4672,4593,5332,5213,5141,5026,4911,4841,4761,4670,4588,4490,5221,5130,5044,4939,4816,4736,4663,4570,4486,4423,8553,8246,8020,7671,7423,7131,6842,6715,6486,6289,8235,7963,7764,7448,7177,6932,6684,6535,6315,6140,7932,7695,7543,7211,6984,6751,6507,6357,6163,6008,7666,7444,7310,6974,6797,6602,6342,6190,6043,5867,7415,7184,7079,6794,6590,6404,6186,6043,5889,5743,7139,6929,6849,6581,6385,6232,6053,5881,5745,5628,6893,6722,6630,6355,6193,6066,5898,5742,5633,5511,6679,6490,6389,6149,6017,5866,5732,5618,5489,5382,6456,6262,6198,5985,5848,5738,5635,5481,5354,5281,6241,6111,6018,5801,5724,5616,5508,5363,5260,5177,8248,8037,7665,7401,7122,6886,6638,6469,6274,6112,7959,7781,7438,7170,6939,6692,6480,6299,6137,5962,7702,7550,7222,6953,6771,6520,6304,6180,5973,5802,7432,7293,7037,6769,6559,6358,6164,6006,5840,5711,7171,7076,6826,6557,6395,6226,5998,5857,5733,5597,6945,6830,6616,6362,6222,6032,5864,5745,5612,5468,6724,6597,6425,6179,6032,5877,5746,5613,5483,5373,6484,6394,6222,5981,5852,5742,5609,5454,5374,5273,6286,6221,6008,5819,5727,5592,5492,5355,5266,5160,6086,6000,5874,5695,5598,5476,5412,5258,5147,5062,8052,7681,7390,7141,6900,6670,6414,6275,6111,5914,7786,7447,7167,6943,6694,6486,6263,6113,5927,5793,7528,7263,6976,6740,6516,6341,6109,5953,5806,5672,7289,7044,6784,6550,6384,6165,5956,5848,5697,5540,7069,6815,6610,6371,6199,6022,5832,5717,5558,5442,6822,6622,6426,6170,6010,5887,5723,5580,5436,5341,6611,6422,6254,5996,5874,5746,5571,5479,5367,5222,6416,6210,6056,5848,5725,5586,5461,5355,5260,5125,6183,6011,5897,5701,5572,5486,5372,5244,5124,5047,6006,5874,5738,5562,5464,5385,5259,5149,5066,4946,7692,7390,7145,6905,6654,6488,6212,6065,5930,5757,7472,7185,6932,6706,6499,6305,6061,5907,5788,5627,7256,6979,6759,6551,6326,6136,5932,5796,5633,5498,7026,6784,6600,6362,6157,5990,5805,5663,5529,5413,6816,6617,6397,6172,6022,5867,5684,5531,5434,5299,6632,6432,6240,5995,5875,5709,5554,5447,5334,5188,6414,6235,6097,5868,5716,5595,5463,5333,5216,5105,6210,6064,5933,5691,5574,5486,5337,5209,5127,5006,6033,5896,5776,5554,5472,5373,5236,5124,5039,4914,5857,5720,5652,5462,5352,5261,5186,5028,4928,4824,7403,7135,6883,6695,6498,6286,6031,5905,5759,5692,7185,6915,6715,6506,6301,6132,5898,5761,5612,5578,6976,6752,6550,6332,6129,5987,5764,5618,5505,5463,6790,6578,6348,6176,5999,5833,5647,5527,5387,5328,6608,6388,6213,6023,5833,5704,5565,5418,5276,5238,6410,6227,6066,5850,5701,5591,5439,5302,5168,5161,6233,6086,5916,5713,5596,5470,5304,5222,5119,5038,6044,5898,5783,5595,5473,5335,5223,5109,4992,4955,5854,5753,5634,5443,5350,5261,5133,5010,4919,4863,5720,5620,5518,5339,5239,5169,5039,4940,4840,4765,7124,6898,6674,6471,6302,6116,5865,5740,5671,5577,6922,6711,6484,6293,6135,5954,5710,5602,5558,5425,6745,6524,6323,6147,5979,5806,5609,5488,5430,5320,6559,6360,6201,5954,5820,5707,5499,5363,5331,5252,6399,6209,6024,5831,5702,5570,5381,5278,5235,5127,6223,6045,5883,5711,5579,5425,5294,5179,5126,5036,6046,5896,5793,5575,5456,5343,5219,5075,5003,4967,5879,5779,5653,5442,5359,5242,5105,4991,4948,4860,5732,5624,5505,5348,5248,5128,5028,4922,4844,4750,5575,5484,5396,5240,5149,5019,4955,4844,4750,4623,6902,6696,6455,6301,6131,5947,5712,5664,5543,5434,6678,6495,6304,6116,5937,5798,5584,5525,5424,5345,6515,6348,6137,5945,5804,5670,5437,5423,5332,5233,6358,6184,5996,5822,5674,5549,5337,5332,5226,5123,6188,6013,5883,5696,5536,5427,5265,5210,5122,5049,6020,5889,5756,5556,5433,5326,5145,5105,5024,4955,5894,5760,5614,5459,5348,5239,5057,5013,4962,4855,5743,5606,5497,5360,5224,5114,4998,4935,4828,4764,5585,5492,5398,5220,5125,5033,4889,4844,4751,4667,5470,5394,5281,5132,5035,4943,4802,4748,4641,4578,6694,6487,6273,6118,5946,5811,5648,5517,5442,5351,6523,6306,6102,5951,5809,5647,5504,5425,5330,5241,6332,6135,5949,5806,5666,5509,5411,5305,5223,5151,6166,6007,5846,5661,5531,5402,5287,5185,5125,5083,6020,5887,5718,5546,5431,5315,5178,5106,5047,4969,5887,5730,5605,5454,5309,5191,5097,5018,4942,4872,5734,5607,5509,5335,5213,5119,5022,4914,4853,4773,5626,5488,5396,5198,5129,5023,4927,4830,4772,4674,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,5448,5344,5230,6277,6113,5921,5767,5609,5586,5422,5303,5241,5171,6132,5976,5777,5641,5510,5435,5277,5215,5145,5064,5986,5825,5657,5534,5397,5334,5177,5127,5036,4966,5849,5717,5563,5416,5281,5231,5110,5026,4957,4899,5699,5603,5464,5292,5193,5148,4982,4936,4876,4775,5608,5468,5354,5213,5106,5046,4913,4866,4769,4677,5485,5369,5263,5113,4984,4952,4834,4749,4677,4581,5357,5272,5175,5006,4908,4869,4746,4634,4585,4509,5269,5178,5065,4937,4833,4743,4629,4552,4483,4408,6276,6098,5901,5733,5715,5617,5418,5342,5267,5156,6121,5920,5736,5614,5563,5461,5302,5235,5167,5048,5935,5776,5627,5487,5425,5342,5214,5110,5040,4992,5798,5671,5522,5357,5328,5238,5091,5012,4962,4886,5691,5554,5407,5264,5227,5141,5022,4958,4872,4794,5568,5436,5323,5177,5118,5011,4951,4884,4750,4702,5444,5359,5243,5055,5023,4950,4846,4776,4702,4581,5349,5245,5139,4987,4952,4841,4741,4670,4579,4502,5266,5141,5034,4913,4855,4736,4645,4589,4497,4386,5141,5047,4973,4828,4730,4641,4561,4460,4404,4334,8200,7957,7750,7449,7185,6879,6723,6515,6330,6100,7921,7677,7507,7227,6993,6717,6547,6373,6159,5909,7639,7426,7266,7017,6769,6546,6396,6211,6008,5795,7379,7206,7048,6795,6619,6393,6226,6058,5910,5686,7144,6937,6814,6589,6415,6218,6044,5928,5780,5549,6901,6696,6577,6413,6209,6034,5902,5766,5632,5446,6652,6484,6346,6190,6024,5889,5731,5598,5513,5335,6468,6291,6119,6015,5875,5736,5603,5495,5401,5225,6280,6082,5958,5853,5717,5603,5486,5398,5269,5145,6077,5921,5795,5690,5572,5504,5357,5259,5163,5049,7945,7742,7440,7194,6923,6658,6513,6315,6109,5915,7663,7522,7220,6966,6732,6506,6350,6134,5992,5770,7430,7296,6993,6766,6588,6315,6180,6022,5870,5624,7185,7064,6791,6599,6409,6176,6052,5905,5749,5520,6931,6852,6577,6375,6214,6029,5886,5732,5629,5428,6702,6634,6363,6190,6062,5891,5744,5604,5506,5322,6498,6384,6153,6013,5878,5738,5599,5490,5375,5193,6275,6202,5967,5849,5721,5615,5485,5360,5275,5128,6099,6017,5811,5703,5596,5493,5377,5261,5184,5030,5928,5857,5648,5577,5486,5357,5250,5173,5080,4951,7759,7433,7171,6923,6715,6459,6280,6108,5954,5740,7537,7204,6971,6763,6527,6291,6149,5982,5803,5611,7293,7010,6769,6571,6339,6144,6010,5835,5694,5498,7064,6837,6577,6395,6205,6001,5868,5723,5608,5385,6845,6619,6358,6211,6054,5859,5718,5619,5476,5284,6622,6406,6183,6033,5872,5731,5607,5495,5358,5202,6373,6221,5978,5852,5736,5598,5462,5368,5247,5101,6217,6042,5807,5699,5609,5482,5337,5276,5170,4989,6034,5873,5685,5594,5469,5376,5259,5161,5059,4954,5837,5732,5552,5456,5357,5270,5155,5048,4968,4860,7438,7150,6950,6712,6511,6253,6109,5934,5769,5598,7226,6967,6749,6521,6325,6117,5941,5793,5686,5465,7024,6787,6555,6357,6176,5942,5802,5680,5556,5335,6832,6591,6388,6210,6023,5815,5714,5585,5432,5246,6619,6426,6202,6020,5876,5720,5579,5445,5348,5170,6418,6254,5991,5858,5759,5588,5470,5352,5240,5063,6220,6053,5836,5693,5591,5442,5364,5247,5122,4968,6028,5907,5705,5569,5466,5362,5239,5128,5033,4901,5870,5770,5561,5453,5379,5262,5119,5043,4973,4799,5728,5599,5443,5367,5261,5154,5045,4959,4868,4710,7155,6938,6713,6507,6323,6072,5906,5789,5634,5529,6971,6731,6550,6346,6159,5910,5790,5666,5491,5405,6770,6558,6385,6175,5981,5809,5661,5518,5400,5325,6606,6402,6191,6023,5874,5690,5544,5425,5316,5192,6417,6222,6012,5891,5735,5548,5439,5333,5216,5077,6238,6056,5865,5734,5596,5462,5359,5214,5110,5034,6046,5928,5686,5580,5472,5355,5217,5128,5018,4923,5898,5779,5559,5465,5366,5226,5127,5032,4941,4835,5739,5621,5466,5370,5254,5147,5027,4934,4825,4760,5580,5513,5346,5234,5159,5086,4944,4848,4731,4628,6929,6695,6516,6314,6133,5881,5759,5610,5533,5442,6736,6544,6331,6145,6002,5752,5622,5492,5448,5315,6572,6364,6169,6002,5866,5625,5504,5386,5326,5197,6381,6199,6029,5864,5718,5528,5424,5282,5233,5111,6210,6052,5873,5718,5583,5433,5317,5174,5145,5008,6080,5908,5706,5596,5487,5325,5210,5107,5064,4913,5904,5758,5571,5471,5346,5207,5144,4996,4946,4834,5741,5636,5472,5354,5245,5110,5018,4916,4841,4736,5621,5515,5335,5254,5161,5047,4931,4827,4777,4633,5493,5383,5219,5167,5071,4932,4870,4739,4628,4536,6725,6507,6299,6143,5968,5707,5598,5552,5422,5333,6516,6325,6157,5995,5827,5594,5480,5423,5313,5212,6341,6170,5991,5841,5695,5492,5359,5320,5224,5125,6198,6039,5844,5702,5594,5387,5248,5247,5144,5006,6040,5874,5717,5590,5460,5287,5164,5141,5046,4934,5889,5760,5594,5463,5339,5200,5097,5027,4946,4858,5749,5641,5451,5328,5255,5109,4975,4949,4864,4743,5634,5520,5337,5250,5142,5018,4912,4852,4745,4640,5469,5404,5238,5159,5038,4931,4844,4739,4628,4549,5354,5283,5131,5029,4959,4855,4732,4656,4545,4448,6509,6283,6152,5959,5809,5587,5530,5398,5322,5244,6349,6142,5973,5813,5675,5461,5402,5304,5212,5132,6189,5987,5831,5712,5561,5342,5301,5220,5129,5013,6012,5845,5717,5568,5443,5256,5220,5120,5045,4964,5878,5753,5586,5428,5349,5160,5087,5026,4969,4862,5761,5611,5471,5351,5231,5061,5012,4955,4881,4756,5617,5492,5359,5255,5126,4972,4942,4841,4758,4657,5492,5406,5249,5120,5041,4926,4838,4727,4688,4552,5406,5267,5126,5027,4942,4836,4746,4635,4567,4470,5291,5177,5036,4975,4849,4716,4653,4535,4457,4362,6329,6097,5928,5807,5653,5494,5394,5343,5229,5122,6136,5928,5812,5670,5505,5395,5318,5205,5127,5041,5991,5808,5671,5543,5403,5290,5207,5124,5058,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,5721,5593,5474,5345,5221,5116,5010,4930,4828,5780,5562,5463,5378,5224,5121,5033,4926,4841,4706,5638,5447,5366,5267,5134,5034,4978,4835,4744,4643,5509,5343,5257,5139,5067,4964,4833,4742,4644,4535,5400,5216,5132,5067,4972,4881,4777,4648,4568,4450,6548,6351,6164,6006,5754,5634,5465,5426,5320,5239,6361,6186,5983,5869,5643,5484,5387,5335,5192,5121,6191,6016,5887,5717,5522,5402,5290,5219,5093,5044,6045,5898,5721,5591,5436,5327,5179,5139,5022,4964,5902,5750,5601,5496,5331,5210,5098,5060,4932,4854,5737,5578,5488,5381,5195,5120,5006,4956,4835,4752,5613,5461,5364,5243,5110,5022,4914,4847,4713,4643,5521,5349,5239,5159,5043,4949,4833,4773,4629,4541,5404,5228,5146,5067,4930,4843,4756,4659,4531,4446,5268,5144,5055,4975,4874,4757,4645,4569,4442,4368,6333,6158,6011,5846,5592,5458,5428,5300,5215,5144,6166,6010,5860,5705,5491,5373,5322,5200,5128,5052,6037,5859,5706,5599,5395,5251,5201,5138,5024,4937,5880,5721,5609,5484,5287,5163,5135,5020,4932,4874,5758,5613,5503,5364,5207,5083,5035,4955,4841,4793,5621,5489,5366,5249,5123,4990,4914,4867,4763,4654,5500,5330,5246,5162,5015,4900,4842,4742,4643,4562,5403,5247,5155,5044,4932,4837,4744,4639,4540,4464,5291,5162,5060,4942,4860,4750,4651,4548,4459,4371,5206,5037,4966,4875,4752,4654,4580,4467,4365,4286,6139,5975,5814,5684,5457,5404,5305,5224,5148,5038,5988,5827,5679,5556,5330,5299,5210,5138,5045,4964,5845,5711,5576,5437,5232,5220,5112,5002,4969,4894,5728,5581,5451,5341,5170,5117,5014,4949,4859,4784,5622,5470,5355,5259,5069,5024,4939,4875,4778,4694,5464,5351,5249,5148,4967,4932,4855,4760,4650,4589,5364,5246,5151,5022,4906,4847,4714,4660,4579,4477,5293,5137,5026,4967,4824,4744,4654,4560,4481,4397,5190,5048,4960,4859,4719,4652,4526,4472,4353,4274,5081,4970,4874,4758,4628,4593,4454,4356,4306,4207,5938,5797,5661,5522,5374,5310,5230,5133,5048,4979,5799,5678,5535,5397,5294,5197,5130,5038,4966,4891,5704,5549,5426,5297,5192,5091,5014,4995,4880,4781,5565,5418,5321,5214,5075,5007,4952,4849,4777,4693,5472,5346,5213,5107,5032,4929,4866,4764,4675,4598,5381,5223,5105,5005,4939,4832,4751,4677,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}; int Solve(int x) { int ans=0,i; for(i=0;i<=10000;i++) { if(x>=i*100000) ans+=r[i]; else break; } for(int j=(i-1)*100000+1;j<=x;j++) if(j%f(j)==0) ans++; return ans; } int main() { scanf("%d",&t); for(int ca=1;ca<=t;ca++) { scanf("%d%d",&a,&b); printf("Case %d: %d\n",ca,Solve(b)-Solve(a-1)); } return 0; }
然后就是数位DP求解:
分别计算出[1, b]中符合条件的个数和[1, a-1]中符合条件的个数。
d[l][i][j][k]表示前l位和为i模j的结果为k的数的个数,那么就有方程
d[l+1][i+x][j][(k*10+x)%j] += d[l][i][j][k],预处理出d[l][i][j][k],然后再逐位统计即可。
#include <iostream> #include <string.h> #include <stdio.h> using namespace std; int dp[10][82][82][82]; void Pre() { int i,j,k,l,x; for(i=1;i<=81;i++) dp[0][0][i][0]=1; for(l=0; l<9; l++) for(i=0; i<=l*9; i++) for(j=1; j<=81; j++) for(k=0; k<j; k++) for(x=0; x<=9; x++) { dp[l+1][i+x][j][(k*10+x)%j]+=dp[l][i][j][k]; } } int Solve(int x) { if(x==0) return 0; int ret=0; if(x==1000000000) { ret++; x--; } int i,j,k; int len,sum,t,tt,power=1,bit[11]; len=sum=0; t=tt=x; while(t) { bit[++len]=t%10; t/=10; sum+=bit[len]; } if(x%sum==0) ret++; for(i=1;i<=len;i++) { tt/=10; power*=10; t=tt*power; sum-=bit[i]; for(j=0;j<bit[i];j++) { for(k=sum+j;k<=sum+j+9*(i-1);k++) { if(k==0) continue; int dd=t%k; if(dd>0) dd=k-dd; ret+=dp[i-1][k-sum-j][k][dd]; } t+=power/10; } } return ret; } int main() { int ta=1,cas; Pre(); scanf("%d",&cas); while(cas--) { int a,b; scanf("%d%d",&a,&b); printf("Case %d: %d\n",ta++,Solve(b)-Solve(a-1)); } return 0; }