QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#289697#7865. Refresher into Midasucup-team296#AC ✓105ms76380kbRust19.5kb2023-12-23 21:22:002023-12-23 21:22:00

Judging History

你现在查看的是最新测评结果

  • [2023-12-23 21:22:00]
  • 评测
  • 测评结果:AC
  • 用时:105ms
  • 内存:76380kb
  • [2023-12-23 21:22:00]
  • 提交

answer

// 
pub mod solution {

use crate::collections::min_max::MinimMaxim;
use crate::io::input::Input;
use crate::io::output::Output;
use crate::misc::memo::memoization_vec::Memoization1d;
use crate::misc::recursive_function::Callable;

type PreCalc = ();

fn solve(input: &mut Input, out: &mut Output, _test_case: usize, _data: &PreCalc) {
    let a = input.read_size();
    let b = input.read_size();
    let m = input.read_size();

    if a == b {
        out.print_line((1 + m / a) * 320);
        return;
    }
    let mut mem = Memoization1d::new(m + 1, |mem, rem| {
        if rem < b {
            2 + rem / a
        } else {
            let mut res: usize = 2 + b / a + mem.call(rem - b) - 1;
            let need_time = b - b % a + a;
            if need_time <= rem {
                res.maxim(2 + b / a + mem.call(rem - need_time));
            }
            res
        }
    });
    out.print_line(mem.call(m) * 160);
}

pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
    let pre_calc = ();

    #[allow(dead_code)]
    enum TestType {
        Single,
        MultiNumber,
        MultiEof,
    }
    let test_type = TestType::MultiNumber;
    match test_type {
        TestType::Single => solve(&mut input, &mut output, 1, &pre_calc),
        TestType::MultiNumber => {
            let t = input.read();
            for i in 1..=t {
                solve(&mut input, &mut output, i, &pre_calc);
            }
        }
        TestType::MultiEof => {
            let mut i = 1;
            while input.peek().is_some() {
                solve(&mut input, &mut output, i, &pre_calc);
                i += 1;
            }
        }
    }
    output.flush();
    input.skip_whitespace();
    input.peek().is_none()
}

}
pub mod collections {
pub mod min_max {
pub trait MinimMaxim<Rhs = Self>: PartialOrd + Sized {
    fn minim(&mut self, other: Rhs) -> bool;

    fn maxim(&mut self, other: Rhs) -> bool;
}

impl<T: PartialOrd> MinimMaxim for T {
    fn minim(&mut self, other: Self) -> bool {
        if other < *self {
            *self = other;
            true
        } else {
            false
        }
    }

    fn maxim(&mut self, other: Self) -> bool {
        if other > *self {
            *self = other;
            true
        } else {
            false
        }
    }
}

impl<T: PartialOrd> MinimMaxim<T> for Option<T> {
    fn minim(&mut self, other: T) -> bool {
        match self {
            None => {
                *self = Some(other);
                true
            }
            Some(v) => v.minim(other),
        }
    }

    fn maxim(&mut self, other: T) -> bool {
        match self {
            None => {
                *self = Some(other);
                true
            }
            Some(v) => v.maxim(other),
        }
    }
}
}
pub mod vec_ext {
pub mod default {
pub fn default_vec<T: Default>(len: usize) -> Vec<T> {
    let mut v = Vec::with_capacity(len);
    for _ in 0..len {
        v.push(T::default());
    }
    v
}
}
}
}
pub mod io {
pub mod input {
use crate::collections::vec_ext::default::default_vec;
use std::io::Read;

pub struct Input<'s> {
    input: &'s mut dyn Read,
    buf: Vec<u8>,
    at: usize,
    buf_read: usize,
}

macro_rules! read_impl {
    ($t: ty, $read_name: ident, $read_vec_name: ident) => {
        pub fn $read_name(&mut self) -> $t {
            self.read()
        }

        pub fn $read_vec_name(&mut self, len: usize) -> Vec<$t> {
            self.read_vec(len)
        }
    };

    ($t: ty, $read_name: ident, $read_vec_name: ident, $read_pair_vec_name: ident) => {
        read_impl!($t, $read_name, $read_vec_name);

        pub fn $read_pair_vec_name(&mut self, len: usize) -> Vec<($t, $t)> {
            self.read_vec(len)
        }
    };
}

impl<'s> Input<'s> {
    const DEFAULT_BUF_SIZE: usize = 4096;

    pub fn new(input: &'s mut dyn Read) -> Self {
        Self {
            input,
            buf: default_vec(Self::DEFAULT_BUF_SIZE),
            at: 0,
            buf_read: 0,
        }
    }

