{"id":536,"date":"2010-10-20T10:04:06","date_gmt":"2010-10-20T02:04:06","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=536"},"modified":"2012-10-20T21:57:02","modified_gmt":"2012-10-20T13:57:02","slug":"hoj-1004-prime-palindromes","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/hoj-1004-prime-palindromes\/","title":{"rendered":"HOJ 1004. Prime Palindromes"},"content":{"rendered":"<h3>Brief description: <\/h3>\n<p>nimendongde .. <\/p>\n<h3>Analysis: <\/h3>\n<p>&#8230;<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n\/* This Code is Submitted by xiaodao for Problem 1004 at 2010-10-24 14:13:43 *\/\r\n#include &lt;iostream&gt;\r\n#include &lt;cmath&gt;\r\nusing namespace std;\r\n \r\nconst int N = 9999;\r\n \r\nstring s; int x;\r\nint l, r;\r\n \r\n \r\nstring L(int x){\r\n    string res;\r\n    while (x!=0){\r\n        res = char(x%10 + 48) + res;\r\n        x \/= 10;\r\n    }\r\n    return res;\r\n}\r\n \r\nstring R(int x){\r\n    string res;\r\n    while (x!=0){\r\n        res = res + char(x%10 + 48);\r\n        x \/= 10;\r\n    }\r\n    return res;\r\n}\r\n \r\nstring M(int x){\r\n    string res; res = x + 48;\r\n    return res;\r\n}\r\n \r\nint g(string x){\r\n    int res = 0;\r\n    for (int i=x.size()-1;i&gt;=0;i--)\r\n        res = res * 10 + (x&#x5B;i]-48);\r\n    return res;\r\n}\r\n \r\nbool isPrime(int x){\r\n    int t = sqrt(x);\r\n    for (int i=2;i&lt;=t;i++)\r\n        if (x%i==0) return false;\r\n    return true;\r\n}\r\n \r\nvoid Letsgo(){\r\n        for (int i=1;i&lt;=N;i++){\r\n            for (int j=0;j&lt;=9;j++){\r\n                x = g(L(i) + M(j) + R(i));\r\n                if (x &gt; r) return;\r\n                if (l&lt;=x &amp;&amp; x&lt;=r &amp;&amp; isPrime(x)) cout &lt;&lt; x &lt;&lt; endl;\r\n            }\r\n        }\r\n}\r\n \r\n \r\n \r\nint main(){\r\n    while (cin &gt;&gt; l &gt;&gt; r){\r\n        if (l&lt;=5 &amp;&amp; 5&lt;=r) cout &lt;&lt; 5 &lt;&lt; endl;\r\n        if (l&lt;=7 &amp;&amp; 7&lt;=r) cout &lt;&lt; 7 &lt;&lt; endl;\r\n        if (l&lt;=11 &amp;&amp; 11&lt;=r) cout &lt;&lt; 11 &lt;&lt; endl;\r\n        Letsgo();\r\n    }\r\n}  \r\n<\/pre>\n<h3>External link: <\/h3>\n<p><a href=\"http:\/\/acm.hit.edu.cn\/hoj\/problem\/view?id=1004\">http:\/\/acm.hit.edu.cn\/hoj\/problem\/view?id=1004<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Brief description: nimendongde .. Analysis: &#8230; \/* This Code is Submitted by xiaodao for Problem 1004 at 2010-10-24 14:13:43 *\/ #include &lt;iostream&gt; #include &lt;cmath&gt; using namespace std; const int N = 9999; string s; int x; int l, r; string L(int x){ string res; while (x!=0){ res = char(x%10 + 48) + res; x \/= [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[20],"tags":[],"class_list":["post-536","post","type-post","status-publish","format-standard","hentry","category-hoj"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-8E","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/536","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=536"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/536\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}