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

相关推荐

爱喝奶茶的垂耳兔拥抱太阳:感觉项目和实习没有技术亮点和难点,单纯说了自己干了啥
点赞 评论 收藏
分享
牛客网
牛客企业服务