    pub fn new_with_size(input: &'s mut dyn Read, buf_size: usize) -> Self {
        Self {
            input,
            buf: default_vec(buf_size),
            at: 0,
            buf_read: 0,
        }
    }

    pub fn get(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            self.at += 1;
            if res == b'\r' {
                if self.refill_buffer() && self.buf[self.at] == b'\n' {
                    self.at += 1;
                }
                return Some(b'\n');
            }
            Some(res)
        } else {
            None
        }
    }

    pub fn peek(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            Some(if res == b'\r' { b'\n' } else { res })
        } else {
            None
        }
    }

    pub fn skip_whitespace(&mut self) {
        while let Some(b) = self.peek() {
            if !char::from(b).is_whitespace() {
                return;
            }
            self.get();
        }
    }

    pub fn next_token(&mut self) -> Option<Vec<u8>> {
        self.skip_whitespace();
        let mut res = Vec::new();
        while let Some(c) = self.get() {
            if char::from(c).is_whitespace() {
                break;
            }
            res.push(c);
        }
        if res.is_empty() {
            None
        } else {
            Some(res)
        }
    }

    //noinspection RsSelfConvention
    pub fn is_exhausted(&mut self) -> bool {
        self.peek().is_none()
    }

    //noinspection RsSelfConvention
    pub fn is_empty(&mut self) -> bool {
        self.skip_whitespace();
        self.is_exhausted()
    }

    pub fn read<T: Readable>(&mut self) -> T {
        T::read(self)
    }

    pub fn read_vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
        let mut res = Vec::with_capacity(size);
        for _ in 0..size {
            res.push(self.read());
        }
        res
    }

    pub fn read_char(&mut self) -> char {
        self.skip_whitespace();
        self.get().unwrap().into()
    }

    read_impl!(u32, read_unsigned, read_unsigned_vec);
    read_impl!(u64, read_u64, read_u64_vec);
    read_impl!(usize, read_size, read_size_vec, read_size_pair_vec);
    read_impl!(i32, read_int, read_int_vec, read_int_pair_vec);
    read_impl!(i64, read_long, read_long_vec, read_long_pair_vec);
    read_impl!(i128, read_i128, read_i128_vec);

    fn refill_buffer(&mut self) -> bool {
        if self.at == self.buf_read {
            self.at = 0;
            self.buf_read = self.input.read(&mut self.buf).unwrap();
            self.buf_read != 0
        } else {
            true
        }
    }
}

pub trait Readable {
    fn read(input: &mut Input) -> Self;
}

impl Readable for char {
    fn read(input: &mut Input) -> Self {
        input.read_char()
    }
}

impl<T: Readable> Readable for Vec<T> {
    fn read(input: &mut Input) -> Self {
        let size = input.read();
        input.read_vec(size)
    }
}

macro_rules! read_integer {
    ($($t:ident)+) => {$(
        impl Readable for $t {
            fn read(input: &mut Input) -> Self {
                input.skip_whitespace();
                let mut c = input.get().unwrap();
                let sgn = match c {
                    b'-' => {
                        c = input.get().unwrap();
                        true
                    }
                    b'+' => {
                        c = input.get().unwrap();
                        false
                    }
                    _ => false,
                };
                let mut res = 0;
                loop {
                    assert!(c.is_ascii_digit());
                    res *= 10;
                    let d = (c - b'0') as $t;
                    if sgn {
                        res -= d;
                    } else {
                        res += d;
                    }
                    match input.get() {
                        None => break,
                        Some(ch) => {
                            if ch.is_ascii_whitespace() {
                                break;
                            } else {
                                c = ch;
                            }
                        }
                    }
                }
                res
            }
        }
    )+};
}

read_integer!(i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize);

macro_rules! tuple_readable {
    ($($name:ident)+) => {
        impl<$($name: Readable), +> Readable for ($($name,)+) {
            fn read(input: &mut Input) -> Self {
                ($($name::read(input),)+)
            }
        }
    }
}

tuple_readable! {T}
tuple_readable! {T U}
tuple_readable! {T U V}
tuple_readable! {T U V X}
tuple_readable! {T U V X Y}
tuple_readable! {T U V X Y Z}
tuple_readable! {T U V X Y Z A}
tuple_readable! {T U V X Y Z A B}
tuple_readable! {T U V X Y Z A B C}
tuple_readable! {T U V X Y Z A B C D}
tuple_readable! {T U V X Y Z A B C D E}
tuple_readable! {T U V X Y Z A B C D E F}

