da1 <- read.table("D:/R/plyr/1.txt",
header = FALSE)
names(da1) <- c("n","m")
da1 <- as.matrix(da1)
f <- function(x)
{
n <- x[1]
m <- x[2]
a <- numeric(m)
a[1] <- n
for(i in 2:m)
{
a[i] <- sqrt(a[i-1])
}
return(round(sum(a),digits = 2))
}
write.table(apply(da1,1,f),"D:/R/plyr/1output.txt",
quote = FALSE,
col.names = FALSE,
row.names = FALSE)
纪念牛客的第一次写作业
最新推荐文章于 2024-05-26 11:05:55 发布