3452. 唐纳德先生和假骰子

随风久远行123

include

int main()
{
int i,j,p,a[6],b[6],flag=1,book[6]={0};
scanf(“%d”,&p);
for(i=0;i<6;i++)
scanf(“%d”,&a[i]);
for(i=0;i<6;i++)
scanf(“%d”,&b[i]);
for(i=0;i<6;i++)
for(j=0;j<6;j++)
{
book[(a[i]+b[j])%p]++;
}
for(i=1;i<p;i++)
if(book[i]!=book[i-1]) flag=0;
if(flag) printf(“YES\n”);
else printf(“NO\n”);
return 0;
}

中二猫

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int i = Integer.parseInt(scanner.nextLine());
String[] a = scanner.nextLine().split(“\s+”);
String[] b = scanner.nextLine().split(“\s+”);
ArrayList arr = new ArrayList<>();
for (String s : a) {
for (String s1 : b) {
arr.add(Integer.parseInt(s) + Integer.parseInt(s1));
}
}
// 将所有可能出现的点数放进一个集合
int[] adds = new int[i];
for (Integer integer : arr) {
adds[integer % i]++;
}
// 将所有的点数对人数取余,出现的余数就次数加一
int sign = 0;
for (int j = 0; j < adds.length-1; j++) {
if (adds[j] != adds[j + 1]) {
sign++;
}
}
// 如果这个数组中的每个值相同,概率就相同
if (sign == 0) {
System.out.println(“YES”);
} else {
System.out.println(“NO”);
}
}
}

wty403

p = int(input())
a = list( map( lambda x:int(x),input().split()))
b = list( map( lambda x:int(x),input().split()))
m = len(a)
n = len(b)
L = []
for i in range(m):
for j in range(n ):
L.append(a[i] + b[j])
L1 = [0 for s in range(p)]
for k in range(len(L)):
t = L[k] % p
L1[t] = L1[t] + 1
for z in range(1,len(L1)):
if L1[0] != L1[z]:
print(“NO”)
break
else:
print(“YES”)

YZAZJL

include

include

using namespace std;

int main()
{
int n;
int i;
int j;
cin >> n;
int num[n] = {0};
int a[6];
int b[6];
for(i = 0; i < 6; i++){
cin >> a[i];
}
for(i = 0; i < 6; i++){
cin >> b[i];
}
for(i = 0; i < 6; i++){
for(j = 0; j < 6; j++){
int tmp = (a[i] + b[j]) % n;
num[tmp]++;
}
}
for(i = 0; i < n - 1; i++){
if(num[i] != num[i+1]){
break;
}
}
if(i == n-1){
cout << “YES” << endl;
}
if(i < n-1){
cout << “NO” << endl;
}
return 0;
}

你当前正在回复 博客/题目
存在问题!