高校数学の質問スレ(医者・東大卒専用) Part438 (979レス)
高校数学の質問スレ(医者・東大卒専用) Part438 http://rio2016.5ch.net/test/read.cgi/math/1723152147/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
512: 132人目の素数さん [sage] 2025/01/08(水) 04:11:37.72 ID:X/URcmTf rm(list=ls()) JugRiddle <- function( big=5, small=3, end=4){ # starting from the bigger jug movebig <- function(xy){ # start from c(big,0) x=xy[1] ; y=xy[2] # x==big if(x==big) re=c(big-(small-y),small) # x==0 if(x==0) re=c(big,y) # y==small if(y==small) re=c(x,0) # y==0 if(y==0 & x!=big){ if(x>=small) re=c(x-small,small) else re=c(0,x) } return(re) } STATUS=status=c(big,0) i=1 while(!identical(status,c(0,0))){# i=i+1 status=movebig(status) STATUS=rbind(STATUS,status) } rownames(STATUS)=1:nrow(STATUS) colnames(STATUS)=c(paste0(big,'L'),paste0(small,'L')) (Bigger=STATUS) # starting from the smaller jug movesmall <- function(xy){ # start from c(0,small) x=xy[1] ; y=xy[2] if(y==small){ if(x<=(big-small)) re=c(x+small,0) else re=c(big, small-(big-x)) } if(y==0) re=c(x,small) if(x==big) re=c(0,y) if(x==0) re=c(y,0) return(re) } STATUS=status=c(0,small) i=1 while(!identical(status,c(0,0))){ # i=i+1 status=movesmall(status) STATUS=rbind(STATUS,status) } rownames(STATUS)=1:nrow(STATUS) colnames(STATUS)=c(paste0(big,'L'),paste0(small,'L')) (Smaller=STATUS) if(all(end != c(Bigger,Smaller))) return(NA) min_Bigger=min(which(apply(Bigger,1,function(x) end %in% x))) min_Smaller=min(which(apply(Smaller,1,function(x) end %in% x))) list(Bigger=as.matrix(Bigger)[1:min_Bigger,], Smaller=as.matrix(Smaller)[1:min_Smaller,], min_Bigger=min_Bigger,min_Smaller=min_Smaller) } JugRiddle(5,3,4) JugRiddle(10,5,3) http://rio2016.5ch.net/test/read.cgi/math/1723152147/512
514: 132人目の素数さん [sage] 2025/01/08(水) 19:29:44.12 ID:X/URcmTf >>513 (2)回数の差の分布 https://i.imgur.com/jDZubdl.png http://rio2016.5ch.net/test/read.cgi/math/1723152147/514
515: 132人目の素数さん [sage] 2025/01/08(水) 20:16:25.91 ID:X/URcmTf >>514 https://i.imgur.com/cmdTCLY.png http://rio2016.5ch.net/test/read.cgi/math/1723152147/515
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
2.305s*