{"id":228,"date":"2018-05-30T11:17:16","date_gmt":"2018-05-30T03:17:16","guid":{"rendered":"https:\/\/dragonyue.fortiddns.com\/blog\/?p=228"},"modified":"2022-07-31T13:04:52","modified_gmt":"2022-07-31T05:04:52","slug":"java-uva10019","status":"publish","type":"post","link":"https:\/\/dragonyue.fortiddns.com\/blog\/java-uva10019\/","title":{"rendered":"Java &#8211; UVA10019"},"content":{"rendered":"<pre class=\"lang:java decode:1 \" >\r\nimport java.util.Scanner;\r\n\r\n\/**\r\n * UVA10019\r\n *\/\r\npublic class UVA10019 {\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 i = 0; i &lt; count; i++) {\r\n            int num = sc.nextInt();\r\n            String bin = Integer.toBinaryString(num);\r\n            int hexNum = Integer.parseInt(Integer.toString(num), 16);\r\n            String hex = Integer.toBinaryString(hexNum);\r\n            int binFreq = 0, hexFreq = 0;\r\n            for (int j = 0; j &lt; bin.length(); j++)\r\n                if (bin.charAt(j) == '1')\r\n                    binFreq++;\r\n            for (int j = 0; j &lt; hex.length(); j++)\r\n                if (hex.charAt(j) == '1')\r\n                    hexFreq++;\r\n            System.out.printf(&quot;%d %d\\r\\n&quot;, binFreq, hexFreq);\r\n        }\r\n        sc.close();\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import java.util.Scanner; \/** * UVA10019 *\/ public clas [&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-228","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts\/228","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=228"}],"version-history":[{"count":1,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts\/228\/revisions"}],"predecessor-version":[{"id":405,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts\/228\/revisions\/405"}],"wp:attachment":[{"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/media?parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/categories?post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/tags?post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}