import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); while(sc.hasNext()) { int n = sc.nextInt(); long x = (1<<n)-1; Map<Long,Integer> map = new HashMap<>(); while(x>=0) { long c = count(x); if(map.containsKey(c)) { int r = map.get(c); map.put(c,r+1); }else { map.put(c,1); } x--; } long q = 0; long o = 0; for(Map.Entry<Long,Integer> entry:map.entrySet()) { int re = entry.getValue(); if(re%2==0) { o++; }else{ q++; } } System.out.println(q); System.out.println(o); } } public static Long count(long a) { long count = 0; while(a!=0) { a = a&(a-1); count++; } return count; } }
点赞 2

相关推荐

能干的三文鱼刷了100道题:公司可能有弄嵌入式需要会画pcb的需求,而且pcb能快速直观看出一个人某方面的实力。看看是否有面试资格。问你问题也能ai出来,pcb这东西能作假概率不高
点赞 评论 收藏
分享
04-28 11:34
西北大学 运营
牛客4396号:不好意思,这个照片猛一看像丁真
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务