結果
| 問題 | No.492 IOI数列 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-10-17 16:07:52 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 1,000 ms | 
| コード長 | 2,851 bytes | 
| コンパイル時間 | 11,392 ms | 
| コンパイル使用メモリ | 404,064 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-17 21:58:09 | 
| 合計ジャッジ時間 | 12,496 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}
#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}
fn solve(n: u64, m: u64) -> u64 {
    let b = (1..).find(|&i| n >> i == 0).unwrap();
    let mut a = 0;
    let mut i100 = 1;
    for i in 1..b + 1 {
        if n >> (b - i) & 1 == 1 {
            // succ
            a = (a * 100 + 1) % m;
            i100 = i100 * 100 % m;
        }
        // double
        if i != b {
            a = (a * i100 + a) % m;
            i100 = i100 * i100 % m;
        }
    }
    a
}
fn main() {
    let n: u64 = util::get::<u64>();
    println!("{}", solve(n, 1000000007));
    let m = n % 11;
    if m == 0 {
        println!("0");
    } else {
        println!(
            "{}",
            vec!["1"]
                .into_iter()
                .chain((1..m).map(|_| "01"))
                .collect::<Vec<_>>()
                .join("")
        );
    }
}
            
            
            
        