Skip to content

Commit

Permalink
abc215 a, b, c, d, e
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Aug 21, 2021
1 parent a899048 commit ff3c39c
Show file tree
Hide file tree
Showing 11 changed files with 1,998 additions and 0 deletions.
161 changes: 161 additions & 0 deletions abc215/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions abc215/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "abc215"
version = "0.1.0"
authors = ["bouzuya <m@bouzuya.net>"]
edition = "2018"

# dependencies added to new project
[dependencies]
num = "=0.2.1"
proconio = { version = "=0.3.6", features = ["derive"] }
superslice = "=1.0.0"

[profile.release]
lto = true
panic = 'abort'
1 change: 1 addition & 0 deletions abc215/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.42.0
9 changes: 9 additions & 0 deletions abc215/src/bin/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use proconio::input;

fn main() {
input! {
s: String,
};
let ans = s == "Hello,World!";
println!("{}", if ans { "AC" } else { "WA" });
}
23 changes: 23 additions & 0 deletions abc215/src/bin/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::cmp;

use proconio::input;

fn main() {
input! {
n: usize,
};
let mut max = 0_usize;
for k in 0.. {
match 2_usize.checked_pow(k as u32) {
Some(x) => {
if x > n {
break;
}
}
None => break,
}
max = cmp::max(max, k);
}
let ans = max;
println!("{}", ans);
}
25 changes: 25 additions & 0 deletions abc215/src/bin/c.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::collections::BTreeSet;

use proconio::{input, marker::Chars};
use superslice::Ext;

fn main() {
input! {
s: Chars,
k: usize,
};
let n = s.len();
let mut is = (0..n).collect::<Vec<usize>>();
let mut set = BTreeSet::new();
loop {
let mut t = vec![];
for i in is.clone() {
t.push(s[i]);
}
set.insert(t.iter().collect::<String>());
if !is.next_permutation() {
break;
}
}
println!("{}", set.iter().nth(k - 1).unwrap());
}
62 changes: 62 additions & 0 deletions abc215/src/bin/d.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
use std::collections::HashSet;

use proconio::input;

fn f(n: usize) -> HashSet<usize> {
let mut p = HashSet::new();
if n < 2 {
return p;
}
let mut n = n; // shadowing
for i in 2.. {
if i * i > n {
break;
}
let mut c = 0;
while n % i == 0 {
c += 1;
n /= i;
}
if c > 0 {
p.insert(i);
}
}
if n != 1 {
p.insert(n);
}
p
}

fn main() {
input! {
n: usize,
m: usize,
a: [usize; n],
};
let mut set = HashSet::new();
for a_i in a.iter().copied() {
for k in f(a_i) {
set.insert(k);
}
}
let mut b = vec![true; m + 1];
for x in 1..=m {
if b[x] && set.contains(&x) {
b[x] = false;
for j in (x + x..=m).step_by(x) {
b[j] = false;
}
}
}
let mut ans = vec![];
for x in 1..=m {
if b[x] {
ans.push(x);
}
}

println!("{}", ans.len());
for x in ans {
println!("{}", x);
}
}
Loading

0 comments on commit ff3c39c

Please sign in to comment.