https://atcoder.jp/contests/math-and-algorithm/tasks/math_and_algorithm_bq
ですね。
// Simple Math Easy #![allow(non_snake_case)] //////////////////// library //////////////////// fn read<T: std::str::FromStr>() -> T { let mut line = String::new(); std::io::stdin().read_line(&mut line).ok(); line.trim().parse().ok().unwrap() } //////////////////// process //////////////////// fn f(N: u64) -> u64 { let D: u64 = 10u64.pow(9) + 7; let M = N * (N + 1) / 2 % D; M * M % D } fn main() { let N = read(); println!("{}", f(N)) }