View display_vec.rs
use std::fmt;
struct Array(Vec<i64>);
impl fmt::Display for Array {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Array(ref vec) = *self;
for (count, v) in vec.iter().enumerate() {
if count != 0 { try!(write!(f, " ")); }
try!(write!(f, "{}", v));
View arc080-e.rs
use std::io;
use std::str::FromStr;
use std::cmp;
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::collections::HashMap;
const INT_MAX: i64 = 200001;
struct SegmentTree {
View arc080-e.go
package main
import (
"bufio"
"container/heap"
"fmt"
"os"
"strconv"
"strings"
)
View arc080-a.rb
# K-City
n, m = gets.chomp.split(" ").map(&:to_i)
puts (n - 1) * (m - 1)
View aoj-icpc-1125.rb
# ICPC Domestic 2003
# Get Many Persimmon Trees
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1125
def cumsum2d(m)
h = m.size-1
w = m[0].size-1
ms = Array.new(h+1){Array.new(w+1, 0)}
(h+1).times do |i|
w.times do |j|
ms[i][j+1] = ms[i][j] + m[i][j+1]
View aoj-icpc-1124.rb
# ICPC Domestic 2003
# When Can We Meet?
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1124
while true
n, q = gets.chomp.split(" ").map(&:to_i)
break if n == 0 && q == 0
a = Array.new(101, 0)
n.times do
m, *d = gets.chomp.split(" ").map(&:to_i)
m.times do |i|
View aoj-icpc-1192.rb
# ICPC Domestic 2014
# Tax Rate Changed
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1192&lang=jp
while true
x, y, s = gets.chomp.split(" ").map(&:to_i)
break if x == 0 && y == 0 && s == 0
ret = 0
(1...s).each do |i|
(i...s).each do |j|
i0 = i * (100 + x) / 100
View aoj-icpc-1179.rb
# ICPC Domestic 2012
# Millennium
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1179&lang=jp
n = gets.chomp.to_i
yday = Array.new(1000, 195)
yday[0] = 0
(1..999).select{|i| i % 3 == 0}.each do |i|
yday[i] += 5
end
View aoj-icpc-1153.rb
# IOJ Domestic 2008
# Equal Total Scores
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1153&lang=jp
while true
n, m = gets.chomp.split(" ").map(&:to_i)
break if n == 0 && m == 0
asum = 0
a = []
n.times do
x = gets.chomp.to_i
View aoj-icpc-1159.rb
# ICPC Domestic 2009
# Next Mayer
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1159
while true
n, p_ = gets.chomp.split(" ").map(&:to_i)
break if n == 0 && p_ == 0
cand = Array.new(n, 0)
stone = p_
(0...n).cycle do |i|
if stone > 0 then