第二题 思维题,将n个数存到k个桶里,如果选第i个桶,就不能选k-i个桶的 import java.util.Scanner; public class Main { static int[] a = new int[1005]; static long mod = 1000000007; static long pow[]=new long[100005]; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); pow[0]=1; for (int i = 1; i <=n; i++) { int x = sc.nextInt(); a[x % k]++; pow[i]=pow[i-1]*2%mod; } long ans=1; for (int i = 1; i < (k+1) / 2; i++) { ans*= (pow[a[i]] + pow[a[k - i]]-1); ans %= mod; } if(a[0]>0)ans*=2; if(k%2==0 &&a[k/2]>0)ans*=2; System.out.println(ans); } }
3 7

相关推荐

09-28 22:01
已编辑
广西科技大学 IT技术支持
合适才能收到offe...:找桌面运维?
点赞 评论 收藏
分享
10-17 23:18
已编辑
西北农林科技大学 Web前端
独行m:给25可以试试,但他只能给12,那就是纯纯的事精
秋招,不懂就问
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务