impl Read for Input<'_> {
    fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
        if self.at == self.buf_read {
            self.input.read(buf)
        } else {
            let mut i = 0;
            while i < buf.len() && self.at < self.buf_read {
                buf[i] = self.buf[self.at];
                i += 1;
                self.at += 1;
            }
            Ok(i)
        }
    }
}
}
pub mod output {
use crate::collections::vec_ext::default::default_vec;
use std::io::{stderr, Stderr, Write};

#[derive(Copy, Clone)]
pub enum BoolOutput {
    YesNo,
    YesNoCaps,
    PossibleImpossible,
    Custom(&'static str, &'static str),
}

impl BoolOutput {
    pub fn output(&self, output: &mut Output, val: bool) {
        (if val { self.yes() } else { self.no() }).write(output);
    }

    fn yes(&self) -> &str {
        match self {
            BoolOutput::YesNo => "Yes",
            BoolOutput::YesNoCaps => "YES",
            BoolOutput::PossibleImpossible => "Possible",
            BoolOutput::Custom(yes, _) => yes,
        }
    }

    fn no(&self) -> &str {
        match self {
            BoolOutput::YesNo => "No",
            BoolOutput::YesNoCaps => "NO",
            BoolOutput::PossibleImpossible => "Impossible",
            BoolOutput::Custom(_, no) => no,
        }
    }
}

pub struct Output<'s> {
    output: &'s mut dyn Write,
    buf: Vec<u8>,
    at: usize,
    auto_flush: bool,
    bool_output: BoolOutput,
}

impl<'s> Output<'s> {
    const DEFAULT_BUF_SIZE: usize = 4096;

    pub fn new(output: &'s mut dyn Write) -> Self {
        Self {
            output,
            buf: default_vec(Self::DEFAULT_BUF_SIZE),
            at: 0,
            auto_flush: false,
            bool_output: BoolOutput::YesNoCaps,
        }
    }

    pub fn new_with_auto_flush(output: &'s mut dyn Write) -> Self {
        Self {
            output,
            buf: default_vec(Self::DEFAULT_BUF_SIZE),
            at: 0,
            auto_flush: true,
            bool_output: BoolOutput::YesNoCaps,
        }
    }

    pub fn flush(&mut self) {
        if self.at != 0 {
            self.output.write_all(&self.buf[..self.at]).unwrap();
            self.output.flush().unwrap();
            self.at = 0;
        }
    }

    pub fn print<T: Writable>(&mut self, s: T) {
        s.write(self);
        self.maybe_flush();
    }

    pub fn print_line<T: Writable>(&mut self, s: T) {
        self.print(s);
        self.put(b'\n');
        self.maybe_flush();
    }

    pub fn put(&mut self, b: u8) {
        self.buf[self.at] = b;
        self.at += 1;
        if self.at == self.buf.len() {
            self.flush();
        }
    }

    pub fn maybe_flush(&mut self) {
        if self.auto_flush {
            self.flush();
        }
    }

    pub fn print_per_line<T: Writable>(&mut self, arg: &[T]) {
        for i in arg {
            i.write(self);
            self.put(b'\n');
        }
    }

    pub fn print_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }

    pub fn print_iter_ref<'a, T: 'a + Writable, I: Iterator<Item = &'a T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }

    pub fn set_bool_output(&mut self, bool_output: BoolOutput) {
        self.bool_output = bool_output;
    }
}

impl Write for Output<'_> {
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
        let mut start = 0usize;
        let mut rem = buf.len();
        while rem > 0 {
            let len = (self.buf.len() - self.at).min(rem);
            self.buf[self.at..self.at + len].copy_from_slice(&buf[start..start + len]);
            self.at += len;
            if self.at == self.buf.len() {
                self.flush();
            }
            start += len;
            rem -= len;
        }
        self.maybe_flush();
        Ok(buf.len())
    }

    fn flush(&mut self) -> std::io::Result<()> {
        self.flush();
        Ok(())
    }
}

pub trait Writable {
    fn write(&self, output: &mut Output);
}

