This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#See also: ABC084 D - 2017-like Number | |
require "set" | |
n = gets.to_i | |
require "prime" | |
n_is_prime= false | |
n21_is_prime = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
2020のように、ある文字列の2回以上の繰り返しとして表せる自然数を「2020に似た数」と呼ぶことにします。 | |
Q個のクエリA_iとB_iが入力されたとき、A_iからB_iまでに2020に似た数が何個含まれるか求めなさい。 | |
制約 | |
1≦Q≦1e+5 | |
1≦A_i≦B_i≦1e+5 | |
入力 | |
Q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 提出: https://atcoder.jp/contests/typical90/submissions/23159483 | |
# 入力 | |
N, M = gets.split.map(&:to_i) | |
A = Array.new(N) { gets; gets.split.map(&:to_i) } | |
S = gets.split.map(&:to_i) | |
# 行ベクトルの配列 | |
xs = A.map { |indices| | |
x = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function *main() { | |
const Q = +(yield); | |
const head = [], tail = []; | |
for (let i = 0; i < Q; i++) { | |
const [t, x] = (yield).split(" ").map(Number); | |
if (t == 1) { | |
head.push(x); | |
} else if (t == 2) { | |
tail.push(x); | |
} else if (t == 3) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let tree = RBST::new(); | |
} | |
//https://tjkendev.github.io/procon-library/python/binary_search_tree/RBST.html | |
pub mod rbst { | |
use std::cmp::{Ordering::*, *}; | |
pub struct RBST<K> { | |
root: Node<K>, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name AtCoder Standings Watcher | |
// @namespace https://atcoder.jp/ | |
// @version 0.2.7 | |
// @description Watch standings and notifies | |
// @author magurofly | |
// @match https://atcoder.jp/contests/* | |
// @icon https://www.google.com/s2/favicons?domain=atcoder.jp | |
// @grant GM_notification | |
// @grant unsafeWindow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(non_snake_case, dead_code)] | |
#[fastout] | |
fn main() { | |
input! { | |
N: usize, mut W: Weight, | |
mut X: [(Value, Weight, Count); N], | |
} | |
let mut Y = vec![vec![]; 20]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N, K, M = gets.split.map(&:to_i) | |
sum = 0 | |
(1 .. M - 1).each do |i| | |
count = (N - i) / M | |
sum += count * i.pow(K, M) | |
sum %= M | |
end | |
puts sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N, K, M = gets.split.map(&:to_i) | |
sum = 0 | |
(1 .. N).each do |i| | |
sum += i.pow(K, M) | |
sum %= M | |
end | |
puts sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#include <atcoder/segtree> | |
using namespace atcoder; | |
#define rep(i, l, r) for (auto i = (l); i < (r); i++) | |
#define all(a) a.begin(), a.end() | |
#define chmin(dest, src) if ((dest) > (src)) dest = (src) | |
#define chmax(dest, src) if ((dest) < (src)) dest = (src) | |
using ll = int; |
OlderNewer