Closed feldblume5263 closed 2 years ago
let input = Int(readLine()!)!
var sums = [Int]()
for _ in 0..<input {
let result = readLine()!
var sum = 0
var count = 0
for idx in 0..<result.count {
if result[String.Index(encodedOffset: idx)] == "O" {
count += 1
sum += count
} else {
count = 0
}
}
sums.append(sum)
}
for sum in sums {
print(sum)
}
import Foundation
let input = Int(readLine()!)!
var results = [Double]()
for _ in 0 ..< input {
var sum: Double = 0
var count: Double = 0
var scores: [Double] = readLine()!.split(separator: " ").map {
sum += Double($0)!
count += 1
return Double($0)!
}
sum -= scores[0]
scores.removeFirst()
count -= 1
let average: Double = sum / count
var result: Double = 0
for score in scores {
if score > average {
result += 1
}
}
results.append(result/count)
}
for result in results {
print(String(format: "%.3f%%", result * 100))
}
long long sum(int *a, int n)
{
int idx = 0;
long long sum = 0;
while (idx < n)
{
sum += (long long)a[idx];
idx++;
}
return (sum);
}
func selfNum(input: Int) -> Int {
let new = String(input)
var result = input
_ = new.map {
result += Int(String($0))!
}
return result
}
for i in 1...10000 {
history.append(selfNum(input: i))
}
for i in 1...10000 {
if history.firstIndex(of: i) == nil {
print(i)
}
}
let k = Int(readLine()!)!
var sum = 0
for i in 1 ... k {
var ns = [Int]()
_ = String(i).map {
ns.append(Int(String($0))!)
}
if ns.count >= 3 {
let d = ns[1] - ns[0]
var flag = true
for idx in 2 ..< ns.count {
if ns[idx] - ns[idx - 1] != d {
flag = false
break
}
}
if flag {
sum += 1
}
} else {
sum += 1
}
}
print(sum)
잘해보자