impl Writable for &str {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for String {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for char {
    fn write(&self, output: &mut Output) {
        output.put(*self as u8);
    }
}

impl<T: Writable> Writable for [T] {
    fn write(&self, output: &mut Output) {
        output.print_iter_ref(self.iter());
    }
}

impl<T: Writable, const N: usize> Writable for [T; N] {
    fn write(&self, output: &mut Output) {
        output.print_iter_ref(self.iter());
    }
}

impl<T: Writable> Writable for &T {
    fn write(&self, output: &mut Output) {
        T::write(self, output)
    }
}

impl<T: Writable> Writable for Vec<T> {
    fn write(&self, output: &mut Output) {
        self.as_slice().write(output);
    }
}

impl Writable for () {
    fn write(&self, _output: &mut Output) {}
}

macro_rules! write_to_string {
    ($($t:ident)+) => {$(
        impl Writable for $t {
            fn write(&self, output: &mut Output) {
                self.to_string().write(output);
            }
        }
    )+};
}

write_to_string!(u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);

macro_rules! tuple_writable {
    ($name0:ident $($name:ident: $id:tt )*) => {
        impl<$name0: Writable, $($name: Writable,)*> Writable for ($name0, $($name,)*) {
            fn write(&self, out: &mut Output) {
                self.0.write(out);
                $(
                out.put(b' ');
                self.$id.write(out);
                )*
            }
        }
    }
}

tuple_writable! {T}
tuple_writable! {T U:1}
tuple_writable! {T U:1 V:2}
tuple_writable! {T U:1 V:2 X:3}
tuple_writable! {T U:1 V:2 X:3 Y:4}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5 A:6}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5 A:6 B:7}

impl<T: Writable> Writable for Option<T> {
    fn write(&self, output: &mut Output) {
        match self {
            None => (-1).write(output),
            Some(t) => t.write(output),
        }
    }
}

impl Writable for bool {
    fn write(&self, output: &mut Output) {
        let bool_output = output.bool_output;
        bool_output.output(output, *self)
    }
}

static mut ERR: Option<Stderr> = None;
pub fn err() -> Output<'static> {
    unsafe {
        if ERR.is_none() {
            ERR = Some(stderr());
        }
        Output::new_with_auto_flush(ERR.as_mut().unwrap())
    }
}
}
}
pub mod misc {
pub mod memo {
pub mod memoization_vec {
use crate::misc::recursive_function::Callable;

pub struct Memoization1d<F, Output>
where
    F: FnMut(&mut dyn Callable<usize, Output>, usize) -> Output,
{
    f: std::cell::UnsafeCell<F>,
    res: Vec<Option<Output>>,
}

impl<F, Output: Clone> Memoization1d<F, Output>
where
    F: FnMut(&mut dyn Callable<usize, Output>, usize) -> Output,
{
    pub fn new(len: usize, f: F) -> Self {
        Self {
            f: std::cell::UnsafeCell::new(f),
            res: vec![None; len],
        }
    }
}

impl<F, Output: Clone> Callable<usize, Output> for Memoization1d<F, Output>
where
    F: FnMut(&mut dyn Callable<usize, Output>, usize) -> Output,
{
    fn call(&mut self, n: usize) -> Output {
        match self.res[n].as_ref() {
            None => {
                let res = unsafe { (*self.f.get())(self, n) };
                self.res[n] = Some(res.clone());
                res
            }
            Some(res) => res.clone(),
        }
    }
}
}
}
pub mod recursive_function {
use std::marker::PhantomData;

macro_rules! recursive_function {
    ($name: ident, $trait: ident, ($($type: ident $arg: ident,)*)) => {
        pub trait $trait<$($type, )*Output> {
            fn call(&mut self, $($arg: $type,)*) -> Output;
        }

        pub struct $name<F, $($type, )*Output>
        where
            F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
        {
            f: std::cell::UnsafeCell<F>,
            $($arg: PhantomData<$type>,
            )*
            phantom_output: PhantomData<Output>,
        }

        impl<F, $($type, )*Output> $name<F, $($type, )*Output>
        where
            F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
        {
            pub fn new(f: F) -> Self {
                Self {
                    f: std::cell::UnsafeCell::new(f),
                    $($arg: Default::default(),
                    )*
                    phantom_output: Default::default(),
                }
            }
        }

        impl<F, $($type, )*Output> $trait<$($type, )*Output> for $name<F, $($type, )*Output>
        where
            F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
        {
            fn call(&mut self, $($arg: $type,)*) -> Output {
                unsafe { (*self.f.get())(self, $($arg, )*) }
            }
        }
    }
}

recursive_function!(RecursiveFunction0, Callable0, ());
recursive_function!(RecursiveFunction, Callable, (Arg arg,));
recursive_function!(RecursiveFunction2, Callable2, (Arg1 arg1, Arg2 arg2,));
recursive_function!(RecursiveFunction3, Callable3, (Arg1 arg1, Arg2 arg2, Arg3 arg3,));
recursive_function!(RecursiveFunction4, Callable4, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4,));
recursive_function!(RecursiveFunction5, Callable5, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5,));
recursive_function!(RecursiveFunction6, Callable6, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6,));
recursive_function!(RecursiveFunction7, Callable7, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7,));
recursive_function!(RecursiveFunction8, Callable8, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, Arg8 arg8,));
recursive_function!(RecursiveFunction9, Callable9, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, Arg8 arg8, Arg9 arg9,));
}
}
fn main() {
    let mut sin = std::io::stdin();
    let input = if false {
        io::input::Input::new_with_size(&mut sin, 1)
    } else {
        io::input::Input::new(&mut sin)
    };

    let mut stdout = std::io::stdout();
    let output = if false {
        io::output::Output::new_with_auto_flush(&mut stdout)
    } else {
        io::output::Output::new(&mut stdout)
    };

    solution::run(input, output);
}


