結果
| 問題 |
No.1168 Digit Sum Sequence
|
| コンテスト | |
| ユーザー |
Konton7
|
| 提出日時 | 2020-08-17 21:42:49 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 788 bytes |
| コンパイル時間 | 13,049 ms |
| コンパイル使用メモリ | 383,716 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 11:18:04 |
| 合計ジャッジ時間 | 14,260 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 |
ソースコード
use std::fs::File;
use std::io::Read;
// use std::cmp;
fn digitsum(mut a: i32) -> i32 {
let mut b = 0;
loop{
b += a % 10;
a /= 10;
if a == 0{
break;
}
}
return b;
}
fn main() {
let inputstatus = 10;
let mut buf = String::new();
let filename = "inputrust.txt";
if inputstatus == 0 {
let mut f = File::open(filename).expect("file not found");
f.read_to_string(&mut buf)
.expect("something went wrong reading the file");
} else {
std::io::stdin().read_to_string(&mut buf).unwrap();
}
let mut iter = buf.split_whitespace();
let mut n: i32 = iter.next().unwrap().parse().unwrap();
for _ in 0..10 {
n = digitsum(n);
}
println!("{}", n);
}
Konton7