高校数学の質問スレ(医者・東大卒専用) Part438 (899レス)
上
下
前
次
1-
新
771
: 03/31(月)11:28
ID:u+Kd/O/2(1/3)
AA×
[240|
320
|
480
|
600
|
100%
|
JPG
|
べ
|
レス栞
|
レス消
]
771: [sage] 2025/03/31(月) 11:28:24.79 ID:u+Kd/O/2 # 赤玉a個、黒玉b個、白玉c個、青玉d個の合計(a+b+c+d)個の玉を空箱なしで3つの箱に分けて入れる。箱を区別しないとき、入れ方は何通りあるか?" solve=function(a,b,c,d){ divide = function(n) { indices = expand.grid(i = 0:n, j = 0:n) indices = indices[indices$j >= indices$i, ] result = lapply(1:nrow(indices), function(k) { x = indices[k, ] matrix(c(x$i, x$j - x$i, n - x$j), nrow = 1) }) return(result) } reds = divide(a) blacks = divide(b) whites = divide(c) blues = divide(d) box3 = list() combinations = expand.grid(red = reds, black = blacks, white = whites, blue = blues) box3 = apply(combinations, 1, function(x) { red = x[[1]] black = x[[2]] white = x[[3]] blue = x[[4]] box = do.call(rbind, lapply(1:3, function(i) { sum_values = red[i] + black[i] + white[i] + blue[i] if (sum_values > 0) c('red'=red[i], 'black'=black[i], 'white'=white[i], 'blue'=blue[i]) else NULL })) if (!is.null(box) & nrow(box) == 3) { sorted_box = box[order(apply(box, 1, paste, collapse = ",")), ] return(sorted_box) } return(NULL) }) length(unique(Filter(Negate(is.null), box3))) } f=function(a,b,c,d){ ball=c(a,b,c,d) x=(a+2)*(b+2)*(c+2)*(d+2) y=(a+1)*(b+1)*(c+1)*(d+1) z=floor(a/2+1)*floor(b/2+1)*floor(c/2+1)*floor(d/2+1) u=ifelse(all(ball%%2==0),1,0) v=ifelse(all(ball%%2==0),1,0) x*y/96-(3*y-3*z-3*u+4*v)/6-u*v } p=sample(10,4) p solve(p[1],p[2],p[3],p[4]) f(p[1],p[2],p[3],p[4]) http://rio2016.5ch.net/test/read.cgi/math/1723152147/771
赤玉個黒玉個白玉個青玉個の合計個の玉を空箱なしでつの箱に分けて入れる箱を区別しないとき入れ方は何通りあるか?
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 128 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
ぬこの手
ぬこTOP
0.061s