题目地址
https://ac.nowcoder.com/acm/contest/57677/A
代码
use std::io::{self, BufRead, Write};
fn is_prime_trivial(n: i128) -> bool {
if n i128 {
let mut result = 1;
a %= m;
while b > 0 {
if b % 2 != 0 {
result = (result * a) % m;
}
b >>= 1;
a = (a * a) % m;
}
result
}
fn is_prime(n: i128) -> bool {
if n i128 {
if _n == 1 {
return 1;
} else if _n == 4 {
return 4;
} else {
let mut n = _n;
while !is_prime(n) {
n -= 1;
}
return n;
}
}
fn main() {
let stdin = io::stdin();
let mut lines = stdin.lock().lines();
let t: i32 = lines.next().unwrap().unwrap().trim().parse().unwrap();
let stdout = io::stdout();
let mut writer = io::BufWriter::new(stdout.lock());
for _ in 0..t {
let n: i128 = lines.next().unwrap().unwrap().trim().parse().unwrap();
// println!("n {}", is_prime(n));
let result = solve(n);
writeln!(&mut writer, "{}", result).unwrap();
}
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: MySQL—多表联合查询(下)(内连接查询、外连接查询、子查询(ALL/ANY/SOME/IN/EXISTS关键字)、自关联查询)
1. 内连接查询 数据准备: use mydb3; — 创建部门表 create table if not exists dept3( deptno varchar(20) primary key , — 部门号 name varchar(20) — 部…