hdu 3652 打表
思路:直接打表
#include<cstdio> #include<vector> #include<cmath> #include<iostream> using namespace std; int num[10010]={0,1356,1967,2577,3188,3799,5156,13154,13762,14374,14985,16341,16953,17563,18174,18785,20142,20753,21364,21975,22587,23942,24554,25165,25775,26387,27744,28355,28966,29576,30187,31544,32155,32767,33375,33987,35344,35954,36566,37176,37787,39144,39754,40365,40976,41587,42946,43554,44166,44777,45387,46746,47356,47967,48578,49188,50545,58543,59154,59766,60374,61731,62342,62952,63564,64175,79559,94944,110328,125713,141098,142455,143067,143675,144287,144898,146254,146866,147476,148087,148698,150055,150666,151277,151888,152500,153855,154467,155078,155688,156300,157657,158268,158879,159489,160100,161457,162068,162680,163288,163900,165257,165867,166479,167089,167700,169057,177054,177665,178276,178887,180246,180854,181466,182077,182687,184046,184656,185267,185878,186488,187845,188456,189067,189679,190287,191644,192255,192865,193477,194087,195443,196054,196664,197275,197886,199243,199855,200463,201075,201686,203042,203654,204264,204875,205486,206843,207454,208065,208676,209288,210643,211255,211866,212476,213088,214445,222444,223055,223665,224276,225633,226244,226856,227464,228076,229433,230043,230655,231265,231876,233233,233843,234454,235065,235676,237035,237643,238255,238866,239476,240835,241445,242056,242667,243277,244634,245245,245856,246468,247076,248433,249044,249654,250266,250876,252232,252843,253453,254064,254675,256032,256644,257252,257864,258475,259831,267829,268439,269050,269661,271018,271629,272240,272851,273463,274818,275430,276041,276651,277263,278620,279231,279842,280452,281063,282420,283031,283643,284251,284863,286220,286830,287442,288052,288663,290020,290630,291241,291852,292463,293822,294430,295042,295653,296263,297622,298232,298843,299454,300064,301421,302032,302643,303255,303863,305220,313218,313828,314440,315050,316406,317017,317627,318238,318849,320206,320818,321426,322038,322649,324005,324617,325227,325838,326449,327806,328417,329028,329639,330251,331606,332218,332829,333439,334051,335408,336019,336630,337240,337851,339208,339819,340431,341039,341651,343008,343618,344230,344840,345451,346808,347418,348029,348640,349251,350610,358606,359218,359829,360439,361798,362408,363019,363630,364240,365597,366208,366819,367431,368039,369396,370007,370617,371229,371839,373195,373806,374416,375027,375638,376995,377607,378215,378827,379438,380794,381406,382016,382627,383238,384595,385206,385817,386428,387040,388395,389007,389618,390228,390840,392197,392808,393419,394029,394640,395997,403995,404607,405215,405827,407184,407794,408406,409016,409627,410984,411594,412205,412816,413427,414786,415394,416006,416617,417227,418586,419196,419807,420418,421028,422385,422996,423607,424219,424827,426184,426795,427405,428017,428627,429983,430594,431204,431815,432426,433783,434395,435003,435615,436226,437582,438194,438804,439415,440026,441383,449381,449992,450603,451215,452570,453182,453793,454403,455015,456372,456983,457594,458204,458815,460172,460783,461395,462003,462615,463972,464582,465194,465804,466415,467772,468382,468993,469604,470215,471574,472182,472794,473405,474015,475374,475984,476595,477206,477816,479173,479784,480395,481007,481615,482972,483583,484193,484805,485415,486771,494768,495378,495989,496600,497957,498569,499177,499789,500400,501756,502368,502978,503589,504200,505557,506168,506779,507390,508002,509357,509969,510580,511190,511802,513159,513770,514381,514991,515602,516959,517570,518182,518790,519402,520759,521369,521981,522591,523202,524559,525169,525780,526391,527002,528361,528969,529581,530192,530802,532161,540158,540769,541380,541990,543347,543958,544569,545181,545789,547146,547757,548367,548979,549589,550945,551556,552166,552777,553388,554745,555357,555965,556577,557188,558544,559156,559766,560377,560988,562345,562956,563567,564178,564790,566145,566757,567368,567978,568590,569947,570558,571169,571779,572390,573747,574358,574970,575578,576190,577547,585544,586156,586766,587377,588734,589344,589955,590566,591177,606562,621946,637331,652716,668100,669459,670069,670680,671291,671901,673258,673869,674480,675092,675700,677057,677668,678278,678890,679500,680856,681467,682077,682688,683299,684656,685268,685876,686488,687099,688455,689067,689677,690288,690899,692256,692867,693478,694089,694701,696056,704055,704666,705276,705888,707245,707856,708467,709077,709688,711045,711656,712268,712876,713488,714845,715455,716067,716677,717288,718645,719255,719866,720477,721088,722447,723055,723667,724278,724888,726247,726857,727468,728079,728689,730046,730657,731268,731880,732488,733845,734456,735066,735678,736289,751673,767058,782442,797827,813212,828596,843981,859365,874750,890135,905519,920904,936289,951673,967058,982442,997827,1013212,1028596,1043981,1059365,1074750,1090135,1105519,1120904,1136289,1151673,1167058,1182442,1197827,1213212,1228596,1243981,1259365,1274750,1290135,1305519,1320904,1336289,1351673,1367058,1382442,1397827,1413212,1428596,1443981,1459365,1474750,1490135,1505519,1506878,1507488,1508099,1508710,1509320,1510677,1518675,1519286,1519898,1520506,1521863,1522474,1523084,1523696,1524306,1525662,1526273,1526883,1527494,1528105,1529462,1530074,1530682,1531294,1531905,1533261,1533873,1534483,1535094,1535705,1537062,1537673,1538284,1538895,1539507,1540862,1541474,1542085,1542695,1543307,1544664,1545275,1545886,1546496,1547107,1548464,1549075,1549687,1550295,1550907,1552264,1552874,1553486,1554096,1554707,1556064,1564061,1564672,1565283,1565894,1567253,1567861,1568473,1569084,1569694,1571053,1571663,1572274,1572885,1573495,1574852,1575463,1576074,1576686,1577294,1578651,1579262,1579872,1580484,1581094,1582450,1583061,1583671,1584282,1584893,1586250,1586862,1587470,1588082,1588693,1590049,1590661,1591271,1591882,1592493,1593850,1594461,1595072,1595683,1596295,1597650,1598262,1598873,1599483,1600095,1601452,1609451,1610062,1610672,1611283,1612640,1613251,1613863,1614471,1615083,1616440,1617050,1617662,1618272,1618883,1620240,1620850,1621461,1622072,1622683,1624042,1624650,1625262,1625873,1626483,1627842,1628452,1629063,1629674,1630284,1631641,1632252,1632863,1633475,1634083,1635440,1636051,1636661,1637273,1637883,1639239,1639850,1640460,1641071,1641682,1643039,1643651,1644259,1644871,1645482,1646838,1654836,1655446,1656057,1656668,1658025,1658636,1659247,1659858,1660470,1661825,1662437,1663048,1663658,1664270,1665627,1666238,1666849,1667459,1668070,1669427,1670038,1670650,1671258,1671870,1673227,1673837,1674449,1675059,1675670,1677027,1677637,1678248,1678859,1679470,1680829,1681437,1682049,1682660,1683270,1684629,1685239,1685850,1686461,1687071,1688428,1689039,1689650,1690262,1690870,1692227,1700225,1700835,1701447,1702057,1703413,1704024,1704634,1705245,1705856,1707213,1707825,1708433,1709045,1709656,1711012,1711624,1712234,1712845,1713456,1714813,1715424,1716035,1716646,1717258,1718613,1719225,1719836,1720446,1721058,1722415,1723026,1723637,1724247,1724858,1726215,1726826,1727438,1728046,1728658,1730015,1730625,1731237,1731847,1732458,1733815,1734425,1735036,1735647,1736258,1737617,1745613,1746225,1746836,1747446,1748805,1749415,1750026,1750637,1751247,1752604,1753215,1753826,1754438,1755046,1756403,1757014,1757624,1758236,1758846,1760202,1760813,1761423,1762034,1762645,1764002,1764614,1765222,1765834,1766445,1767801,1768413,1769023,1769634,1770245,1771602,1772213,1772824,1773435,1774047,1775402,1776014,1776625,1777235,1777847,1779204,1779815,1780426,1781036,1781647,1783004,1791002,1791614,1792222,1792834,1794191,1794801,1795413,1796023,1796634,1797991,1798601,1799212,1799823,1800434,1801793,1802401,1803013,1803624,1804234,1805593,1806203,1806814,1807425,1808035,1809392,1810003,1810614,1811226,1811834,1813191,1813802,1814412,1815024,1815634,1816990,1817601,1818211,1818822,1819433,1820790,1821402,1822010,1822622,1823233,1824589,1825201,1825811,1826422,1827033,1828390,1836388,1836999,1837610,1838222,1839577,1840189,1840800,1841410,1842022,1857407,1872791,1888176,1903560,1918945,1920302,1920913,1921525,1922133,1922745,1924102,1924712,1925324,1925934,1926545,1927902,1928512,1929123,1929734,1930345,1931704,1932312,1932924,1933535,1934145,1935504,1936114,1936725,1937336,1937946,1939303,1939914,1940525,1941137,1941745,1943102,1943713,1944323,1944935,1945545,1946901,1954898,1955508,1956119,1956730,1958087,1958699,1959307,1959919,1960530,1961886,1962498,1963108,1963719,1964330,1965687,1966298,1966909,1967520,1968132,1969487,1970099,1970710,1971320,1971932,1973289,1973900,1974511,1975121,1975732,1977089,1977700,1978312,1978920,1979532,1980889,1981499,1982111,1982721,1983332,1984689,1985299,1985910,1986521,1987132,1988491,1989099,1989711,1990322,1990932,1992291,2000288,2000899,2001510,2002120,2003477,2004088,2004699,2005311,2005919,2007276,2007887,2008497,2009109,2009719,2011075,2011686,2012296,2012907,2013518,2014875,2015487,2016095,2016707,2017318,2018674,2019286,2019896,2020507,2021118,2022475,2023086,2023697,2024308,2024920,2026275,2026887,2027498,2028108,2028720,2030077,2030688,2031299,2031909,2032520,2033877,2034488,2035100,2035708,2036320,2037677,2045674,2046286,2046896,2047507,2048864,2049474,2050085,2050696,2051307,2052666,2053274,2053886,2054497,2055107,2056466,2057076,2057687,2058298,2058908,2060265,2060876,2061487,2062099,2062707,2064064,2064675,2065285,2065897,2066507,2067863,2068474,2069084,2069695,2070306,2071663,2072275,2072883,2073495,2074106,2075462,2076074,2076684,2077295,2077906,2079263,2079874,2080485,2081096,2081708,2083063,2091062,2091673,2092283,2092895,2094252,2094863,2095474,2096084,2096695,2098052,2098663,2099275,2099883,2100495,2101852,2102462,2103074,2103684,2104295,2105652,2106262,2106873,2107484,2108095,2109454,2110062,2110674,2111285,2111895,2113254,2113864,2114475,2115086,2115696,2117053,2117664,2118275,2118887,2119495,2120852,2121463,2122073,2122685,2123295,2124651,2125262,2125872,2126483,2127094,2128451,2136449,2137057,2137669,2138280,2139636,2140248,2140858,2141469,2142080,2143437,2144048,2144659,2145270,2145882,2147237,2147849,2148460,2149070,2149682,2151039,2151650,2152261,2152871,2153482,2154839,2155450,2156062,2156670,2157282,2158639,2159249,2159861,2160471,2161082,2162439,2163049,2163660,2164271,2164882,2166241,2166849,2167461,2168072,2168682,2170041,2170651,2171262,2171873,2172483,2173840,2181838,2182449,2183061,2183669,2185026,2185637,2186247,2186859,2187469,2188825,2189436,2190046,2190657,2191268,2192625,2193237,2193845,2194457,2195068,2196424,2197036,2197646,2198257,2198868,2200225,2200836,2201447,2202058,2202670,2204025,2204637,2205248,2205858,2206470,2207827,2208438,2209049,2209659,2210270,2211627,2212238,2212850,2213458,2214070,2215427,2216037,2216649,2217259,2217870,2219227,2227224,2227835,2228446,2229057,2230416,2231024,2231636,2232247,2232857,2234216,2234826,2235437,2236048,2236658,2238015,2238626,2239237,2239849,2240457,2241814,2242425,2243035,2243647,2244257,2245613,2246224,2246834,2247445,2248056,2249413,2250025,2250633,2251245,2251856,2253212,2253824,2254434,2255045,2255656,2257013,2257624,2258235,2258846,2259458,2260813,2261425,2262036,2262646,2263258,2264615,2272614,2273225,2273835,2274446,2275803,2276414,2277026,2277634,2278246,2279603,2280213,2280825,2281435,2282046,2283403,2284013,2284624,2285235,2285846,2287205,2287813,2288425,2289036,2289646,2291005,2291615,2292226,2292837,2293447,2294804,2295415,2296026,2296638,2297246,2298603,2299214,2299824,2300436,2301046,2302402,2303013,2303623,2304234,2304845,2306202,2306814,2307422,2308034,2308645,2310001,2317999,2318609,2319220,2319831,2321188,2321799,2322410,2323021,2323633,2324988,2325600,2326211,2326821,2327433,2328790,2329401,2330012,2330622,2331233,2332590,2333201,2333813,2334421,2335033,2336390,2337000,2337612,2338222,2338833,2340190,2340800,2341411,2342022,2342633,2343992,2344600,2345212,2345823,2346433,2347792,2348402,2349013,2349624,2350234,2351591,2352202,2352813,2353425,2354033,2355390,2363388,2363998,2364610,2365220,2366576,2367187,2367797,2368408,2369019,2384403,2399788,2415172,2430557,2445942,2447298,2447910,2448520,2449131,2449742,2451099,2451710,2452321,2452932,2453544,2454899,2455511,2456122,2456732,2457344,2458701,2459312,2459923,2460533,2461144,2462501,2463112,2463724,2464332,2464944,2466301,2466911,2467523,2468133,2468744,2470101,2470711,2471322,2471933,2472544,2473903,2481899,2482511,2483122,2483732,2485091,2485701,2486312,2486923,2487533,2488890,2489501,2490112,2490724,2491332,2492689,2493300,2493910,2494522,2495132,2496488,2497099,2497709,2498320,2498931,2500288,2500900,2501508,2502120,2502731,2504087,2504699,2505309,2505920,2506531,2507888,2508499,2509110,2509721,2510333,2511688,2512300,2512911,2513521,2514133,2515490,2516101,2516712,2517322,2517933,2519290,2527288,2527900,2528508,2529120,2530477,2531087,2531699,2532309,2532920,2534277,2534887,2535498,2536109,2536720,2538079,2538687,2539299,2539910,2540520,2541879,2542489,2543100,2543711,2544321,2545678,2546289,2546900,2547512,2548120,2549477,2550088,2550698,2551310,2551920,2553276,2553887,2554497,2555108,2555719,2557076,2557688,2558296,2558908,2559519,2560875,2561487,2562097,2562708,2563319,2564676,2572674,2573285,2573896,2574508,2575863,2576475,2577086,2577696,2578308,2579665,2580276,2580887,2581497,2582108,2583465,2584076,2584688,2585296,2585908,2587265,2587875,2588487,2589097,2589708,2591065,2591675,2592286,2592897,2593508,2594867,2595475,2596087,2596698,2597308,2598667,2599277,2599888,2600499,2601109,2602466,2603077,2603688,2604300,2604908,2606265,2606876,2607486,2608098,2608708,2610064,2618061,2618671,2619282,2619893,2621250,2621862,2622470,2623082,2623693,2625049,2625661,2626271,2626882,2627493,2628850,2629461,2630072,2630683,2631295,2632650,2633262,2633873,2634483,2635095,2636452,2637063,2637674,2638284,2638895,2640252,2640863,2641475,2642083,2642695,2644052,2644662,2645274,2645884,2646495,2647852,2648462,2649073,2649684,2650295,2651654,2652262,2652874,2653485,2654095,2655454,2663451,2664062,2664673,2665283,2666640,2667251,2667862,2668474,2669082,2670439,2671050,2671660,2672272,2672882,2674238,2674849,2675459,2676070,2676681,2678038,2678650,2679258,2679870,2680481,2681837,2682449,2683059,2683670,2684281,2685638,2686249,2686860,2687471,2688083,2689438,2690050,2690661,2691271,2691883,2693240,2693851,2694462,2695072,2695683,2697040,2697651,2698263,2698871,2699483,2700840,2708837,2709449,2710059,2710670,2712027,2712637,2713248,2713859,2714470,2715829,2716437,2717049,2717660,2718270,2719629,2720239,2720850,2721461,2722071,2723428,2724039,2724650,2725262,2725870,2727227,2727838,2728448,2729060,2729670,2731026,2731637,2732247,2732858,2733469,2734826,2735438,2736046,2736658,2737269,2738625,2739237,2739847,2740458,2741069,2742426,2743037,2743648,2744259,2744871,2746226,2754225,2754836,2755446,2756058,2757415,2758026,2758637,2759247,2759858,2761215,2761826,2762438,2763046,2763658,2765015,2765625,2766237,2766847,2767458,2768815,2769425,2770036,2770647,2771258,2772617,2773225,2773837,2774448,2775058,2776417,2777027,2777638,2778249,2778859,2780216,2780827,2781438,2782050,2782658,2784015,2784626,2785236,2785848,2786458,2787814,2788425,2789035,2789646,2790257,2791614,2799612,2800220,2800832,2801443,2802799,2803411,2804021,2804632,2805243,2806600,2807211,2807822,2808433,2809045,2810400,2811012,2811623,2812233,2812845,2814202,2814813,2815424,2816034,2816645,2818002,2818613,2819225,2819833,2820445,2821802,2822412,2823024,2823634,2824245,2825602,2826212,2826823,2827434,2828045,2829404,2830012,2830624,2831235,2831845,2833204,2833814,2834425,2835036,2835646,2837003,2845001,2845612,2846224,2846832,2848189,2848800,2849410,2850022,2850632,2851988,2852599,2853209,2853820,2854431,2855788,2856400,2857008,2857620,2858231,2859587,2860199,2860809,2861420,2862031,2863388,2863999,2864610,2865221,2865833,2867188,2867800,2868411,2869021,2869633,2870990,2871601,2872212,2872822,2873433,2874790,2875401,2876013,2876621,2877233,2878590,2879200,2879812,2880422,2881033,2882390,2890387,2890998,2891609,2892220,2893579,2894187,2894799,2895410,2896020,2911405,2926790,2942174,2957559,2972943,2974300,2974911,2975522,2976134,2976742,2978099,2978710,2979320,2979932,2980542,2981898,2982509,2983119,2983730,2984341,2985698,2986310,2986918,2987530,2988141,2989497,2990109,2990719,2991330,2991941,2993298,2993909,2994520,2995131,2995743,2997098,2997710,2998321,2998931,2999543,3000900,3008899,3009510,3010120,3010731,3012088,3012699,3013311,3013919,3014531,3015888,3016498,3017110,3017720,3018331,3019688,3020298,3020909,3021520,3022131,3023490,3024098,3024710,3025321,3025931,3027290,3027900,3028511,3029122,3029732,3031089,3031700,3032311,3032923,3033531,3034888,3035499,3036109,3036721,3037331,3038687,3039298,3039908,3040519,3041130,3042487,3043099,3043707,3044319,3044930,3046286,3054284,3054894,3055505,3056116,3057473,3058084,3058695,3059306,3059918,3061273,3061885,3062496,3063106,3063718,3065075,3065686,3066297,3066907,3067518,3068875,3069486,3070098,3070706,3071318,3072675,3073285,3073897,3074507,3075118,3076475,3077085,3077696,3078307,3078918,3080277,3080885,3081497,3082108,3082718,3084077,3084687,3085298,3085909,3086519,3087876,3088487,3089098,3089710,3090318,3091675,3099673,3100283,3100895,3101505,3102861,3103472,3104082,3104693,3105304,3106661,3107273,3107881,3108493,3109104,3110460,3111072,3111682,3112293,3112904,3114261,3114872,3115483,3116094,3116706,3118061,3118673,3119284,3119894,3120506,3121863,3122474,3123085,3123695,3124306,3125663,3126274,3126886,3127494,3128106,3129463,3130073,3130685,3131295,3131906,3133263,3133873,3134484,3135095,3135706,3137065,3145061,3145673,3146284,3146894,3148253,3148863,3149474,3150085,3150695,3152052,3152663,3153274,3153886,3154494,3155851,3156462,3157072,3157684,3158294,3159650,3160261,3160871,3161482,3162093,3163450,3164062,3164670,3165282,3165893,3167249,3167861,3168471,3169082,3169693,3171050,3171661,3172272,3172883,3173495,3174850,3175462,3176073,3176683,3177295,3178652,3179263,3179874,3180484,3181095,3182452,3190450,3191062,3191670,3192282,3193639,3194249,3194861,3195471,3196082,3197439,3198049,3198660,3199271,3199882,3201241,3201849,3202461,3203072,3203682,3205041,3205651,3206262,3206873,3207483,3208840,3209451,3210062,3210674,3211282,3212639,3213250,3213860,3214472,3215082,3216438,3217049,3217659,3218270,3218881,3220238,3220850,3221458,3222070,3222681,3224037,3224649,3225259,3225870,3226481,3227838,3235836,3236447,3237058,3237670,3239025,3239637,3240248,3240858,3241470,3242827,3243438,3244049,3244659,3245270,3246627,3247238,3247850,3248458,3249070,3250427,3251037,3251649,3252259,3252870,3254227,3254837,3255448,3256059,3256670,3258029,3258637,3259249,3259860,3260470,3261829,3262439,3263050,3263661,3264271,3265628,3266239,3266850,3267462,3268070,3269427,3270038,3270648,3271260,3271870,3273226,3281223,3281833,3282444,3283055,3284412,3285024,3285632,3286244,3286855,3288211,3288823,3289433,3290044,3290655,3292012,3292623,3293234,3293845,3294457,3295812,3296424,3297035,3297645,3298257,3299614,3300225,3300836,3301446,3302057,3303414,3304025,3304637,3305245,3305857,3307214,3307824,3308436,3309046,3309657,3311014,3311624,3312235,3312846,3313457,3314816,3315424,3316036,3316647,3317257,3318616,3326613,3327224,3327835,3328445,3329802,3330413,3331024,3331636,3332244,3333601,3334212,3334822,3335434,3336044,3337400,3338011,3338621,3339232,3339843,3341200,3341812,3342420,3343032,3343643,3344999,3345611,3346221,3346832,3347443,3348800,3349411,3350022,3350633,3351245,3352600,3353212,3353823,3354433,3355045,3356402,3357013,3357624,3358234,3358845,3360202,3360813,3361425,3362033,3362645,3364002,3371999,3372611,3373221,3373832,3375189,3375799,3376410,3377021,3377632,3378991,3379599,3380211,3380822,3381432,3382791,3383401,3384012,3384623,3385233,3386590,3387201,3387812,3388424,3389032,3390389,3391000,3391610,3392222,3392832,3394188,3394799,3395409,3396020,3396631,3397988,3398600,3399208,3399820,3400431,3401787,3402399,3403009,3403620,3404231,3405588,3406199,3406810,3407421,3408033,3409388,3417387,3417998,3418608,3419220,3420577,3421188,3421799,3422409,3423020,3438405,3453789,3469174,3484558,3499943,3501300,3501910,3502522,3503132,3503743,3505100,3505710,3506321,3506932,3507543,3508902,3509510,3510122,3510733,3511343,3512702,3513312,3513923,3514534,3515144,3516501,3517112,3517723,3518335,3518943,3520300,3520911,3521521,3522133,3522743,3524099,3524710,3525320,3525931,3526542,3527899,3535897,3536505,3537117,3537728,3539084,3539696,3540306,3540917,3541528,3542885,3543496,3544107,3544718,3545330,3546685,3547297,3547908,3548518,3549130,3550487,3551098,3551709,3552319,3552930,3554287,3554898,3555510,3556118,3556730,3558087,3558697,3559309,3559919,3560530,3561887,3562497,3563108,3563719,3564330,3565689,3566297,3566909,3567520,3568130,3569489,3570099,3570710,3571321,3571931,3573288,3581286,3581897,3582509,3583117,3584474,3585085,3585695,3586307,3586917,3588273,3588884,3589494,3590105,3590716,3592073,3592685,3593293,3593905,3594516,3595872,3596484,3597094,3597705,3598316,3599673,3600284,3600895,3601506,3602118,3603473,3604085,3604696,3605306,3605918,3607275,3607886,3608497,3609107,3609718,3611075,3611686,3612298,3612906,3613518,3614875,3615485,3616097,3616707,3617318,3618675,3626672,3627283,3627894,3628505,3629864,3630472,3631084,3631695,3632305,3633664,3634274,3634885,3635496,3636106,3637463,3638074,3638685,3639297,3639905,3641262,3641873,3642483,3643095,3643705,3645061,3645672,3646282,3646893,3647504,3648861,3649473,3650081,3650693,3651304,3652660,3653272,3653882,3654493,3655104,3656461,3657072,3657683,3658294,3658906,3660261,3660873,3661484,3662094,3662706,3664063,3672062,3672673,3673283,3673894,3675251,3675862,3676474,3677082,3677694,3679051,3679661,3680273,3680883,3681494,3682851,3683461,3684072,3684683,3685294,3686653,3687261,3687873,3688484,3689094,3690453,3691063,3691674,3692285,3692895,3694252,3694863,3695474,3696086,3696694,3698051,3698662,3699272,3699884,3700494,3701850,3702461,3703071,3703682,3704293,3705650,3706262,3706870,3707482,3708093,3709449,3717447,3718057,3718668,3719279,3720636,3721247,3721858,3722469,3723081,3724436,3725048,3725659,3726269,3726881,3728238,3728849,3729460,3730070,3730681,3732038,3732649,3733261,3733869,3734481,3735838,3736448,3737060,3737670,3738281,3739638,3740248,3740859,3741470,3742081,3743440,3744048,3744660,3745271,3745881,3747240,3747850,3748461,3749072,3749682,3751039,3751650,3752261,3752873,3753481,3754838,3762836,3763446,3764058,3764668,3766024,3766635,3767245,3767856,3768467,3769824,3770436,3771044,3771656,3772267,3773623,3774235,3774845,3775456,3776067,3777424,3778035,3778646,3779257,3779869,3781224,3781836,3782447,3783057,3783669,3785026,3785637,3786248,3786858,3787469,3788826,3789437,3790049,3790657,3791269,3792626,3793236,3793848,3794458,3795069,3796426,3797036,3797647,3798258,3798869,3800228,3808224,3808836,3809447,3810057,3811416,3812026,3812637,3813248,3813858,3815215,3815826,3816437,3817049,3817657,3819014,3819625,3820235,3820847,3821457,3822813,3823424,3824034,3824645,3825256,3826613,3827225,3827833,3828445,3829056,3830412,3831024,3831634,3832245,3832856,3834213,3834824,3835435,3836046,3836658,3838013,3838625,3839236,3839846,3840458,3841815,3842426,3843037,3843647,3844258,3845615,3853613,3854225,3854833,3855445,3856802,3857412,3858024,3858634,3859245,3860602,3861212,3861823,3862434,3863045,3864404,3865012,3865624,3866235,3866845,3868204,3868814,3869425,3870036,3870646,3872003,3872614,3873225,3873837,3874445,3875802,3876413,3877023,3877635,3878245,3879601,3880212,3880822,3881433,3882044,3883401,3884013,3884621,3885233,3885844,3887200,3887812,3888422,3889033,3889644,3891001,3898999,3899610,3900221,3900833,3902188,3902800,3903411,3904021,3904633,3905990,3906601,3907212,3907822,3908433,3909790,3910401,3911013,3911621,3912233,3913590,3914200,3914812,3915422,3916033,3917390,3918000,3918611,3919222,3919833,3921192,3921800,3922412,3923023,3923633,3924992,3925602,3926213,3926824,3927434,3928791,3929402,3930013,3930625,3931233,3932590,3933201,3933811,3934423,3935033,3936389,3944386,3944996,3945607,3946218,3947575,3948187,3948795,3949407,3950018,3965402,3980787,3996172,4011556,4026941,4028298,4028909,4029520,4030131,4030743,4032098,4032710,4033321,4033931,4034543,4035900,4036511,4037122,4037732,4038343,4039700,4040311,4040923,4041531,4042143,4043500,4044110,4044722,4045332,4045943,4047300,4047910,4048521,4049132,4049743,4051102,4051710,4052322,4052933,4053543,4054902,4062899,4063510,4064121,4064731,4066088,4066699,4067310,4067922,4068530,4069887,4070498,4071108,4071720,4072330,4073686,4074297,4074907,4075518,4076129,4077486,4078098,4078706,4079318,4079929,4081285,4081897,4082507,4083118,4083729,4085086,4085697,4086308,4086919,4087531,4088886,4089498,4090109,4090719,4091331,4092688,4093299,4093910,4094520,4095131,4096488,4097099,4097711,4098319,4098931,4100288,4108285,4108897,4109507,4110118,4111475,4112085,4112696,4113307,4113918,4115277,4115885,4116497,4117108,4117718,4119077,4119687,4120298,4120909,4121519,4122876,4123487,4124098,4124710,4125318,4126675,4127286,4127896,4128508,4129118,4130474,4131085,4131695,4132306,4132917,4134274,4134886,4135494,4136106,4136717,4138073,4138685,4139295,4139906,4140517,4141874,4142485,4143096,4143707,4144319,4145674,4153673,4154284,4154894,4155506,4156863,4157474,4158085,4158695,4159306,4160663,4161274,4161886,4162494,4163106,4164463,4165073,4165685,4166295,4166906,4168263,4168873,4169484,4170095,4170706,4172065,4172673,4173285,4173896,4174506,4175865,4176475,4177086,4177697,4178307,4179664,4180275,4180886,4181498,4182106,4183463,4184074,4184684,4185296,4185906,4187262,4187873,4188483,4189094,4189705,4191062,4199060,4199668,4200280,4200891,4202247,4202859,4203469,4204080,4204691,4206048,4206659,4207270,4207881,4208493,4209848,4210460,4211071,4211681,4212293,4213650,4214261,4214872,4215482,4216093,4217450,4218061,4218673,4219281,4219893,4221250,4221860,4222472,4223082,4223693,4225050,4225660,4226271,4226882,4227493,4228852,4229460,4230072,4230683,4231293,4232652,4233262,4233873,4234484,4235094,4236451,4244449,4245060,4245672,4246280,4247637,4248248,4248858,4249470,4250080,4251436,4252047,4252657,4253268,4253879,4255236,4255848,4256456,4257068,4257679,4259035,4259647,4260257,4260868,4261479,4262836,4263447,4264058,4264669,4265281,4266636,4267248,4267859,4268469,4269081,4270438,4271049,4271660,4272270,4272881,4274238,4274849,4275461,4276069,4276681,4278038,4278648,4279260,4279870,4280481,4281838,4289835,4290446,4291057,4291668,4293027,4293635,4294247,4294858,4295468,4296827,4297437,4298048,4298659,4299269,4300626,4301237,4301848,4302460,4303068,4304425,4305036,4305646,4306258,4306868,4308224,4308835,4309445,4310056,4310667,4312024,4312636,4313244,4313856,4314467,4315823,4316435,4317045,4317656,4318267,4319624,4320235,4320846,4321457,4322069,4323424,4324036,4324647,4325257,4325869,4327226,4335225,4335836,4336446,4337057,4338414,4339025,4339637,4340245,4340857,4342214,4342824,4343436,4344046,4344657,4346014,4346624,4347235,4347846,4348457,4349816,4350424,4351036,4351647,4352257,4353616,4354226,4354837,4355448,4356058,4357415,4358026,4358637,4359249,4359857,4361214,4361825,4362435,4363047,4363657,4365013,4365624,4366234,4366845,4367456,4368813,4369425,4370033,4370645,4371256,4372612,4380610,4381220,4381831,4382442,4383799,4384410,4385021,4385632,4386244,4387599,4388211,4388822,4389432,4390044,4391401,4392012,4392623,4393233,4393844,4395201,4395812,4396424,4397032,4397644,4399001,4399611,4400223,4400833,4401444,4402801,4403411,4404022,4404633,4405244,4406603,4407211,4407823,4408434,4409044,4410403,4411013,4411624,4412235,4412845,4414202,4414813,4415424,4416036,4416644,4418001,4425999,4426609,4427221,4427831,4429187,4429798,4430408,4431019,4431630,4432987,4433599,4434207,4434819,4435430,4436786,4437398,4438008,4438619,4439230,4440587,4441198,4441809,4442420,4443032,4444387,4444999,4445610,4446220,4446832,4448189,4448800,4449411,4450021,4450632,4451989,4452600,4453212,4453820,4454432,4455789,4456399,4457011,4457621,4458232,4459589,4460199,4460810,4461421,4462032,4463391,4471387,4471999,4472610,4473220,4474579,4475189,4475800,4476411,4477021,4492406,4507791,4523175,4538560,4553944,4555301,4555912,4556522,4557134,4557744,4559100,4559711,4560321,4560932,4561543,4562900,4563512,4564120,4564732,4565343,4566699,4567311,4567921,4568532,4569143,4570500,4571111,4571722,4572333,4572945,4574300,4574912,4575523,4576133,4576745,4578102,4578713,4579324,4579934,4580545,4581902,4589900,4590512,4591120,4591732,4593089,4593699,4594311,4594921,4595532,4596889,4597499,4598110,4598721,4599332,4600691,4601299,4601911,4602522,4603132,4604491,4605101,4605712,4606323,4606933,4608290,4608901,4609512,4610124,4610732,4612089,4612700,4613310,4613922,4614532,4615888,4616499,4617109,4617720,4618331,4619688,4620300,4620908,4621520,4622131,4623487,4624099,4624709,4625320,4625931,4627288,4635286,4635897,4636508,4637120,4638475,4639087,4639698,4640308,4640920,4642277,4642888,4643499,4644109,4644720,4646077,4646688,4647300,4647908,4648520,4649877,4650487,4651099,4651709,4652320,4653677,4654287,4654898,4655509,4656120,4657479,4658087,4658699,4659310,4659920,4661279,4661889,4662500,4663111,4663721,4665078,4665689,4666300,4666912,4667520,4668877,4669488,4670098,4670710,4671320,4672676,4680673,4681283,4681894,4682505,4683862,4684474,4685082,4685694,4686305,4687661,4688273,4688883,4689494,4690105,4691462,4692073,4692684,4693295,4693907,4695262,4695874,4696485,4697095,4697707,4699064,4699675,4700286,4700896,4701507,4702864,4703475,4704087,4704695,4705307,4706664,4707274,4707886,4708496,4709107,4710464,4711074,4711685,4712296,4712907,4714266,4714874,4715486,4716097,4716707,4718066,4726063,4726674,4727285,4727895,4729252,4729863,4730474,4731086,4731694,4733051,4733662,4734272,4734884,4735494,4736850,4737461,4738071,4738682,4739293,4740650,4741262,4741870,4742482,4743093,4744449,4745061,4745671,4746282,4746893,4748250,4748861,4749472,4750083,4750695,4752050,4752662,4753273,4753883,4754495,4755852,4756463,4757074,4757684,4758295,4759652,4760263,4760875,4761483,4762095,4763452,4771449,4772061,4772671,4773282,4774639,4775249,4775860,4776471,4777082,4778441,4779049,4779661,4780272,4780882,4782241,4782851,4783462,4784073,4784683,4786040,4786651,4787262,4787874,4788482,4789839,4790450,4791060,4791672,4792282,4793638,4794249,4794859,4795470,4796081,4797438,4798050,4798658,4799270,4799881,4801237,4801849,4802459,4803070,4803681,4805038,4805649,4806260,4806871,4807483,4808838,4816837,4817448,4818058,4818670,4820027,4820638,4821249,4821859,4822470,4823827,4824438,4825050,4825658,4826270,4827627,4828237,4828849,4829459,4830070,4831427,4832037,4832648,4833259,4833870,4835229,4835837,4836449,4837060,4837670,4839029,4839639,4840250,4840861,4841471,4842828,4843439,4844050,4844662,4845270,4846627,4847238,4847848,4848460,4849070,4850426,4851037,4851647,4852258,4852869,4854226,4862224,4862832,4863444,4864055,4865411,4866023,4866633,4867244,4867855,4869212,4869823,4870434,4871045,4871657,4873012,4873624,4874235,4874845,4875457,4876814,4877425,4878036,4878646,4879257,4880614,4881225,4881837,4882445,4883057,4884414,4885024,4885636,4886246,4886857,4888214,4888824,4889435,4890046,4890657,4892016,4892624,4893236,4893847,4894457,4895816,4896426,4897037,4897648,4898258,4899615,4907613,4908224,4908836,4909444,4910801,4911412,4912022,4912634,4913244,4914600,4915211,4915821,4916432,4917043,4918400,4919012,4919620,4920232,4920843,4922199,4922811,4923421,4924032,4924643,4926000,4926611,4927222,4927833,4928445,4929800,4930412,4931023,4931633,4932245,4933602,4934213,4934824,4935434,4936045,4937402,4938013,4938625,4939233,4939845,4941202,4941812,4942424,4943034,4943645,4945002,4952999,4953610,4954221,4954832,4956191,4956799,4957411,4958022,4958632,4959991,4960601,4961212,4961823,4962433,4963790,4964401,4965012,4965624,4966232,4967589,4968200,4968810,4969422,4970032,4971388,4971999,4972609,4973220,4973831,4975188,4975800,4976408,4977020,4977631,4978987,4979599,4980209,4980820,4981431,4982788,4983399,4984010,4984621,4985233,4986588,4987200,4987811,4988421,4989033,4990390,4998389,4999000,4999610,5000221,5001578,5002189,5002801,5003409,5004021,5019406,5034790,5050175,5065560,5080944,5082301,5082911,5083522,5084133,5084744,5086103,5086711,5087323,5087934,5088544,5089903,5090513,5091124,5091735,5092345,5093702,5094313,5094924,5095536,5096144,5097501,5098112,5098722,5099334,5099944,5101300,5101911,5102521,5103132,5103743,5105100,5105712,5106320,5106932,5107543,5108899,5116897,5117507,5118118,5118729,5120086,5120697,5121308,5121919,5122531,5123886,5124498,5125109,5125719,5126331,5127688,5128299,5128910,5129520,5130131,5131488,5132099,5132711,5133319,5133931,5135288,5135898,5136510,5137120,5137731,5139088,5139698,5140309,5140920,5141531,5142890,5143498,5144110,5144721,5145331,5146690,5147300,5147911,5148522,5149132,5150489,5151100,5151711,5152323,5152931,5154288,5162286,5162896,5163508,5164118,5165474,5166085,5166695,5167306,5167917,5169274,5169886,5170494,5171106,5171717,5173073,5173685,5174295,5174906,5175517,5176874,5177485,5178096,5178707,5179319,5180674,5181286,5181897,5182507,5183119,5184476,5185087,5185698,5186308,5186919,5188276,5188887,5189499,5190107,5190719,5192076,5192686,5193298,5193908,5194519,5195876,5196486,5197097,5197708,5198319,5199678,5207674,5208286,5208897,5209507,5210866,5211476,5212087,5212698,5213308,5214665,5215276,5215887,5216499,5217107,5218464,5219075,5219685,5220297,5220907,5222263,5222874,5223484,5224095,5224706,5226063,5226675,5227283,5227895,5228506,5229862,5230474,5231084,5231695,5232306,5233663,5234274,5234885,5235496,5236108,5237463,5238075,5238686,5239296,5239908,5241265,5241876,5242487,5243097,5243708,5245065,5253063,5253675,5254283,5254895,5256252,5256862,5257474,5258084,5258695,5260052,5260662,5261273,5261884,5262495,5263854,5264462,5265074,5265685,5266295,5267654,5268264,5268875,5269486,5270096,5271453,5272064,5272675,5273287,5273895,5275252,5275863,5276473,5277085,5277695,5279051,5279662,5280272,5280883,5281494,5282851,5283463,5284071,5284683,5285294,5286650,5287262,5287872,5288483,5289094,5290451,5298449,5299060,5299671,5300283,5301638,5302250,5302861,5303471,5304083,5305440,5306051,5306662,5307272,5307883,5309240,5309851,5310463,5311071,5311683,5313040,5313650,5314262,5314872,5315483,5316840,5317450,5318061,5318672,5319283,5320642,5321250,5321862,5322473,5323083,5324442,5325052,5325663,5326274,5326884,5328241,5328852,5329463,5330075,5330683,5332040,5332651,5333261,5333873,5334483,5335839,5343836,5344446,5345057,5345668,5347025,5347637,5348245,5348857,5349468,5350824,5351436,5352046,5352657,5353268,5354625,5355236,5355847,5356458,5357070,5358425,5359037,5359648,5360258,5360870,5362227,5362838,5363449,5364059,5364670,5366027,5366638,5367250,5367858,5368470,5369827,5370437,5371049,5371659,5372270,5373627,5374237,5374848,5375459,5376070,5377429,5378037,5378649,5379260,5379870,5381229,5389226,5389837,5390448,5391058,5392415,5393026,5393637,5394249,5394857,5396214,5396825,5397435,5398047,5398657,5400013,5400624,5401234,5401845,5402456,5403813,5404425,5405033,5405645,5406256,5407612,5408224,5408834,5409445,5410056,5411413,5412024,5412635,5413246,5413858,5415213,5415825,5416436,5417046,5417658,5419015,5419626,5420237,5420847,5421458,5422815,5423426,5424038,5424646,5425258,5426615,5434612,5435224,5435834,5436445,5437802,5438412,5439023,5439634,5440245,5441604,5442212,5442824,5443435,5444045,5445404,5446014,5446625,5447236,5447846,5449203,5449814,5450425,5451037,5451645,5453002,5453613,5454223,5454835,5455445,5456801,5457412,5458022,5458633,5459244,5460601,5461213,5461821,5462433,5463044,5464400,5465012,5465622,5466233,5466844,5468201,5468812,5469423,5470034,5470646,5472001,5480000,5480611,5481221,5481833,5483190,5483801,5484412,5485022,5485633,5486990,5487601,5488213,5488821,5489433,5490790,5491400,5492012,5492622,5493233,5494590,5495200,5495811,5496422,5497033,5498392,5499000,5499612,5500223,5500833,5502192,5502802,5503413,5504024,5504634,5505991,5506602,5507213,5507825,5508433,5509790,5510401,5511011,5511623,5512233,5513589,5514200,5514810,5515421,5516032,5517389,5525387,5525995,5526607,5527218,5528574,5529186,5529796,5530407,5531018,5546402,5561787,5577172,5592556,5607941,5609296,5609908,5610519,5611129,5611741,5613098,5613709,5614320,5614930,5615541,5616898,5617509,5618121,5618729,5619341,5620698,5621308,5621920,5622530,5623141,5624498,5625108,5625719,5626330,5626941,5628300,5628908,5629520,5630131,5630741,5632100,5632710,5633321,5633932,5634542,5635899,5643897,5644508,5645120,5645728,5647085,5647696,5648306,5648918,5649528,5650884,5651495,5652105,5652716,5653327,5654684,5655296,5655904,5656516,5657127,5658483,5659095,5659705,5660316,5660927,5662284,5662895,5663506,5664117,5664729,5666084,5666696,5667307,5667917,5668529,5669886,5670497,5671108,5671718,5672329,5673686,5674297,5674909,5675517,5676129,5677486,5678096,5678708,5679318,5679929,5681286,5689283,5689894,5690505,5691116,5692475,5693083,5693695,5694306,5694916,5696275,5696885,5697496,5698107,5698717,5700074,5700685,5701296,5701908,5702516,5703873,5704484,5705094,5705706,5706316,5707672,5708283,5708893,5709504,5710115,5711472,5712084,5712692,5713304,5713915,5715271,5715883,5716493,5717104,5717715,5719072,5719683,5720294,5720905,5721517,5722872,5723484,5724095,5724705,5725317,5726674,5734673,5735284,5735894,5736505,5737862,5738473,5739085,5739693,5740305,5741662,5742272,5742884,5743494,5744105,5745462,5746072,5746683,5747294,5747905,5749264,5749872,5750484,5751095,5751705,5753064,5753674,5754285,5754896,5755506,5756863,5757474,5758085,5758697,5759305,5760662,5761273,5761883,5762495,5763105,5764461,5765072,5765682,5766293,5766904,5768261,5768873,5769481,5770093,5770704,5772060,5780058,5780668,5781279,5781890,5783247,5783858,5784469,5785080,5785692,5787047,5787659,5788270,5788880,5789492,5790849,5791460,5792071,5792681,5793292,5794649,5795260,5795872,5796480,5797092,5798449,5799059,5799671,5800281,5800892,5802249,5802859,5803470,5804081,5804692,5806051,5806659,5807271,5807882,5808492,5809851,5810461,5811072,5811683,5812293,5813650,5814261,5814872,5815484,5816092,5817449,5825447,5826057,5826669,5827279,5828635,5829246,5829856,5830467,5831078,5832435,5833047,5833655,5834267,5834878,5836234,5836846,5837456,5838067,5838678,5840035,5840646,5841257,5841868,5842480,5843835,5844447,5845058,5845668,5846280,5847637,5848248,5848859,5849469,5850080,5851437,5852048,5852660,5853268,5853880,5855237,5855847,5856459,5857069,5857680,5859037,5859647,5860258,5860869,5861480,5862839,5870835,5871447,5872058,5872668,5874027,5874637,5875248,5875859,5876469,5877826,5878437,5879048,5879660,5880268,5881625,5882236,5882846,5883458,5884068,5885424,5886035,5886645,5887256,5887867,5889224,5889836,5890444,5891056,5891667,5893023,5893635,5894245,5894856,5895467,5896824,5897435,5898046,5898657,5899269,5900624,5901236,5901847,5902457,5903069,5904426,5905037,5905648,5906258,5906869,5908226,5916224,5916836,5917444,5918056,5919413,5920023,5920635,5921245,5921856,5923213,5923823,5924434,5925045,5925656,5927015,5927623,5928235,5928846,5929456,5930815,5931425,5932036,5932647,5933257,5934614,5935225,5935836,5936448,5937056,5938413,5939024,5939634,5940246,5940856,5942212,5942823,5943433,5944044,5944655,5946012,5946624,5947232,5947844,5948455,5949811,5950423,5951033,5951644,5952255,5953612,5961610,5962221,5962832,5963444,5964799,5965411,5966022,5966632,5967244,5968601,5969212,5969823,5970433,5971044,5972401,5973012,5973624,5974232,5974844,5976201,5976811,5977423,5978033,5978644,5980001,5980611,5981222,5981833,5982444,5983803,5984411,5985023,5985634,5986244,5987603,5988213,5988824,5989435,5990045,5991402,5992013,5992624,5993236,5993844}; int OK(int n) { int temp=n,x; int f=0; while(temp){ x=temp%10; if(x==3) f=1; else if(x==1&&f) f=2; else f=0; if(f==2) break; temp/=10; } if(n%13==0&&f==2) return 1; return 0; } int main() { int i,j,n; int ans=0; while(scanf("%d",&n)!=EOF){ ans=0; int cnt=n/200000; ans+=num[cnt]; for(i=cnt*200000+1;i<=n;i++){ if(OK(i)){ ans++; while(i<=n){ i+=13; if(OK(i)) ans++; } if(i>n&&OK(i)) ans--; } } printf("%d\n",ans); } return 0; }