{"id":239,"date":"2017-03-14T08:47:44","date_gmt":"2017-03-14T07:47:44","guid":{"rendered":"http:\/\/www.tastestars.com\/?p=239"},"modified":"2017-03-14T08:47:44","modified_gmt":"2017-03-14T07:47:44","slug":"1439","status":"publish","type":"post","link":"https:\/\/tastestars.com\/index.php\/2017\/03\/14\/1439\/","title":{"rendered":"\u9898\u76ee1439\uff1aLeast Common Multiple WA\u89e3\u51b3"},"content":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0\uff1a<br \/>\nThe least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 15 is 105.<br \/>\n\u8f93\u5165\uff1a<br \/>\nInput will consist of multiple problem instances. The first line of the input will contain a single integer indicating the number of problem instances. Each instance will consist of a single line of the form m n1 n2 n3 &#8230; nm where m is the number of integers in the set and n1 &#8230; nm are the integers. All integers will be positive and lie within the range of a 32-bit integer.<br \/>\n\u8f93\u51fa\uff1a<br \/>\nFor each problem instance, output a single line containing the corresponding LCM. All results will lie in the range of a 32-bit integer.<br \/>\n\u6837\u4f8b\u8f93\u5165\uff1a<br \/>\n2<br \/>\n3 5 7 15<br \/>\n6 4 10296 936 1287 792 1<br \/>\n\u6837\u4f8b\u8f93\u51fa\uff1a<br \/>\n105<br \/>\n10296<\/p>\n<p>\u601d\u8def\uff1a<br \/>\nWA\u534a\u5929\uff0c\u505a\u5230\u6000\u7591\u4eba\u751f\uff0c\u6700\u7ec8\u82b1\u4e86\u621120\u4e2a\u8c46\u5b50\u89e3\u51b3\uff0c\u9898\u76ee\u8981\u6c42lie in the range of 32-bit integer.int\u662f\u52302^32-1\u3002int\u4e0d\u591f\uff0c\u8981longlong\u624d\u884c\u3002\u771f\u7684\u4e00\u4e2a-1\u6ca1\u770b\u6e05\uff0c\u6d6a\u8d39\u4e86\u597d\u591a\u65f6\u95f4\u3002<\/p>\n<p>\u8d34\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:default decode:true \" >#include&lt;stdio.h&gt; \r\nint lcm(long long a,long long b){\r\n    long long m=a,n=b;\r\n    while(b!=0){\r\n        long long t=a%b;\r\n        a=b;\r\n        b=t;\r\n    }\r\n    return m*n\/a;\r\n}\r\nint main(){\r\n    int n,m;\r\n    long long a,b;\r\n    while(scanf(\"%d\",&amp;n)!=EOF){\r\n        while(n--&gt;0){\r\n            scanf(\"%d%lld\",&amp;m,&amp;a);\r\n            for(int i=1;i&lt;m;i++){\r\n                scanf(\"%lld\",&amp;b);\r\n                a=lcm(a,b);\r\n            }   \r\n            printf(\"%d\\n\",a);\r\n        }\r\n    }\r\n    return 0;\r\n}\r\n\/**************************************************************\r\n    Problem: 1439\r\n    User: WZDCJ0206\r\n    Language: C++\r\n    Result: Accepted\r\n    Time:0 ms\r\n    Memory:1020 kb\r\n****************************************************************\/<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0\uff1a The least common multiple (LCM) of a set of posit [&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","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-239","post","type-post","status-publish","format-standard","hentry","category-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s9Hs6X-1439","_links":{"self":[{"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/posts\/239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/comments?post=239"}],"version-history":[{"count":1,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/posts\/239\/revisions"}],"predecessor-version":[{"id":240,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/posts\/239\/revisions\/240"}],"wp:attachment":[{"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/media?parent=239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/categories?post=239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/tags?post=239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}