{"id":226,"date":"2018-05-30T11:16:48","date_gmt":"2018-05-30T03:16:48","guid":{"rendered":"https:\/\/dragonyue.fortiddns.com\/blog\/?p=226"},"modified":"2022-07-31T13:04:52","modified_gmt":"2022-07-31T05:04:52","slug":"java-uva948","status":"publish","type":"post","link":"https:\/\/dragonyue.fortiddns.com\/blog\/java-uva948\/","title":{"rendered":"Java &#8211; UVA948"},"content":{"rendered":"<pre class=\"lang:java decode:1 \" >\r\nimport java.util.ArrayList;\r\nimport java.util.Scanner;\r\n\r\n\/**\r\n * UVA948\r\n *\/\r\npublic class UVA948 {\r\n\r\n    public static void main(String[] args) {\r\n        Scanner sc = new Scanner(System.in);\r\n        int count = sc.nextInt();\r\n        for (int j = 0; j &lt; count; j++) {\r\n            int n = sc.nextInt();\r\n            int N = n;\r\n            ArrayList&lt;Integer&gt; intList = new ArrayList&lt;Integer&gt;();\r\n            intList.add(1);\r\n            if (n &gt;= 1) {\r\n                intList.add(2);\r\n                int temp = 0;\r\n                while (temp &lt;= n) {\r\n                    temp = intList.get(intList.size() - 2) + intList.get(intList.size() - 1);\r\n                    intList.add(temp);\r\n                }\r\n            }\r\n            String fib = &quot;&quot;;\r\n            for (int i = intList.size() - 2; i &gt;= 0; i--) {\r\n                int get = intList.get(i);\r\n                if (n &gt;= get) {\r\n                    n -= get;\r\n                    fib += &quot;1&quot;;\r\n                } else\r\n                    fib += &quot;0&quot;;\r\n            }\r\n            if (N == 1)\r\n                fib = &quot;1&quot;;\r\n            System.out.printf(&quot;%d = %s (fib)\\r\\n&quot;, N, fib);\r\n        }\r\n        sc.close();\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import java.util.ArrayList; import java.util.Scanner; \/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-226","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts\/226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/comments?post=226"}],"version-history":[{"count":1,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts\/226\/revisions"}],"predecessor-version":[{"id":406,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts\/226\/revisions\/406"}],"wp:attachment":[{"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/media?parent=226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/categories?post=226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/tags?post=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}