[過去ログ] 臨床統計もおもしろいですよ、その1 [無断転載禁止]©2ch.net (747レス)
上下前次1-新
このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
716: 2018/09/22(土)21:34 ID:zrIlwkkB(2/2) AAS
#include <stdio.h>
int arr[] ={1,2,3,4,5};
int total = (sizeof(arr) / sizeof(arr[0]));
void heapify(int arr[], int i)
{
int lft = i * 2;
int rgt = lft + 1;
int grt = i;
if (lft <= total && arr[lft] > arr[grt]) grt = lft;
if (rgt <= total && arr[rgt] > arr[grt]) grt = rgt;
省12
717: 2018/09/23(日)18:58 ID:edPyfcCi(1/2) AAS
library(gtools)
k=3
perm=unique(permutations(3*k,3*k,rep(1:3,k),set=F,rep=F))
is3 <- function(x){
n=length(x)
y=c(x,x[1])
re=NULL
for(i in 1:(n-1)) re[i]=all((1:3) %in% y[i:(i+2)])
any(re)
}
省20
718: 2018/09/23(日)18:58 ID:edPyfcCi(2/2) AAS
same <- function(x,base){
f=function(a,b=base){ # is equal to base
all(a==b)
}
mat=rbind(rn(x),rn(rev(x))) # rotation and/or symmetric conversion
any(apply(mat,1,f))
}
mat=perm1
tail(perm1)
exvar <- function(row,mat=perm1){
省12
719: 2018/09/24(月)16:11 ID:cwdsebwG(1/7) AAS
same <- function(x,base){
f=function(a,b=base){ # is equal to base
all(a==b)
}
mat=rbind(rn(x),rn(rev(x))) # rotation and/or symmetric conversion
any(apply(mat,1,f))
}
mat=perm1
core=NULL # 基本解を集める行列
while(nrow(mat)){
省12
720: 2018/09/24(月)20:26 ID:cwdsebwG(2/7) AAS
library(compiler)
cuniq=cmpfun(unique)
jperm <- function(n,r,v) {
if (r == 1)
matrix(v, n, 1)
else if (n == 1)
matrix(v, 1, r)
else {
X <- NULL
for (i in 1:n) X <- rbind(X, cbind(v[i], jperm(n - 1, r - 1, v[-i])))
省7
721: 2018/09/24(月)20:44 ID:cwdsebwG(3/7) AAS
#include<stdio.h>
#define N 6
int b[N];
char * u[] = {"P","E","P","P","E","R"};
void p_table(int k){
int i;
if(k < N){
for(i=0;i<N;i++){
b[k] = i;
p_table(k+1);
省13
722: 2018/09/24(月)21:05 ID:cwdsebwG(4/7) AAS
// 外部リンク:www.geeksforgeeks.org
// Program to print all permutations of a string in sorted order.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
/* Following function is needed for library function qsort(). */
int compare(const void *a, const void * b)
{
return ( *(char *)a - *(char *)b );
省8
723: 2018/09/24(月)21:05 ID:cwdsebwG(5/7) AAS
// This function finds the index of the smallest character
// which is greater than 'first' and is present in str[l..h]
int findCeil(char str[], char first, int l, int h)
{
// initialize index of ceiling element
int ceilIndex = l;
// Now iterate through rest of the elements and find
// the smallest character greater than 'first'
for (int i = l+1; i <= h; i++)
if (str[i] > first && str[i] < str[ceilIndex])
省3
724: 2018/09/24(月)21:05 ID:cwdsebwG(6/7) AAS
// Print all permutations of str in sorted order
void sortedPermutations(char str[])
{
// Get size of string
int size = strlen(str);
// Sort the string in increasing order
qsort(str, size, sizeof( str[0] ), compare);
// Print permutations one by one
bool isFinished = false;
while (!isFinished)
省10
725: 2018/09/24(月)21:06 ID:cwdsebwG(7/7) AAS
// If there is no such chracter, all are sorted in decreasing order,
// means we just printed the last permutation and we are done.
if (i == -1)
isFinished = true;
else
{
// Find the ceil of 'first char' in right of first character.
// Ceil of a character is the smallest character greater than it
int ceilIndex = findCeil(str, str[i], i + 1, size - 1);
// Swap first and second characters
省13
726: 2018/09/26(水)11:07 ID:Rj8Wp2L9(1) AAS
b=0
w=1
bwb=function(x){
n=length(x)
if(n<3) return(F)
else x[n-2]==b & x[n-1]==w & x[n]==b
}
f = function(){
x=NULL
while(!bwb(x)){
省7
727: 2018/09/26(水)22:08 ID:+zbP8/80(1) AAS
library(Rmpfr)
f <- function(NN,prec=1000){
for(k in 1:NN){
for(m in k:NN){
for(n in m:NN){
K=mpfr(factorial(k),prec)
M=mpfr(factorial(m),prec)
N=mpfr(factorial(n),prec)
if(K+M==N) cat(k,'! + ',m,'! = ',n,'!\n')
}
省4
728: 2018/10/02(火)21:03 ID:DMIGI67G(1/2) AAS
print $ foldr (-) 0 [1,2,3]
print $ foldr (-) 0 ( 1:(2:(3:[])) )
print $ 1-(2-(3-0))
729: 2018/10/02(火)22:17 ID:DMIGI67G(2/2) AAS
elem_r y ys = foldr (\x acc -> if x==y then True else acc) False ys
elem_r 39 [3.6..]
elem_l y ys = foldl(\acc x -> if x==y then True else acc) False ys
{- ERROR!!
elem_l 39 [3,6..]
730: 2018/10/03(水)13:45 ID:OGYXL17c(1) AAS
map' f xs = foldr (\x acc -> f x:acc) [] xs
elem_r y ys = foldr (\x acc -> if x==y then True else acc) False ys
elem_l y ys = foldl(\acc x -> if x==y then True else acc) False ys
main = do
print $ zipWith (\x y -> (x*30+3)/y) [5,4,3,2,1] [1..5]
print $ map (\(a, b) -> a+b) [(1,2),(3,5),(6,3),(2,6),(2,5)]
print $ zipWith (flip (++)) ["love you","is an angel"] ["I ","Mei "]
print $ map (flip subtract 20) [1..5]
print $ foldl (\a b -> a+b) 0 [3,5,2,1]
print $ foldl (-) 0 [1,2,3]
省7
731: 2018/10/08(月)17:55 ID:pH+BqnrA(1/5) AAS
import Data.List
divisor n = find (\m -> n `mod` m ==0 )[2..floor.sqrt.fromIntegral $ n]
main = do
print $ divisor $ (10^19-1) `div` 9
732: 2018/10/08(月)18:06 ID:pH+BqnrA(2/5) AAS
import Data.List
divisor n = find (\m -> n `mod` m ==0 )[2..floor.sqrt.fromIntegral $ n]
divisors n = filter (\m -> n `mod` m ==0 )[2..n-1]
main = do
print $ divisor $ (10^19-1) `div` 9
733: 2018/10/08(月)20:25 ID:pH+BqnrA(3/5) AAS
100万個の○が円形に並んでいます。
図のように、まず1つの○に色をぬり、
次にその●から時計回りに108個進んで止まり、そこにある○をぬります。
さらにその●から
時計回りに108個進んで止まり、
そこにある○をぬり、以下同じ作業を くり返していきます。
すでに色がぬられた●に止まったときに終了とするとき、
何個の○をぬることができますか?
foo jump spot = length $ takeWhile (\x -> x*jump `mod` spot /=0) [1..]
1 + foo 108 1000000
734: 2018/10/08(月)20:30 ID:pH+BqnrA(4/5) AAS
m個の○が円形に並んでいます。
図のように、まず1つの○に色をぬり、
次にその●から時計回りにn個進んで止まり、そこにある○をぬります。
さらにその●から
時計回りにn個進んで止まり、
そこにある○をぬり、以下同じ作業を くり返していきます。
すでに色がぬられた●に止まったときに終了とするとき、
何個の○をぬることができますか?
m / gcd(m.n)
m,nが互いに素なら全部塗れる。
735: 2018/10/08(月)20:48 ID:pH+BqnrA(5/5) AAS
gcd a b
| a `mod` b == 0 = b
| otherwise = gcd b $ a `mod` b
上下前次1-新書関写板覧索設栞歴
あと 12 レスあります
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.180s*