QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#433317 | #8795. Mysterious Sequence | ucup-team635# | AC ✓ | 0ms | 2372kb | Rust | 2.3kb | 2024-06-08 10:18:51 | 2024-06-08 10:18:52 |
Judging History
answer
use std::io::Write;
use std::collections::*;
type Map<K, V> = BTreeMap<K, V>;
type Set<T> = BTreeSet<T>;
type Deque<T> = VecDeque<T>;
fn main() {
input! {
a: f64,
b: f64,
n: usize,
x: f64,
z: f64,
}
let eval = |v: f64| -> [f64; 10] {
let mut p = [0f64; 10];
p[0] = x;
p[1] = v;
for i in 2..n {
p[i] = a * p[i - 1] + b * p[i - 2];
}
p
};
let mut l = -10f64.powi(16);
let mut r = 10f64.powi(16);
for _ in 0..100 {
let m = (l + r) * 0.5;
if eval(m)[n - 1] >= z {
r = m;
} else {
l = m;
}
}
let a = eval((l + r) * 0.5);
for a in a.iter().take(n) {
println!("{:.7}", *a);
}
}
// ---------- begin input macro ----------
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[macro_export]
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
input_inner!{iter, $($r)*}
};
($($r:tt)*) => {
let s = {
use std::io::Read;
let mut s = String::new();
std::io::stdin().read_to_string(&mut s).unwrap();
s
};
let mut iter = s.split_whitespace();
input_inner!{iter, $($r)*}
};
}
#[macro_export]
macro_rules! input_inner {
($iter:expr) => {};
($iter:expr, ) => {};
($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($iter, $t);
input_inner!{$iter $($r)*}
};
}
#[macro_export]
macro_rules! read_value {
($iter:expr, ( $($t:tt),* )) => {
( $(read_value!($iter, $t)),* )
};
($iter:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
};
($iter:expr, chars) => {
read_value!($iter, String).chars().collect::<Vec<char>>()
};
($iter:expr, bytes) => {
read_value!($iter, String).bytes().collect::<Vec<u8>>()
};
($iter:expr, usize1) => {
read_value!($iter, usize) - 1
};
($iter:expr, $t:ty) => {
$iter.next().unwrap().parse::<$t>().expect("Parse error")
};
}
// ---------- end input macro ----------
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 2228kb
input:
1.0 1.0 10 1 10
output:
1.0000000 -0.3235294 0.6764706 0.3529412 1.0294118 1.3823529 2.4117647 3.7941176 6.2058824 10.0000000
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 2268kb
input:
1 1 2 1 100
output:
1.0000000 100.0000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 2144kb
input:
1 1 5 50 100
output:
50.0000000 -0.0000000 50.0000000 50.0000000 100.0000000
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 2224kb
input:
0.25 0.25 10 1 1
output:
1.0000000 55.8755365 14.2188841 17.5236052 7.9356223 6.3648069 3.5751073 2.4849785 1.5150215 1.0000000
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 2172kb
input:
0.25 0.63 6 93 12
output:
93.0000000 -14.2048080 55.0387980 4.8106705 35.8771104 12.0000000
result:
ok 6 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 2120kb
input:
0.25 0.80 10 5 63
output:
5.0000000 78.7695362 23.6923840 68.9387250 36.1885885 64.1981271 45.0004026 62.6086023 51.6524726 63.0000000
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 0ms
memory: 2232kb
input:
0.25 0.99 3 18 30
output:
18.0000000 48.7200000 30.0000000
result:
ok 3 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 2232kb
input:
0.28 0.64 9 6 10
output:
6.0000000 20.9504033 9.7061129 16.1259698 10.7271838 13.3242321 10.5961826 11.4944397 10.0000000
result:
ok 9 numbers
Test #9:
score: 0
Accepted
time: 0ms
memory: 2312kb
input:
0.31 0.40 7 10 49
output:
10.0000000 240.1150640 78.4356698 120.3610832 68.6862037 69.4371565 49.0000000
result:
ok 7 numbers
Test #10:
score: 0
Accepted
time: 0ms
memory: 2132kb
input:
0.32 0.28 5 36 6
output:
36.0000000 10.1213768 13.3188406 7.0960145 6.0000000
result:
ok 5 numbers
Test #11:
score: 0
Accepted
time: 0ms
memory: 2292kb
input:
0.35 0.65 10 86 82
output:
86.0000000 79.5339248 83.7368737 81.0049569 82.7807028 81.6264680 82.3767206 81.8890564 82.2060381 82.0000000
result:
ok 10 numbers
Test #12:
score: 0
Accepted
time: 0ms
memory: 2164kb
input:
0.36 0.68 8 72 59
output:
72.0000000 38.2399186 62.7263707 48.5846381 60.1444018 54.6895386 60.5864271 59.0000000
result:
ok 8 numbers
Test #13:
score: 0
Accepted
time: 0ms
memory: 2236kb
input:
0.43 0.61 2 93 84
output:
93.0000000 84.0000000
result:
ok 2 numbers
Test #14:
score: 0
Accepted
time: 0ms
memory: 2112kb
input:
0.46 0.96 6 65 35
output:
65.0000000 -16.6174237 54.7559851 9.2350264 56.8138579 35.0000000
result:
ok 6 numbers
Test #15:
score: 0
Accepted
time: 0ms
memory: 2076kb
input:
0.50 0.90 4 19 1
output:
19.0000000 -6.5652174 13.8173913 1.0000000
result:
ok 4 numbers
Test #16:
score: 0
Accepted
time: 0ms
memory: 2236kb
input:
0.54 0.35 3 16 22
output:
16.0000000 30.3703704 22.0000000
result:
ok 3 numbers
Test #17:
score: 0
Accepted
time: 0ms
memory: 2228kb
input:
0.55 0.89 10 74 13
output:
74.0000000 -48.3219371 39.2829346 -21.4009100 23.1913113 -6.2915886 17.1798933 3.8494274 17.4072901 13.0000000
result:
ok 10 numbers
Test #18:
score: 0
Accepted
time: 0ms
memory: 2120kb
input:
0.56 0.36 3 31 88
output:
31.0000000 137.2142857 88.0000000
result:
ok 3 numbers
Test #19:
score: 0
Accepted
time: 0ms
memory: 2160kb
input:
0.57 0.93 7 71 48
output:
71.0000000 -34.0805654 46.6040777 -5.1306015 40.4173495 18.2664298 48.0000000
result:
ok 7 numbers
Test #20:
score: 0
Accepted
time: 0ms
memory: 2136kb
input:
0.58 0.41 8 30 69
output:
30.0000000 89.4321217 64.1706306 73.8861356 69.1639172 70.4083876 69.1940708 69.0000000
result:
ok 8 numbers
Test #21:
score: 0
Accepted
time: 0ms
memory: 2100kb
input:
0.58 0.49 6 31 96
output:
31.0000000 99.5576135 72.9334159 91.0846118 88.5664486 96.0000000
result:
ok 6 numbers
Test #22:
score: 0
Accepted
time: 0ms
memory: 2004kb
input:
0.61 0.29 8 62 25
output:
62.0000000 34.4076513 38.9686673 33.7491059 31.8878681 29.2388403 27.0831743 25.0000000
result:
ok 8 numbers
Test #23:
score: 0
Accepted
time: 0ms
memory: 2152kb
input:
0.63 0.89 9 37 85
output:
37.0000000 -5.8878533 29.2206524 13.1688216 34.3027383 33.3309763 51.5279521 62.1271788 85.0000000
result:
ok 9 numbers
Test #24:
score: 0
Accepted
time: 0ms
memory: 2292kb
input:
0.64 0.67 2 74 42
output:
74.0000000 42.0000000
result:
ok 2 numbers
Test #25:
score: 0
Accepted
time: 0ms
memory: 2096kb
input:
0.65 0.56 2 94 96
output:
94.0000000 96.0000000
result:
ok 2 numbers
Test #26:
score: 0
Accepted
time: 0ms
memory: 2352kb
input:
0.65 0.90 10 97 23
output:
97.0000000 -61.7035763 47.1926754 -24.8579796 26.3157211 -5.2669629 20.2606231 8.4291384 23.7135007 23.0000000
result:
ok 10 numbers
Test #27:
score: 0
Accepted
time: 0ms
memory: 2372kb
input:
0.67 0.88 4 70 42
output:
70.0000000 0.5478215 61.9670404 42.0000000
result:
ok 4 numbers
Test #28:
score: 0
Accepted
time: 0ms
memory: 2160kb
input:
0.69 0.39 10 2 27
output:
2.0000000 22.3659077 16.2124763 19.9093126 20.0602915 21.6062331 22.7318145 24.1113829 25.5022618 27.0000000
result:
ok 10 numbers
Test #29:
score: 0
Accepted
time: 0ms
memory: 2228kb
input:
0.69 0.57 4 88 47
output:
88.0000000 11.8436096 58.3320906 47.0000000
result:
ok 4 numbers
Test #30:
score: 0
Accepted
time: 0ms
memory: 2080kb
input:
0.71 0.89 8 4 41
output:
4.0000000 6.8388904 8.4156122 12.0616971 16.0536997 22.1330372 30.0022492 41.0000000
result:
ok 8 numbers
Test #31:
score: 0
Accepted
time: 0ms
memory: 2148kb
input:
0.72 0.49 8 21 48
output:
21.0000000 19.9404424 24.6471185 27.5167421 31.8891424 36.4433861 41.8649178 48.0000000
result:
ok 8 numbers
Test #32:
score: 0
Accepted
time: 0ms
memory: 2164kb
input:
0.74 0.58 3 57 29
output:
57.0000000 -5.4864865 29.0000000
result:
ok 3 numbers
Test #33:
score: 0
Accepted
time: 0ms
memory: 2176kb
input:
0.76 0.70 2 91 18
output:
91.0000000 18.0000000
result:
ok 2 numbers
Test #34:
score: 0
Accepted
time: 0ms
memory: 2108kb
input:
0.77 0.36 10 31 25
output:
31.0000000 5.2149721 15.1755285 13.5625469 15.9063514 17.1304074 18.9167002 20.7328059 22.7742726 25.0000000
result:
ok 10 numbers
Test #35:
score: 0
Accepted
time: 0ms
memory: 2348kb
input:
0.77 0.96 8 78 68
output:
78.0000000 -40.0975570 44.0048811 -4.6098963 38.6950657 25.3697002 56.6819322 68.0000000
result:
ok 8 numbers
Test #36:
score: 0
Accepted
time: 0ms
memory: 2276kb
input:
0.78 0.52 7 73 77
output:
73.0000000 8.7275475 44.7674871 39.4569646 54.0555257 62.6809316 77.0000000
result:
ok 7 numbers
Test #37:
score: 0
Accepted
time: 0ms
memory: 2228kb
input:
0.78 0.69 4 42 97
output:
42.0000000 57.2979051 73.6723660 97.0000000
result:
ok 4 numbers
Test #38:
score: 0
Accepted
time: 0ms
memory: 2160kb
input:
0.78 0.70 10 54 99
output:
54.0000000 -13.0128864 27.6499486 12.4579395 29.0721569 31.3968400 44.8400450 56.9530231 75.8113895 99.0000000
result:
ok 10 numbers
Test #39:
score: 0
Accepted
time: 0ms
memory: 2136kb
input:
0.78 0.76 10 97 83
output:
97.0000000 -43.7347370 39.6069052 -2.3450141 28.2721370 20.2700562 37.2974679 44.4972676 63.0539444 83.0000000
result:
ok 10 numbers
Test #40:
score: 0
Accepted
time: 0ms
memory: 2132kb
input:
0.78 0.95 10 100 32
output:
100.0000000 -63.2695788 45.6497285 -24.4993116 24.2577790 -4.3532784 19.6493329 11.1908652 27.3957411 32.0000000
result:
ok 10 numbers
Test #41:
score: 0
Accepted
time: 0ms
memory: 2144kb
input:
0.79 0.90 10 98 42
output:
98.0000000 -58.2469146 42.1849374 -19.0961226 22.8805069 0.8890901 21.2948373 17.6231026 33.0876047 42.0000000
result:
ok 10 numbers
Test #42:
score: 0
Accepted
time: 0ms
memory: 2160kb
input:
0.81 0.48 10 97 1
output:
97.0000000 -38.2575017 15.5714236 -5.7507477 2.8161777 -0.4792549 0.9635688 0.5504484 0.9083763 1.0000000
result:
ok 10 numbers
Test #43:
score: 0
Accepted
time: 0ms
memory: 2104kb
input:
0.81 0.86 10 20 100
output:
20.0000000 -3.3328429 14.5003973 8.8790769 19.6623940 23.5625453 35.9953205 49.4199985 70.9861744 100.0000000
result:
ok 10 numbers
Test #44:
score: 0
Accepted
time: 0ms
memory: 2228kb
input:
0.84 0.85 10 74 95
output:
74.0000000 -36.2908049 32.4157239 -3.6179761 24.5142654 17.5167033 35.5511564 44.7521692 67.8103050 95.0000000
result:
ok 10 numbers
Test #45:
score: 0
Accepted
time: 0ms
memory: 2352kb
input:
0.88 0.37 10 3 96
output:
3.0000000 29.0218285 26.6492091 34.1893805 39.9468622 47.8033095 56.8472514 67.7128058 80.6207521 96.0000000
result:
ok 10 numbers
Test #46:
score: 0
Accepted
time: 0ms
memory: 2076kb
input:
0.91 0.50 10 100 98
output:
100.0000000 -22.5868579 29.4459594 15.5023941 28.8301583 33.9866411 45.3429225 58.2553801 75.6838571 98.0000000
result:
ok 10 numbers
Test #47:
score: 0
Accepted
time: 0ms
memory: 2148kb
input:
0.94 0.48 10 44 97
output:
44.0000000 -1.5827434 19.6322212 17.6945710 26.0563629 32.9863753 43.5142470 56.7368523 74.2194797 97.0000000
result:
ok 10 numbers
Test #48:
score: 0
Accepted
time: 0ms
memory: 2144kb
input:
0.94 0.54 10 28 95
output:
28.0000000 0.4525463 15.5453935 14.8570449 22.3601347 29.0413309 39.3733238 52.6932431 70.7932433 95.0000000
result:
ok 10 numbers
Test #49:
score: 0
Accepted
time: 0ms
memory: 2140kb
input:
0.95 0.57 10 2 94
output:
2.0000000 9.2272842 9.9059200 14.6701759 19.5830415 26.9658897 36.7799289 50.3114896 68.7604746 94.0000000
result:
ok 10 numbers
Test #50:
score: 0
Accepted
time: 0ms
memory: 2172kb
input:
0.98 0.90 10 21 99
output:
21.0000000 -8.2131935 10.8510704 3.2421748 12.9432947 15.6023862 26.9393037 40.4426651 63.8791851 99.0000000
result:
ok 10 numbers
Extra Test:
score: 0
Extra Test Passed