Skip to content

Instantly share code, notes, and snippets.

@catupper
catupper / Treap.cpp
Last active March 21, 2023 14:05
Solve AOJ 1508 with Treap
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int INF = 1 << 30;
struct Node{
Node *left, *right, *parent;
def gcd(a, b):
if a == 0:return b
else:return gcd(b % a, a)
#returns (x, y, gcd(a,b)) s.t. ax + by = gcd(a,b)
def ext_gcd(a, b):
if a == 0:return (0, 1, b)
else:
(X, Y, g) = ext_gcd(b % a, a)
return (Y-b//a*X, X, g)
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long Int;
Int MOD = 998244353;
// a ^ b % MOD
int[][] open_field = new int[4][4];
int[][] tmp_field = new int[4][4];
int[] direction_x = {0, 1, 0, -1};
int[] direction_y = {1, 0, -1, 0};
int[] prob = {0, 9, 1};
boolean AI_play = false;
int[][] num_color = {
{0, 0, 0},
{238, 228, 218},
{237, 224,200},
7 13
2 4
0 2
1 5
0 3
0 1
2 3
1 3
4 6
0 5
int main(){
int a = 0, c = 2;
auto b = &a;
int c = 3;
a *=/ b;
a /*= c;
a =-+ c;
b =*/ 1;
b -=+ c;
c =/* a;
#include<iostream>
#include<vector>
using namespace std;
//1
#define view_vector1(vec) for(auto v:vec)cout << vec << " ";cout << endl;
//2
#include<iostream>
using namespace std;
int a[108000];
int partition(int l, int r){
int tmp;//入れ替え用の変数
while(1){
//1. rを左に動かす
100000
41 18467 6334 26500 19169 15724 11478 29358 26962 24464 5705 28145 23281 16827 9961 491 2995 11942 4827 5436 32391 14604 3902 153 292 12382 17421 18716 19718 19895 5447 21726 14771 11538 1869 19912 25667 26299 17035 9894 28703 23811 31322 30333 17673 4664 15141 7711 28253 6868 25547 27644 32662 32757 20037 12859 8723 9741 27529 778 12316 3035 22190 1842 288 30106 9040 8942 19264 22648 27446 23805 15890 6729 24370 15350 15006 31101 24393 3548 19629 12623 24084 19954 18756 11840 4966 7376 13931 26308 16944 32439 24626 11323 5537 21538 16118 2082 22929 16541 4833 31115 4639 29658 22704 9930 13977 2306 31673 22386 5021 28745 26924 19072 6270 5829 26777 15573 5097 16512 23986 13290 9161 18636 22355 24767 23655 15574 4031 12052 27350 1150 16941 21724 13966 3430 31107 30191 18007 11337 15457 12287 27753 10383 14945 8909 32209 9758 24221 18588 6422 24946 27506 13030 16413 29168 900 32591 18762 1655 17410 6359 27624 20537 21548 6483 27595 4041 3602 24350 10291 30836 9374 11020 4596 24021 27348 23199 19668 24484
@catupper
catupper / 数え上げN本ノック.md
Last active May 10, 2021 10:23
数え上げN本ノック

特に注意がない場合はM=1,000,000,007でMODを取ってください。 TLEは2sec

注意

答えはありません. ときどき筆者も解けるかどうかわかっていない問題があります.

Episode 0 基礎

Mは素数とは限らないことに注意せよ.

  • 0.1 aのb乗mod Mをもとめよ(a,b< 10^18, M < 10^9)