这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 2064kb

input:

6
50 100 0
40 10 50
10 40 50
1 1 1000000
60 200 960
60 185 905

output:

320
1120
1280
320000320
3520
3360

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 2ms
memory: 1956kb

input:

10000
1 1 0
1 1 1
1 1 2
1 1 3
1 1 4
1 1 5
1 1 6
1 1 7
1 1 8
1 1 9
1 1 10
1 1 11
1 1 12
1 1 13
1 1 14
1 1 15
1 1 16
1 1 17
1 1 18
1 1 19
1 1 20
1 1 21
1 1 22
1 1 23
1 1 24
1 1 25
1 1 26
1 1 27
1 1 28
1 1 29
1 1 30
1 1 31
1 1 32
1 1 33
1 1 34
1 1 35
1 1 36
1 1 37
1 1 38
1 1 39
1 1 40
1 1 41
1 1 42
1 1...

output:

320
640
960
1280
1600
1920
2240
2560
2880
3200
3520
3840
4160
4480
4800
5120
5440
5760
6080
6400
6720
7040
7360
7680
8000
8320
8640
8960
9280
9600
9920
10240
10560
10880
11200
11520
11840
12160
12480
12800
13120
13440
13760
14080
14400
14720
15040
15360
15680
16000
320
480
800
960
1280
1440
1760
192...

result:

ok 10000 lines

Test #3:

score: 0
Accepted
time: 4ms
memory: 2004kb

input:

10000
1 1 50
1 1 51
1 1 52
1 1 53
1 1 54
1 1 55
1 1 56
1 1 57
1 1 58
1 1 59
1 1 60
1 1 61
1 1 62
1 1 63
1 1 64
1 1 65
1 1 66
1 1 67
1 1 68
1 1 69
1 1 70
1 1 71
1 1 72
1 1 73
1 1 74
1 1 75
1 1 76
1 1 77
1 1 78
1 1 79
1 1 80
1 1 81
1 1 82
1 1 83
1 1 84
1 1 85
1 1 86
1 1 87
1 1 88
1 1 89
1 1 90
1 1 91
...

output:

16320
16640
16960
17280
17600
17920
18240
18560
18880
19200
19520
19840
20160
20480
20800
21120
21440
21760
22080
22400
22720
23040
23360
23680
24000
24320
24640
24960
25280
25600
25920
26240
26560
26880
27200
27520
27840
28160
28480
28800
29120
29440
29760
30080
30400
30720
31040
31360
31680
32000
...

result:

ok 10000 lines

Test #4:

score: 0
Accepted
time: 7ms
memory: 1988kb

input:

10000
1 1 100
1 1 101
1 1 102
1 1 103
1 1 104
1 1 105
1 1 106
1 1 107
1 1 108
1 1 109
1 1 110
1 1 111
1 1 112
1 1 113
1 1 114
1 1 115
1 1 116
1 1 117
1 1 118
1 1 119
1 1 120
1 1 121
1 1 122
1 1 123
1 1 124
1 1 125
1 1 126
1 1 127
1 1 128
1 1 129
1 1 130
1 1 131
1 1 132
1 1 133
1 1 134
1 1 135
1 1 13...

output:

32320
32640
32960
33280
33600
33920
34240
34560
34880
35200
35520
35840
36160
36480
36800
37120
37440
37760
38080
38400
38720
39040
39360
39680
40000
40320
40640
40960
41280
41600
41920
42240
42560
42880
43200
43520
43840
44160
44480
44800
45120
45440
45760
46080
46400
46720
47040
47360
47680
48000
...

result:

