結果

問題 No.3331 Consecutive Cubic Sum
コンテスト
ユーザー EvbCFfp1XB
提出日時 2025-11-03 14:14:56
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WA  
実行時間 -
コード長 569 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,047 ms
コンパイル使用メモリ 188,632 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2026-07-16 07:27:13
合計ジャッジ時間 3,997 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 25 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use itertools::Itertools;
use proconio::input;

fn main() {
    input! {
        n: i64,
    }

    let i3 = (0..=1_000_000).map(|i| i * i * i).collect::<Vec<_>>();

    let mut res = vec![];
    let mut r = 1;
    let mut sum = 0;
    for l in 1..i3.len() {
        while sum < n {
            sum += i3[r];
            r += 1;
        }
        if sum == n {
            res.push((l, r - 1));
        }
        sum -= i3[l];
    }

    println!("{}", res.len());
    println!(
        "{}",
        res.iter().map(|(l, r)| format!("{} {}", l, r)).join("\n")
    );
}
0