Skip to content

Instantly share code, notes, and snippets.

View tokugh's full-sized avatar

tokugh

View GitHub Profile
@tokugh
tokugh / subset_convolution.jl
Last active January 8, 2025 11:39
subset_convolution
# https://judge.yosupo.jp/problem/subset_convolution
# O(N^2_2^N)
using OffsetArrays: Origin
const N::Int = 998244353
xy = (z=x+y;ifelse(z<N,z,z-N))
xy = (z=x-y;ifelse(z<0,z+N,z))
xy = mod(x*y,N)
@tokugh
tokugh / index(auto).md
Last active October 2, 2024 07:31
Ollama API wrapper module for Julia

ollama_api モジュールドキュメンテーション

注意:このドキュメンテーションは生成AIによる自動生成です。 MacBookPro 13-inch, M1, 2020でのみ動作を確認しています。

概要

ollama_apiは、Julia用のOllama APIラッパーモジュールです。このモジュールは、Ollama APIとの通信を簡素化し、テキスト生成や会話型AIの機能を提供します。

主要な機能

use std::collections::BTreeMap;
use proconio::input;
const MOD: i64 = 1_000_000_007;
fn main() {
// #1 入力
input!{
n: usize,
k: usize,
@tokugh
tokugh / q086.rs
Last active July 8, 2021 02:45
競プロ典型90問 ソースコード共有
// https://atcoder.jp/contests/typical90/submissions/24040491
use proconio::{input, marker::Usize1};
const MOD: i64 = 1_000_000_007;
fn main() {
input!{
n: usize,
q: usize,
xyzw: [(Usize1, Usize1, Usize1, u64); q],
fn main() {
proconio::input! {
_n: usize,
s: String,
}
let mut cnt: i64 = 0;
for (i, c) in s.chars().enumerate() {
match c {
'c' => {cnt += 2 << i;},
'b' => {cnt += 1 << i;},
use num_integer::{Integer, Roots};
fn main() {
proconio::input!{abc: i64};
let mut cnt = 0;
for a in 1..=abc.cbrt() {
if !abc.is_multiple_of(&a) { continue; }
let bc = abc / a;
for b in a..=bc.sqrt() {
if !bc.is_multiple_of(&b) { continue; }
// 位置は0-indexedで表わす。
// rを固定し、文字列(0,r)の中で'ox'あるいは'xo'が現れる最も右側の位置('ox'なら'x'の位置)をmとすると、
// oとxを両方含む文字列は、(l,r) = (0,r), (1,r), .., (m-1,r)のm通り。
// これをr=0, .., n-1について順次加算する。
fn main() {
proconio::input!{ _n: usize, s: String };
let mut prev_c = 0;
let mut m = 0;
let mut ans = 0;
for (r, c) in s.bytes().enumerate() {
const MOD: i128 = 1_000_000_007;
fn main() {
proconio::input!{ l: i128, r: i128, };
let mut ans = 0;
for i in 0..=18 {
let min = 10i128.pow(i).max(l);
let max = (10i128.pow(i + 1) - 1).min(r);
if min <= max {
ans += (i as i128 + 1) * (min + max) * (max - min + 1) / 2;
@tokugh
tokugh / q059.rs
Last active July 2, 2021 14:11
競プロ典型90問 ソースコード共有
use fixedbitset::FixedBitSet;
use proconio::{input, fastout, marker::Usize1, };
#[fastout]
fn main() {
input! {
n: usize, m: usize, q: usize,
xy: [(Usize1, Usize1); m],
ab: [(Usize1, Usize1); q],
};
use proconio::{input, fastout, marker::Chars} ;
#[fastout]
fn main() {
input! {
n: usize,
s: Chars,
t: Chars,
};
let s: Vec<_> = s.into_iter().map(|x| match x {'R'=>0,'G'=>1,'B'=>2,_=>3}).collect();