ok 10000 lines

Test #5:

score: 0
Accepted
time: 9ms
memory: 2060kb

input:

10000
1 1 150
1 1 151
1 1 152
1 1 153
1 1 154
1 1 155
1 1 156
1 1 157
1 1 158
1 1 159
1 1 160
1 1 161
1 1 162
1 1 163
1 1 164
1 1 165
1 1 166
1 1 167
1 1 168
1 1 169
1 1 170
1 1 171
1 1 172
1 1 173
1 1 174
1 1 175
1 1 176
1 1 177
1 1 178
1 1 179
1 1 180
1 1 181
1 1 182
1 1 183
1 1 184
1 1 185
1 1 18...

output:

48320
48640
48960
49280
49600
49920
50240
50560
50880
51200
51520
51840
52160
52480
52800
53120
53440
53760
54080
54400
54720
55040
55360
55680
56000
56320
56640
56960
57280
57600
57920
58240
58560
58880
59200
59520
59840
60160
60480
60800
61120
61440
61760
62080
62400
62720
63040
63360
63680
64000
...

result:

ok 10000 lines

Test #6:

score: 0
Accepted
time: 12ms
memory: 2088kb

input:

10000
1 1 200
1 1 201
1 1 202
1 1 203
1 1 204
1 1 205
1 1 206
1 1 207
1 1 208
1 1 209
1 1 210
1 1 211
1 1 212
1 1 213
1 1 214
1 1 215
1 1 216
1 1 217
1 1 218
1 1 219
1 1 220
1 1 221
1 1 222
1 1 223
1 1 224
1 1 225
1 1 226
1 1 227
1 1 228
1 1 229
1 1 230
1 1 231
1 1 232
1 1 233
1 1 234
1 1 235
1 1 23...

output:

64320
64640
64960
65280
65600
65920
66240
66560
66880
67200
67520
67840
68160
68480
68800
69120
69440
69760
70080
70400
70720
71040
71360
71680
72000
72320
72640
72960
73280
73600
73920
74240
74560
74880
75200
75520
75840
76160
76480
76800
77120
77440
77760
78080
78400
78720
79040
79360
79680
80000
...

result:

ok 10000 lines

Test #7:

score: 0
Accepted
time: 105ms
memory: 2268kb

input:

4471
5 3 0
5 3 1
5 3 2
5 3 3
5 3 4
5 3 5
5 3 6
5 3 7
5 3 8
5 3 9
5 3 10
5 3 11
5 3 12
5 3 13
5 3 14
5 3 15
5 3 16
5 3 17
5 3 18
5 3 19
5 3 20
5 3 21
5 3 22
5 3 23
5 3 24
5 3 25
5 3 26
5 3 27
5 3 28
5 3 29
5 3 30
5 3 31
5 3 32
5 3 33
5 3 34
5 3 35
5 3 36
5 3 37
5 3 38
5 3 39
5 3 40
5 3 41
5 3 42
5 3 ...

output:

320
320
320
480
480
640
640
640
800
800
960
960
960
1120
1120
1280
1280
1280
1440
1440
1600
1600
1600
1760
1760
1920
1920
1920
2080
2080
2240
2240
2240
2400
2400
2560
2560
2560
2720
2720
2880
2880
2880
3040
3040
3200
3200
3200
3360
3360
3520
3520
3520
3680
3680
3840
3840
3840
4000
4000
4160
4160
416...

result:

ok 4471 lines

Test #8:

score: 0
Accepted
time: 104ms
memory: 2264kb

input:

4471
7 3 0
7 3 1
7 3 2
7 3 3
7 3 4
7 3 5
7 3 6
7 3 7
7 3 8
7 3 9
7 3 10
7 3 11
7 3 12
7 3 13
7 3 14
7 3 15
7 3 16
7 3 17
7 3 18
7 3 19
7 3 20
7 3 21
7 3 22
7 3 23
7 3 24
7 3 25
7 3 26
7 3 27
7 3 28
7 3 29
7 3 30
7 3 31
7 3 32
7 3 33
7 3 34
7 3 35
7 3 36
7 3 37
7 3 38
7 3 39
7 3 40
7 3 41
7 3 42
7 3 ...

output:

320
320
320
480
480
480
640
640
640
800
800
800
960
960
960
1120
1120
1120
1280
1280
1280
1440
1440
1440
1600
1600
1600
1760
1760
1760
1920
1920
1920
2080
2080
2080
2240
2240
2240
2400
2400
2400
2560
2560
2560
2720
2720
2720
2880
2880
2880
3040
3040
3040
3200
3200
3200
3360
3360
3360
3520
3520
3520
...

