diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-11-14 12:16:09 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-11-14 12:16:09 +0200 |
| commit | 65cbc4732866264a930f30d948f7258f6dde7497 (patch) | |
| tree | e62ea126c61eec51e3496285f7621d90ad951c6f /codeforces/BanBan/rust-solution/src/main.rs | |
| parent | 95422138588572e08a1ee78e654741874f11cfa0 (diff) | |
| download | competitive-programming-65cbc4732866264a930f30d948f7258f6dde7497.tar.xz competitive-programming-65cbc4732866264a930f30d948f7258f6dde7497.zip | |
Added new problems
Diffstat (limited to 'codeforces/BanBan/rust-solution/src/main.rs')
| -rw-r--r-- | codeforces/BanBan/rust-solution/src/main.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/codeforces/BanBan/rust-solution/src/main.rs b/codeforces/BanBan/rust-solution/src/main.rs new file mode 100644 index 0000000..e1c0c5c --- /dev/null +++ b/codeforces/BanBan/rust-solution/src/main.rs @@ -0,0 +1,31 @@ +fn readi64(input : &mut dyn Iterator<Item = String>) -> i64 { + input.next().unwrap().parse::<i64>().unwrap() +} + + + +fn main() { + let mut lines = std::io::stdin().lines().map(|line| line.unwrap()); + let tt = readi64(&mut lines); + for _ in 0..tt { + let n = readi64(&mut lines); + if n == 1 { + println!("{n}\n1 2\n"); + } else { + println!("{}", n - 1); + let mut v = Vec::with_capacity(n as usize); + let mut cnt = 0; + let mut i = 0; + while cnt != n - 1 && i < n { + if (3 * n - 1 - i) % 3 != 0 { + v[i as usize] = 3 * n - 1 - i; + cnt +=1; + } + i += 1; + } + for x in &v { + println!("{} {}", i * 3 + 1, x); + } + } + } +} |
