{"id":95,"date":"2010-11-07T08:07:36","date_gmt":"2010-11-07T00:07:36","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=95"},"modified":"2012-03-03T19:31:17","modified_gmt":"2012-03-03T11:31:17","slug":"%e6%a0%a1%e8%b5%9b%e3%80%82%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/%e6%a0%a1%e8%b5%9b%e3%80%82%e3%80%82\/","title":{"rendered":"\u6821\u8d5b\u3002\u3002"},"content":{"rendered":"<p><!--more--><br \/>\n\u57ce\u7ba1\u5927\u961f\u539f\u6765\u662f\u6c99\u6f20\u541b\u3002 \u3002\u3002\u3002<\/p>\n<pre lang=\"cpp\" file=\"A.cpp\">\r\n#include <iostream>\r\nusing namespace std ;\r\n\r\nint   N ;\r\nint   a1 , a2 , s1 , s2 , F[10000001] ;\r\n\r\nvoid\tInit()\r\n{\r\n\t\ta1 = 5 ; a2 = 401 % 29 ;\r\n\t\ts1 = 6 ; s2 = 402 % 29 ;\r\n\t\tF[1] = 5 ;\r\n\t\tfor ( int i = 2 ; i <= 10000000 ; i ++ )\r\n\t\t{\r\n\t\t\ta1 = ( a1 * 5   ) % 29 ;\r\n\t\t\ta2 = ( a2 * 401 ) % 29 ;\r\n\t\t\tF[i] = ( F[i-1] + s1 * a2 + s2 * a1 + a1 * a2 ) % 29 ;\r\n\t\t\ts1 = (s1 + a1) % 29 ;\r\n\t\t\ts2 = (s2 + a2) % 29 ;\r\n\t\t}\r\n}\r\n\r\nint\t\tmain()\r\n{\r\n\t\tInit() ;\r\n\t\twhile ( cin >> N && N != 0 ) cout << F[N] << \"\\n\" ;\r\n\t\treturn 0 ;\r\n}\r\n\r\n<\/pre>\n<pre lang=\"cpp\" file=\"D.cpp\">\r\n\/* This Code is Submitted by xiaodao for Problem 101449 at 2010-11-07 13:55:43 *\/\r\n#include <iostream>\r\nusing namespace std;\r\nconst int N = 366;\r\nint g[N], f[N]; double a[N];\r\n\/\/ f:.. Cana.   g:.. Usa.\r\ndouble ans;\r\nint n;\r\n \r\n \r\nvoid init(){\r\n    for (int i=1;i<=n;i++){\r\n        scanf(\"%lf\", &#038;a[i]);\r\n\t\t\/\/ a[i] = a[i]*0.97;\r\n    }\r\n}\r\n \r\nvoid solve(){\r\n    f[0] = 100000; g[0] = 0;\r\n    for (int i=1;i<=n;i++){\r\n        f[i] = max(f[i-1], int(g[i-1]*a[i]*0.97));\r\n        g[i] = max(g[i-1], int(f[i-1]\/a[i]*0.97));\r\n    }\r\n\t\r\n}\r\n \r\n \r\nint main(){\r\n    cin >> n;\r\n    while (n!=0){\r\n        init(); solve(); ans = double(f[n]) \/ 100;\r\n        printf(\"%.2lf\\n\", ans);\r\n        \/\/cout << f[n]\/100 << endl;\r\n        cin >> n;\r\n    }\r\n\t\r\n}\r\n<\/pre>\n<pre lang=\"cpp\" file=\"E.cpp\">\r\n#include <iostream>\r\n#include <string>\r\nusing namespace std;\r\nconst int N = 10;\r\nint A[N+1];\r\nstring s;\r\nint x;\r\n\r\n\r\n\r\nstring f(int x){\r\n\tstring res;\r\n\t\r\n\tif (x < 0) {\r\n\t\tres = \"\"; x = -x;\r\n\t\t\r\n\t\twhile (x!=0){\r\n\t\t\tres = char( x%10 + 48) + res;\r\n\t\t\tx \/= 10;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\tif (res==\"\") res = '0';\r\n\t\t\r\n\t\tres = \"-\" + res;\r\n\t}\r\n\telse {\t\r\n\t\twhile (x!=0){\r\n\t\t\tres = char(x%10 + 48) + res;\r\n\t\t\tx \/= 10;\r\n\t\t}\r\n\t\t\r\n\t\tif (res==\"\") res = '0';\r\n\t\t\r\n\t\tres = \"+\" + res;\t\r\n\t}\r\n\t\r\n\treturn res;\r\n}\r\n\r\nstring g(int x){\r\n\t\r\n\t\r\n\tif (x == 0) return \"\";\r\n\tif (x == 1) return \"x\";\r\n\t\r\n\tstring res = \"x^\"; res += char(x + 48);\r\n\treturn res;\r\n}\r\n\r\n\r\nvoid encode(){\r\n\t\r\n\ts = \"+\" + s;\r\n\t\r\n\tint x;\r\n\tfor (int i=0;i<s.size();i++){\r\n\t\tif (s[i] == 'x'){\r\n\t\t\tif (s[i+1] == '^') A[int(s[i+2])-48] = x;\r\n\t\t\telse A[1] = x;\r\n\t\t\tx = 0;\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (s[i]=='+') x = int(s[i+1]) - 48;\r\n\t\t\telse if (s[i]=='-') x = - (int(s[i+1]) - 48);\r\n\t\t\tif (x==72) x = 1; else if (x==-72) x = -1;\r\n\t\t}\r\n\t}\r\n\t\r\n\tA[0] = x;\r\n\t\r\n\t\r\n\t\/*\r\n\tfor (int i=0;i<N;i++)\r\n\t\tcout << A[i] << \" \";\r\n\tcout << endl;\r\n\t *\/\r\n}\r\n\r\nvoid decode(){\r\n\ts.clear();\r\n\t\r\n\tfor (int i=N-1;i>=0;i--)\r\n\t\tif (A[i]!=0) s = s + f(A[i]) + g(i);\r\n\t\r\n\t\r\n\tif (s[0]=='+') s.erase(0, 1);\r\n\t\r\n\tcout << s << endl; \r\n}\r\n\r\n\r\nvoid derivate(){\r\n\tfor (int i=0;i<N;i++)\r\n\t\tA[i] = (i+1) * A[i+1];  \r\n\t\r\n}\r\n\r\nvoid replace(){\r\n\tfor (int i=0;i<s.size();i++)\r\n\t\tif (s[i]=='x') cout << \"(\" << x << \")\";\r\n\t\telse cout << s[i];\r\n\tcout << endl;\r\n}\r\n\r\nvoid calc(){\r\n\tint sum = 0, a = 1, b = 1; string s;\r\n\tfor (int i=0;i<N;i++){\r\n\t\tif (A[i]!=0){\r\n\t\t\ta = (A[i] * b), sum += a;\r\n\t\t\ts = f(a) + s;\r\n\t\t}\r\n\t\tb *= x;\r\n\t}\r\n\t\r\n\t\r\n\tif (s[0]=='+') s.erase(0, 1);\r\n\tcout << s << endl;\r\n\tcout << sum << endl;\r\n}\r\n\r\nvoid init(){\r\n    cin >> x; cin >> s; cout << s << endl;\r\n}\r\n\r\nvoid solve(){\r\n\tmemset(A, 0, sizeof(A));\r\n\tencode(); \r\n\t\r\n\tint i;\r\n\tfor (i=1;i<N;i++)\r\n\t\tif (A[i]!=0) break;\r\n\tif (i==N){\r\n\t\tcout << 0 << endl;\r\n\t\tcout << 0 << endl;\r\n\t\tcout << 0 << endl;\r\n\t\tcout << 0 << endl;\r\n\t\t\r\n\t}\r\n\telse {\r\n\t\tderivate(); decode();\r\n\t\treplace(); calc();\r\n\t}\r\n}\r\n\r\n\r\n\r\nint main(){\r\n\t\r\n\t\r\n\tfreopen(\"in.txt\", \"r\", stdin);\r\n\t\r\n\t\r\n    int T; cin >> T;\r\n\tfor (int i=1;i<=T;i++){\r\n\t\tcout << \"POLYNOMIAL \" << i << endl;\r\n        init(); solve();\r\n    }\r\n\t\r\n}\r\n<\/pre>\n<p>Solution for Problem A \uff1a<\/p>\n<p>Problem_A_____________________________________________________________<br \/>\n____Description:_\u6c422005^X\u7684\u6240\u6709\u56e0\u6570\u7684\u548c mod 29________________________<br \/>\n____Solution___:_\u9996\u5148\uff0c2005\u662f\u7531401\u548c5\u8fd92\u4e2a\u8d28\u6570\u76f8\u4e58\u7684\u3002________________<br \/>\n_________________\u6211\u4eec\u8003\u86512005^X\u4e0e2005^(X-1)___________________________<br \/>\n_________________\u4e0e2005^(X-1)\u76f8\u6bd4\uff0c2005^X\u591a\u51fa\u6765\u7684\u56e0\u6570\u6709\uff1a_____________<br \/>\n_____________________(1)_5^i_*_401^X__________________________________<br \/>\n_____________________(2)_5^X_*_401^i__________________________________<br \/>\n_________________\u4e8e\u662f\u6211\u4eec\u7528s1,s2\u5206\u522b\u8bb0\u5f55\u524dX-1\u4e2a5\u7684\u5e42\u548c401\u7684\u5e42\u7684\u548c_____<br \/>\n_________________\u4e8e\u662f_F[X]_=_F[X-1]_+_s1*401^X_+_s2*5^X_+_5^X*401^X___<br \/>\n_________________\u9012\u63a8\u6c42\u51fa\u6240\u6709\u7684\u7b54\u6848\uff0c\u6253\u8868\u3002\u65f6\u95f4\u590d\u6742\u5ea6\u5ea6O(N)___________<\/p>\n<p>Problem_B_____________________________________________________________<br \/>\n____Description:_\u6c42\u75281*2\u7684\u9aa8\u724c\u548c3\u62d0\u7684\u9aa8\u724c\u8986\u76d62*N\u7684\u68cb\u76d8\u7684\u65b9\u6848\u4e2a\u6570______<br \/>\n____Solution___:_\u75280\u30011\u30012\u30013\u8868\u793a4\u79cd\u72b6\u6001______________________________<br \/>\n____________________0\u3001\u25a1___1\u3001\u25a1___2\u3001\u25a0___3\u3001\u25a0_____________________<br \/>\n_______________________\u25a1______\u25a0______\u25a1______\u25a0_____________________<br \/>\n_________________\u4e8e\u662f\u6211\u4eec\u5f97\u5230\u4e0b\u9762\u7684\u5173\u7cfb\u77e9\u9635___________________________<br \/>\n________________________|0___1___2___3________________________________<br \/>\n______________________--+--------------_______________________________<br \/>\n______________________0_|0___1___1___1________________________________<br \/>\n______________________1_|0___0___1___1________________________________<br \/>\n______________________2_|0___1___0___1________________________________<br \/>\n______________________3_|1___0___0___1________________________________<br \/>\n_________________\u7528\u5feb\u901f\u5e42\u77e9\u9635\u4e58\u6cd5DP\u5373\u53ef\u3002_____________________________<\/p>\n","protected":false},"excerpt":{"rendered":"","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":[1],"tags":[],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-1x","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/95","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=95"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}