結果
| 問題 |
No.1423 Triangle of Multiples
|
| コンテスト | |
| ユーザー |
Moss_Local
|
| 提出日時 | 2021-03-12 22:37:16 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 150 ms / 2,000 ms |
| コード長 | 6,572 bytes |
| コンパイル時間 | 12,973 ms |
| コンパイル使用メモリ | 377,780 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 13:10:46 |
| 合計ジャッジ時間 | 14,197 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
コンパイルメッセージ
warning: unused variable: `j`
--> src/main.rs:226:13
|
226 | for j in 0..i.1 {
| ^ help: if this is intentional, prefix it with an underscore: `_j`
|
= note: `#[warn(unused_variables)]` on by default
warning: variable does not need to be mutable
--> src/main.rs:237:9
|
237 | let mut vec: Vec<usize> = read_vec();
| ----^^^
| |
| help: remove this `mut`
|
= note: `#[warn(unused_mut)]` on by default
warning: variable does not need to be mutable
--> src/main.rs:238:9
|
238 | let mut l = vector_lcm(&vec);
| ----^
| |
| help: remove this `mut`
warning: unused variable: `i`
--> src/main.rs:244:9
|
244 | for i in 0..n {
| ^ help: if this is intentional, prefix it with an underscore: `_i`
ソースコード
// -*- coding:utf-8-unix -*-
// #![feature(map_first_last)]
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::collections::*;
use std::convert::*;
use std::convert::{From, Into};
use std::fmt::Debug;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::marker::Copy;
use std::mem::*;
use std::ops::Bound::*;
use std::ops::{Add, Mul, Neg, Sub};
use std::str;
use std::vec;
use std::{cmp, process::Output};
use std::{cmp::Ordering, env::consts::DLL_PREFIX};
use std::{cmp::Ordering::*, f32::consts::PI};
const INF: i64 = 1223372036854775807;
const UINF: usize = INF as usize;
const FINF: f64 = 122337203685.0;
const INF128: i128 = 1223372036854775807000000000000;
const LINF: i64 = 2147483647;
// const MOD: i64 = 1000000007;
const MOD: i64 = 998244353;
const UMOD: usize = MOD as usize;
use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
macro_rules! p {
($x:expr) => {
println!("{}", $x);
};
}
macro_rules! d {
($x:expr) => {
dbg!($x);
};
}
// use str::Chars;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
// #[allow(dead_code)]
// fn readi() -> (i64) {
// let mut str = String::new();
// let _ = stdin().read_line(&mut str).unwrap();
// let mut iter = str.split_whitespace();
// iter.next().unwrap().parse::<i64>().unwrap()
// }
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
(0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn readii() -> (i64, i64) {
let mut str = String::new();
let _ = stdin().read_line(&mut str).unwrap();
let mut iter = str.split_whitespace();
(
iter.next().unwrap().parse::<i64>().unwrap(),
iter.next().unwrap().parse::<i64>().unwrap(),
)
}
fn readff() -> (f64, f64) {
let mut str = String::new();
let _ = stdin().read_line(&mut str).unwrap();
let mut iter = str.split_whitespace();
(
iter.next().unwrap().parse::<f64>().unwrap(),
iter.next().unwrap().parse::<f64>().unwrap(),
)
}
#[allow(dead_code)]
fn readiii() -> (i64, i64, i64) {
let mut str = String::new();
let _ = stdin().read_line(&mut str).unwrap();
let mut iter = str.split_whitespace();
(
iter.next().unwrap().parse::<i64>().unwrap(),
iter.next().unwrap().parse::<i64>().unwrap(),
iter.next().unwrap().parse::<i64>().unwrap(),
)
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
let mut str = String::new();
let _ = stdin().read_line(&mut str).unwrap();
let mut iter = str.split_whitespace();
(
iter.next().unwrap().parse::<usize>().unwrap(),
iter.next().unwrap().parse::<usize>().unwrap(),
)
}
fn readcc() -> (char, char) {
let mut str = String::new();
let _ = stdin().read_line(&mut str).unwrap();
let mut iter = str.split_whitespace();
(
iter.next().unwrap().parse::<char>().unwrap(),
iter.next().unwrap().parse::<char>().unwrap(),
)
}
#[allow(dead_code)]
fn readuuu() -> (usize, usize, usize) {
let mut str = String::new();
let _ = stdin().read_line(&mut str).unwrap();
let mut iter = str.split_whitespace();
(
iter.next().unwrap().parse::<usize>().unwrap(),
iter.next().unwrap().parse::<usize>().unwrap(),
iter.next().unwrap().parse::<usize>().unwrap(),
)
}
#[allow(dead_code)]
fn readuuuu() -> (usize, usize, usize, usize) {
let mut str = String::new();
let _ = stdin().read_line(&mut str).unwrap();
let mut iter = str.split_whitespace();
(
iter.next().unwrap().parse::<usize>().unwrap(),
iter.next().unwrap().parse::<usize>().unwrap(),
iter.next().unwrap().parse::<usize>().unwrap(),
iter.next().unwrap().parse::<usize>().unwrap(),
)
}
fn readiiii() -> (i64, i64, i64, i64) {
let mut str = String::new();
let _ = stdin().read_line(&mut str).unwrap();
let mut iter = str.split_whitespace();
(
iter.next().unwrap().parse::<i64>().unwrap(),
iter.next().unwrap().parse::<i64>().unwrap(),
iter.next().unwrap().parse::<i64>().unwrap(),
iter.next().unwrap().parse::<i64>().unwrap(),
)
}
fn readin() -> (String, String) {
let mut str = String::new();
let _ = stdin().read_line(&mut str).unwrap();
let mut iter = str.split_whitespace();
(
// iter.next().unwrap().parse::<usize>().unwrap(),
iter.next().unwrap().parse::<String>().unwrap(),
iter.next().unwrap().parse::<String>().unwrap(),
)
}
fn prime_factorization(x: usize) -> BTreeMap<usize, usize> {
let mut res: BTreeMap<usize, usize> = BTreeMap::new();
let mut xx = x;
let mut p: usize = 2;
while p * p <= xx {
while xx % p == 0 {
// println!("{:?}", p);
let t = res.get_mut(&p);
if t.is_none() {
res.insert(p, 1);
} else {
*t.unwrap() += 1;
}
xx /= p;
}
// println!("{:?} {:?}", p, res);
p += 1;
}
if xx != 1 {
let t = res.get_mut(&xx);
if t.is_none() {
res.insert(xx, 1);
} else {
*t.unwrap() += 1;
}
}
res
}
pub fn vector_lcm(vec: &Vec<usize>) -> usize {
let mut res = 1;
let mut alcm: BTreeMap<usize, usize> = BTreeMap::new();
for i in 0..vec.len() {
let pf = prime_factorization(vec[i]);
// println!("{:?}", vec[i]);
// println!("{:?}", pf);
for i in pf {
let t = alcm.get_mut(&i.0);
if t.is_none() {
alcm.insert(i.0, i.1);
} else {
let val = *t.unwrap();
*alcm.get_mut(&i.0).unwrap() = max(val, i.1);
}
}
}
for i in alcm {
for j in 0..i.1 {
res *= i.0;
}
// println!("{:?}", i);
}
res
}
fn solve_part() {
// let (a, b, c) = readuuu();
let mut vec: Vec<usize> = read_vec();
let mut l = vector_lcm(&vec);
println!("{:?} {:?} {:?}", l, l, l);
return;
}
fn solve() {
let n: usize = read();
for i in 0..n {
solve_part();
}
return;
}
fn main() {
solve()
}
Moss_Local