result:

ok 4471 lines

Test #9:

score: 0
Accepted
time: 63ms
memory: 2400kb

input:

4471
3 4 0
3 4 1
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
3 4 11
3 4 12
3 4 13
3 4 14
3 4 15
3 4 16
3 4 17
3 4 18
3 4 19
3 4 20
3 4 21
3 4 22
3 4 23
3 4 24
3 4 25
3 4 26
3 4 27
3 4 28
3 4 29
3 4 30
3 4 31
3 4 32
3 4 33
3 4 34
3 4 35
3 4 36
3 4 37
3 4 38
3 4 39
3 4 40
3 4 41
3 4 42
3 4 ...

output:

320
320
320
480
640
640
800
800
960
960
1120
1120
1280
1280
1440
1440
1600
1600
1760
1760
1920
1920
2080
2080
2240
2240
2400
2400
2560
2560
2720
2720
2880
2880
3040
3040
3200
3200
3360
3360
3520
3520
3680
3680
3840
3840
4000
4000
4160
4160
4320
4320
4480
4480
4640
4640
4800
4800
4960
4960
5120
5120
...

result:

ok 4471 lines

Test #10:

score: 0
Accepted
time: 87ms
memory: 2068kb

input:

4471
5 7 0
5 7 1
5 7 2
5 7 3
5 7 4
5 7 5
5 7 6
5 7 7
5 7 8
5 7 9
5 7 10
5 7 11
5 7 12
5 7 13
5 7 14
5 7 15
5 7 16
5 7 17
5 7 18
5 7 19
5 7 20
5 7 21
5 7 22
5 7 23
5 7 24
5 7 25
5 7 26
5 7 27
5 7 28
5 7 29
5 7 30
5 7 31
5 7 32
5 7 33
5 7 34
5 7 35
5 7 36
5 7 37
5 7 38
5 7 39
5 7 40
5 7 41
5 7 42
5 7 ...

output:

320
320
320
320
320
480
480
640
640
640
800
800
800
800
960
960
960
1120
1120
1120
1280
1280
1280
1280
1440
1440
1440
1600
1600
1600
1760
1760
1760
1760
1920
1920
1920
2080
2080
2080
2240
2240
2240
2240
2400
2400
2400
2560
2560
2560
2720
2720
2720
2720
2880
2880
2880
3040
3040
3040
3200
3200
3200
32...

result:

ok 4471 lines

Test #11:

score: 0
Accepted
time: 31ms
memory: 2248kb

input:

4471
7 15 0
7 15 1
7 15 2
7 15 3
7 15 4
7 15 5
7 15 6
7 15 7
7 15 8
7 15 9
7 15 10
7 15 11
7 15 12
7 15 13
7 15 14
7 15 15
7 15 16
7 15 17
7 15 18
7 15 19
7 15 20
7 15 21
7 15 22
7 15 23
7 15 24
7 15 25
7 15 26
7 15 27
7 15 28
7 15 29
7 15 30
7 15 31
7 15 32
7 15 33
7 15 34
7 15 35
7 15 36
7 15 37
7...

output:

320
320
320
320
320
320
320
480
480
480
480
480
480
480
640
800
800
800
800
800
800
960
960
960
960
960
960
960
1120
1120
1280
1280
1280
1280
1280
1280
1440
1440
1440
1440
1440
1440
1600
1600
1600
1760
1760
1760
1760
1760
1760
1920
1920
1920
1920
1920
1920
2080
2080
2080
2240
2240
2240
2240
2240
224...

result:

ok 4471 lines

Test #12:

score: 0
Accepted
time: 13ms
memory: 2348kb

input:

4471
6 24 0
6 24 1
6 24 2
6 24 3
6 24 4
6 24 5
6 24 6
6 24 7
6 24 8
6 24 9
6 24 10
6 24 11
6 24 12
6 24 13
6 24 14
6 24 15
6 24 16
6 24 17
6 24 18
6 24 19
6 24 20
6 24 21
6 24 22
6 24 23
6 24 24
6 24 25
6 24 26
6 24 27
6 24 28
6 24 29
6 24 30
6 24 31
6 24 32
6 24 33
6 24 34
6 24 35
6 24 36
6 24 37
6...

output:

