Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
json
Languages:
English
Size:
< 1K
ArXiv:
Tags:
competitive-programming
code-generation
specification-generation
proof-generation
verification
rust
License:
Download leetcode/lc1411/code_spec.rs from Gax-c/VeriContest_Lite: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/datasets/Gax-c/VeriContest_Lite/resolve/main/leetcode/lc1411/code_spec.rs
- Command line
-
hf download hf://datasets/Gax-c/VeriContest_Lite/leetcode/lc1411/code_spec.rs
-
curl -L -o code_spec.rs https://huggingface.co/datasets/Gax-c/VeriContest_Lite/resolve/main/leetcode/lc1411/code_spec.rs
1.2 kB
| use vstd::prelude::*; | |
| fn main() {} | |
| verus! { | |
| pub struct Solution; | |
| impl Solution { | |
| pub open spec fn ways_mod(n: int, kind: int) -> int | |
| decreases n, | |
| { | |
| if n <= 0 { | |
| 0 | |
| } else if n == 1 { | |
| 6 | |
| } else if kind == 0 { | |
| (3 * Self::ways_mod(n - 1, 0) + 2 * Self::ways_mod(n - 1, 1)) % 1_000_000_007 | |
| } else { | |
| (2 * Self::ways_mod(n - 1, 0) + 2 * Self::ways_mod(n - 1, 1)) % 1_000_000_007 | |
| } | |
| } | |
| pub fn num_of_ways(n: i32) -> (res: i32) | |
| requires | |
| 1 <= n <= 5000, | |
| ensures | |
| 0 <= res, | |
| res as int == (Self::ways_mod(n as int, 0) + Self::ways_mod(n as int, 1)) % 1_000_000_007, | |
| { | |
| let modv: i64 = 1_000_000_007; | |
| let mut a121: i64 = 6; | |
| let mut a123: i64 = 6; | |
| let mut i: i32 = 1; | |
| while i < n { | |
| let new_a121 = (3 * a121 + 2 * a123) % modv; | |
| let new_a123 = (2 * a121 + 2 * a123) % modv; | |
| a121 = new_a121; | |
| a123 = new_a123; | |
| i = i + 1; | |
| } | |
| ((a121 + a123) % modv) as i32 | |
| } | |
| } | |
| } |