#![allow(unused_parens)] #![allow(unused_imports)] #![allow(non_upper_case_globals)] #![allow(non_snake_case)] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(dead_code)] type Vec2 = Vec>; type Vec3 = Vec>>; #[allow(unused_macros)] macro_rules! invec { ( $ t : ty ) => {{ let mut s = String::new(); match std::io::stdin().read_line(&mut s) { Ok(0) => Vec::<$t>::new(), Ok(n) => s .trim() .split_whitespace() .map(|s| s.parse::<$t>().unwrap()) .collect::>(), Err(_) => Vec::<$t>::new(), } }}; } #[allow(unused_macros)] macro_rules! get { ($t:ty) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse::<$t>().unwrap() } }; ($($t:ty),*) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( $(iter.next().unwrap().parse::<$t>().unwrap(),)* ) } }; ($t:ty; $n:expr) => { (0..$n).map(|_| get!($t) ).collect::>() }; ($($t:ty),*; $n:expr) => { (0..$n).map(|_| get!($($t),*) ).collect::>() }; ($t:ty ;;) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::>() } }; ($t:ty ;; $n:expr) => { (0..$n).map(|_| get!($t ;;)).collect::>() }; } #[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let mut 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_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)*} }; ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } #[allow(unused_macros)] 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::>() }; ($next:expr, [$t:tt]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::>() } }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } #[allow(unused_macros)] #[cfg(debug_assertions)] macro_rules! mydbg { //($arg:expr) => (dbg!($arg)) //($arg:expr) => (println!("{:?}",$arg)); ($($a:expr),*) => { eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*); } } #[cfg(not(debug_assertions))] macro_rules! mydbg { ($($arg:expr),*) => {}; } macro_rules! echo { ($($a:expr),*) => { $(println!("{}",$a))* } } use std::cmp::*; use std::collections::*; use std::ops::{Add, Div, Mul, Rem, Sub}; trait SafeRangeContain { fn safe_contains(&self, x: i64) -> bool; } impl SafeRangeContain for std::ops::Range { fn safe_contains(&self, x: i64) -> bool { if x < 0 { return false; } return self.contains(&(x as usize)); } } #[allow(dead_code)] static INF_I64: i64 = i64::max_value() / 2; #[allow(dead_code)] static INF_I32: i32 = i32::max_value() / 2; #[allow(dead_code)] static INF_USIZE: usize = usize::max_value() / 2; #[allow(dead_code)] static M_O_D: usize = 1000000007; #[allow(dead_code)] static PAI: f64 = 3.1415926535897932; trait IteratorExt: Iterator { fn toVec(self) -> Vec; } impl IteratorExt for T { fn toVec(self) -> Vec { self.collect() } } trait CharExt { fn toNum(&self) -> usize; fn toAlphabetIndex(&self) -> usize; fn toNumIndex(&self) -> usize; } impl CharExt for char { fn toNum(&self) -> usize { return *self as usize; } fn toAlphabetIndex(&self) -> usize { return self.toNum() - 'a' as usize; } fn toNumIndex(&self) -> usize { return self.toNum() - '0' as usize; } } trait VectorExt { fn joinToString(&self, s: &str) -> String; } impl VectorExt for Vec { fn joinToString(&self, s: &str) -> String { return self .iter() .map(|x| x.to_string()) .collect::>() .join(s); } } trait StringExt { fn get_reverse(&self) -> String; } impl StringExt for String { fn get_reverse(&self) -> String { self.chars().rev().collect::() } } trait UsizeExt { fn pow(&self, n: usize) -> usize; } impl UsizeExt for usize { fn pow(&self, n: usize) -> usize { return ((*self as u64).pow(n as u32)) as usize; } } fn main() { solve(); } #[derive(Debug)] pub struct PrimeFactor { base: u64, exp: u64, } impl PrimeFactor { fn new(base: u64, exp: u64) -> PrimeFactor { PrimeFactor { base: base, exp: exp, } } } impl PartialEq for PrimeFactor { fn eq(&self, target: &Self) -> bool { self.base == target.base && self.exp == target.exp } } impl Eq for PrimeFactor {} fn factraize(n: u64) -> Vec { let mut tmp = n; let mut b = 1; let mut res = vec![]; let mut count = 0; loop { b += 1; if (b * b > n) { break; }; if (tmp % b == 0) { let mut e = 0; for i in 1.. { e = i; tmp = tmp / b; if (tmp % b != 0) { break; }; } res.push(PrimeFactor::new(b, e)); } } if (tmp != 1) { res.push(PrimeFactor::new(tmp, 1)); } return res; } struct Factraize { primes: Vec, } impl Factraize { fn new(M: u64) -> Self { let mut N = 0_usize; for i in 0_usize.. { if (i as u64 * i as u64) > M { N = i; break; } } let mut p = vec![false; N]; let mut p2 = vec![]; for i in 2..N { if !p[i] { p2.push(i as u64); for j in 1.. { if i * j < N { p[i * j] = true; } else { break; } } } } Factraize { primes: p2 } } fn calc(&self, a: u64) -> Vec { let mut ret = vec![]; let mut a = a; for i in 0..self.primes.len() { let p = self.primes[i]; let mut k = 0; while a >= p && a % p == 0 { k += 1; a /= p; } if k != 0 { ret.push(PrimeFactor::new(p, k)); } } if a != 1 { ret.push(PrimeFactor::new(a, 1)); } return ret; } } fn solve() { let mut ans: u64 = 0; let N = get!(u64); let a = factraize(N); for item in a { ans += item.base * item.exp; } echo!(ans); }