320
320
320
320
320
320
480
480
480
480
480
480
640
640
640
640
640
640
800
800
800
800
800
800
1120
1120
1120
1120
1120
1120
1280
1280
1280
1280
1280
1280
1440
1440
1440
1440
1440
1440
1600
1600
1600
1600
1600
1600
1920
1920
1920
1920
1920
1920
2080
2080
2080
2080
2080
2080
2240
2240
2240
2240
2240...

result:

ok 4471 lines

Test #13:

score: 0
Accepted
time: 2ms
memory: 2080kb

input:

10000
6 7 100
8 5 61
5 75 59
65 51 47
83 37 34
54 87 46
4 26 21
87 12 97
86 68 60
11 62 76
14 83 29
31 91 62
57 80 47
75 85 97
62 77 91
86 14 25
48 77 83
65 39 61
78 77 45
46 90 74
100 91 86
98 55 5
84 42 91
69 100 4
74 98 60
37 75 44
41 12 15
34 36 1
99 16 7
87 36 26
79 42 41
84 17 98
72 16 38
55 1...

output:

4800
2720
2080
320
320
320
1120
1600
320
1440
640
640
320
640
640
480
640
480
320
480
320
320
640
320
320
480
480
320
320
320
320
1120
640
480
1280
320
320
480
320
1280
1120
320
480
1920
320
480
320
1760
1120
320
1280
480
640
320
640
640
640
640
320
320
960
320
320
640
640
4160
1280
1280
960
800
112...

result:

ok 10000 lines

Test #14:

score: 0
Accepted
time: 6ms
memory: 3104kb

input:

1000
65 223 7831
58 236 7220
88 505 9697
67 828 4245
15 832 4221
13 619 4604
68 538 8571
66 890 772
58 823 9165
63 915 9242
12 771 8597
72 74 7578
88 729 2100
20 639 3081
14 326 2224
84 434 6660
83 154 2645
77 399 9160
80 958 7504
42 997 7747
51 99 535
13 841 8540
89 911 6301
64 928 2494
57 621 6548...

output:

24320
24640
20800
11040
46080
58080
22880
2080
27200
25120
116640
32960
4320
25600
26560
15040
7840
22400
16320
30880
2720
106880
12480
6720
20160
3040
19040
18720
16480
19840
29280
5920
18240
68160
7040
3200
13600
36320
10560
21760
30720
10400
28480
40320
2720
800
60640
8000
13920
1143360
32000
112...

result:

ok 1000 lines

Test #15:

score: 0
Accepted
time: 65ms
memory: 76380kb

input:

10
10 1 832732
1 3 522866
1 6 128429
10 9 919864
4 9 333256
3 4 553309
7 4 374556
9 4 271091
2 8 875398
8 10 379537

output:

133237440
111544960
23973600
29435840
17773920
44264960
17122880
10843840
87540000
12145440

result:

ok 10 lines

Test #16:

score: 0
Accepted
time: 51ms
memory: 35452kb

input:

10
97 96 339969
8 49 676417
24 49 374754
18 3 520864
81 39 423754
63 95 328346
97 57 641650
7 2 69638
71 91 629277
89 51 811948

output:

1121600
15461280
3671360
27779680
1738720
1251040
2116960
5571360
2213120
2919680

result:

ok 10 lines

Test #17:

score: 0
Accepted
time: 2ms
memory: 2484kb

input:

1000
352 6973 4250
9698 6537 2807
9351 7213 4446
8761 678 6543
9998 9340 6975
8041 3853 7741
5408 851 5875
7341 7659 3912
43 3040 5926
6997 9188 271
9785 206 4259
2326 1204 7610
1695 8870 2966
1298 9492 3476
4679 6598 8449
696 3487 7559
618 7359 3532
5566 1206 9898
768 884 9282
989 8545 1624
8236 52...

output:

2240
320
320
1760
320
640
1280
320
22400
320
3520
1280
480
640
640
2240
1120
1600
3520
480
480
640
960
960
320
2880
640
1440
320
3840
320
320
960
640
15680
640
640
640
800
480
1440
640
18560
480
320
480
640
320
640
1600
320
480
320
480
800
320
480
640
640
320
320
480
1440
320
800
320
480
800
1120
32...

result:

ok 1000 lines

Test #18:

score: 0
Accepted
time: 3ms
memory: 22556kb

input:

10
438056 72759 404243
221169 26025 363145
109481 793560 122317
355333 503166 896923
523400 910677 61841
513532 649927 225587
33880 233809 954983
526384 136123 343300
436283 238510 469080
986898 462601 192358

output:

1120
2400
480
800
320
320
5440
640
640
320

result:

ok 10 lines

Extra Test:

score: 0
Extra Test Passed