text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); long long ans = 0; for (int i = ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf( %d , &x); } void _R(int64_t &x) { scanf( %lld , &x); } void _R(double &x) { scanf( %lf , &x); } void _R(char &x) { scanf( %c , &x); } void _R(char *x) { scanf( %s , x); } void R...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n, k; vector<pair<int, int> > g[maxn]; int d[maxn], par[maxn]; void dfs1(int u, int fa) { par[u] = fa; for (auto p : g[u]) { int v = p.first; if (v == fa) continue; d[v] = d[u] + p.second; dfs1(v, u);...
// *************************************************************************** // *************************************************************************** // Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved. // // In this HDL repository, there are many different and unique modules, consisting // of...
#include <bits/stdc++.h> using namespace std; const int mo = 998244353; const double PI = acos(-1.0); template <typename _T> _T Fabs(_T x) { return x < 0 ? -x : x; } template <typename _T> void read(_T &x) { _T f = 1; x = 0; char s = getchar(); while (s > 9 || s < 0 ) { if (...
#include <bits/stdc++.h> using namespace std; map<string, string> m; map<string, int> used; string f(string x) { used[x] = 1; if (m[x] == x) return x; return f(m[x]); } int main() { int count = 0; vector<string> tab; int n; cin >> n; for (int i = 0; i < n; i++) { string...
#include <bits/stdc++.h> using namespace std; const int N = 3e4; int n, aa[N + 2], fib[N + 2], con[N + 2], m; void compress() { vector<int> v; for (int i = 1; i <= n; i++) v.push_back(aa[i]); sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); map<int, int> mp; for (i...
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, co, i, j, k, l, m, n; cin >> n; co = 0; set<long long int> myset; for (i = 0; i < n; i++) { cin >> a; myset.insert(a); } if (myset.size() > 3) cout << NO n ; else if (myset.size() == ...
#include <bits/stdc++.h> using namespace std; int a[100005], b[100005]; int main() { int i, j, n, p, k; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &a[i]); b[i] = a[i]; } sort(b + 1, b + 1 + n); for (i = 1; i <= n; i++) { if (b[i] != a[i]) break; } p =...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 08:48:40 04/14/2015 // Design Name: // Module Name: clockdivide2 // Project Name: // Target Devices: // Tool versions: // Description: // // De...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: pcx_buf_pdl_odd.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it a...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2017 by Matt Myers. `define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); $stop; end while(0); ...
#include <bits/stdc++.h> using namespace std; int main() { int n, x = 0, y = 0; string a, b; cin >> a >> b; if (a.size() > b.size()) { n = a.size(); } else { n = b.size(); } for (int i = 0; i < n; i++) { if (b[x] == a[y]) { x++; y++; } else { ...
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { if (a < b) { swap(a, b); } T t; while (b > 0) { t = a % b; a = b; b = t; } return a; } template <class T> T gcdL(vector<T>& v) { int l = v.size(); if (l == 1) return v[0...
#include <bits/stdc++.h> using namespace std; int T, n, head[300005], cnt, in[300005], ans, rt; struct edge { int to, nxt; } e[300005 << 1]; void add(int u, int v) { e[++cnt] = (edge){v, head[u]}; head[u] = cnt; } void dfs(int u, int fa, int tot) { if (tot > ans) ans = tot, rt = u; for...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 28.06.2017 17:24:09 // Design Name: // Module Name: ctrlunit // Project Name: // Target Devices: // Tool Versions: // Description: Based off the code provided by the...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Tue Jun 06 02:45:50 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int, int>; const int mxn = 2e5; int n; string ar[mxn]; void solve() { cin >> n; for (int i = 0; i < n; ++i) cin >> ar[i]; set<string> second; for (int i = n - 1; i >= 0; --i) { ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
//***************************************************************************** // DISCLAIMER OF LIABILITY // // This file contains proprietary and confidential information of // Xilinx, Inc. ("Xilinx"), that is distributed under a license // from Xilinx, and may be used, copied and/or disclosed only // pursuant to the...
#include <bits/stdc++.h> using namespace std; int n, m, q; int par[26][100005], depth[100005]; vector<int> st[400005]; vector<int> G[100005]; vector<int> SS[26][100005]; int cnt, chaincnt; void get10(vector<int> &res, const vector<int> &fir, const vector<int> sec) { int c1 = 0, c2 = 0; res = vec...
#include <bits/stdc++.h> using namespace std; const int max_n = 1e5 + 10; vector<long long> adj[max_n]; long long par[max_n], st[max_n], p[max_n], ft[max_n], doc[max_n], x[max_n], l[max_n], r[max_n], cnt, tmp, k, n, m; bool mark[max_n]; int get_par(int u) { return par[u] == u ? u : par[u] = get_par(pa...
module butterfly_32( enable, i_0, i_1, i_2, i_3, i_4, i_5, i_6, i_7, i_8, i_9, i_10, i_11, i_12, ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; void B(); int main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); B(); } class segmen { public: long long x1, y1, x2, y2; segmen(long long xx1, long long yy1, long long xx2, long long yy2) : x1{xx1}, x2{xx2}, y1{yy1}, y2{y...
module fetch_tb(); reg dispatch2cu_wf_dispatch; reg [14:0]dispatch2cu_wf_tag_dispatch; reg [31:0]dispatch2cu_start_pc_dispatch; reg [9:0]dispatch2cu_vgpr_base_dispatch; reg [8:0]dispatch2cu_sgpr_base_dispatch; reg [15:0]dispatch2cu_lds_base_dispatch; reg [5:0]dispatch2cu_wf_size_disp...
#include <bits/stdc++.h> using namespace std; const int N = 1e5, INF = 1e9; int a[N], n, x, y, res = 0; int main() { int t; ios::sync_with_stdio(false); cin >> t; while (t--) { cin >> n >> x >> y; int res = INF; int rs = 0, rc = 0; for (int i = 1; i <= x; i++) { f...
#include <bits/stdc++.h> using namespace std; int fa[1010]; int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); } int main() { int n, m; scanf( %d%d , &n, &m); if (m != n - 1) { printf( no n ); return 0; } for (int i = 1; i <= n; i++) fa[i] = i; for (int i = 1; i <...
#include <bits/stdc++.h> using namespace std; long long a[200001], b[200001]; int n; int main(void) { int t; cin >> t; while (t--) { cin >> n; long long sum = 0LL; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; ...
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } const long long MOD = 1000000007; long long inv[1...
//############################################################################# //# Function: Parametrized asynchronous clock FIFO # //############################################################################# //# Author: Andreas Olofsson # ...
module hrfp_add #(parameter PIPELINESTAGES=5) (input wire clk, input wire [`MSBBIT:0] op3_a, op3_b, input wire [30:0] mantissa_3_align0, mantissa_3_align1, input wire expdiff_msb_3, output reg [`MSBBIT:0] result_4, output reg [30:0] mantissa_4, output reg [7:0] zeroesmask_4); reg [`MS...
`include "setseed.vh" `define N 500 module top(input clk, stb, di, output do); localparam integer DIN_N = 6; localparam integer DOUT_N = `N; reg [DIN_N-1:0] din; wire [DOUT_N-1:0] dout; reg [DIN_N-1:0] din_shr; reg [DOUT_N-1:0] dout_shr; always @(posedge clk) begin din_shr <= {din_shr, di}; dout_shr <= ...
#include <bits/stdc++.h> using namespace std; char s[10000]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> s; bool t = 0; for (int i = 1; s[i]; ++i) { if (!isdigit(s[i]) && isdigit(s[i - 1])) { t = 1; break; } } if...
/********************************************/ /* generic_input.v */ /* A generic implementation of inputs */ /* (buttons, switches) */ /* */ /* 2012, */ /********************************************/ module ge...
#include <bits/stdc++.h> using namespace std; long long Min(long long a, long long b) { return a < b ? a : b; } inline int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (f == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = (x ...
///////////////////////////////////////////////////////////// // Created by: Synopsys DC Expert(TM) in wire load mode // Version : K-2015.06-SP1 // Date : Tue Mar 1 00:49:30 2016 ///////////////////////////////////////////////////////////// module flex_stp_sr_NUM_BITS8_SHIFT_MSB0 ( clk, n_rst, shift_enable, s...
//==================================================================== // test_bsg.v // 11/15/2016, //==================================================================== // `define RANDOM_TEST 1 `ifdef RANDOM_TEST `define NUM 100000 `else `define NUM 4 `endif `define WIDTH 32 `define SIGN `define ...
/* Copyright (c) 2015 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,...
#include <bits/stdc++.h> using namespace std; bool areParanthesisBalanced(string expr) { stack<char> s; char x; for (int i = 0; i < expr.length(); i++) { if (expr[i] == ( || expr[i] == [ || expr[i] == { ) { s.push(expr[i]); continue; } if (s.empty()) return false; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long l; typedef pair<int, int> pint; typedef vector<pint> vpint; typedef vector<int> vint; typedef vector<vint> vvint; int n, m, x[123457], cum[1234567]; int ans; map<int, int> mp; int main() { cin >> n; for (int i...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; long long a[100000], lim, n, flag; void DFS(long long x, long long y) { if (x > n) { if (y == a[lim]) flag = 1; return; } if (flag) return; DFS(x + 1, y); if (x != lim) { DFS(x + 1, y + a[x]); DFS(x + 1, y - a[x]); } }...
#include <bits/stdc++.h> using namespace std; const long long INF = 99999999; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; if (n == 1) { cout << 1; return 0; } vector<int> a(n); ; for (int i = 0; i < (n); ++i) cin >> a[i]; ; vector...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int a[12][12]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf( %d , &a[i][j]); for (int k = 1; k <= n; k++) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { ...
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7; int add(int a, int b) { if ((a += b) >= P) a -= P; return a < 0 ? a + P : a; } int mul(int a, int b) { return 1ll * a * b % P; } int kpow(int a, int b) { int r = 1; for (; b; b >>= 1, a = mul(a, a)) { if (b & 1) r = m...
//***************************************************************************** // (c) Copyright 2008-2010 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // ...
#include <bits/stdc++.h> using namespace std; vector<pair<pair<int, int>, int> > v; int a[(int)(1e5 + 50)]; string s; void solve() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { int x; scanf( %d , &x); s += (char)(x + 0 ); } for (int i = 0; i < s.size();) { ...
//----------------------------------------------------------------------------- // // (c) Copyright 2010-2011 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property ...
#include <bits/stdc++.h> using namespace std; long long quickMod(long long a, long long b, long long c) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % c; b >>= 1; a = a * a % c; } return ans; } long long Euler(long long x) { long long res = x; for (long lon...
/// date:2016/3/9 /// engineer: ZhaiShaoMin module dc_rep_upload(//input clk, rst, dc_flits_rep, v_dc_flits_rep, flits_max, en_flits_max, ...
/*------------------------------------------------------------------------------ * This code was generated by Spiral Multiplier Block Generator, www.spiral.net * Copyright (c) 2006, Carnegie Mellon University * All rights reserved. * The code is distributed under a BSD style license * (see http://www.opensource.or...
#include <bits/stdc++.h> struct point { double x, y, z; point() {} point(double _x, double _y, double _z) : x(_x), y(_y), z(_z) {} }; const double eps = 1e-8; double vlen(point p) { return sqrt(p.x * p.x + p.y * p.y + p.z * p.z); } point xmult(point u, point v) { point ret; ret.x = u.y * v...
`include "../../../rtl/verilog/gfx/gfx_triangle.v" `include "../../../rtl/verilog/gfx/div_uu.v" module triangle_bench(); parameter point_width = 16; parameter subpixel_width = 16; reg clk_i; reg rst_i; reg ack_i; wire ack_o; reg triangle_write_i; reg texture_enable_i; reg signed [point_width-1:-subpixel_width] de...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int u[5005][10005]; int n, m, a[5005], b[5005] = {1}, c[5005] = {1}, d[5005] = {1}, e[5005]; int expmod(int a, int b, int mod) { int res = 1; for (; b; b >>= 1) { if (b & 1) res = 1ll * res * a % mod; a = 1ll * a * a % ...
#include <bits/stdc++.h> using namespace std; struct elem { int i1, i2, p1, p2, tipo; elem() {} elem(int i1, int i2) : i1(i1), i2(i2) { tipo = 0; } elem(int i1, int i2, int p1, int p2) : i1(i1), i2(i2), p1(p1), p2(p2) { tipo = 1; } }; int inverso(int x) { if (x == 2) return 3; ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1e6 + 5; int n, q, m; const int N = 105; const int L = 1505; char s[maxn]; int tr[maxn][30], tot = 0; int fail[maxn], w[maxn]; vector<int> g[maxn]; void add(char *s, int id) { int u = 0; int n = strlen(...
/** * This is written by Zhiyang Ong * for EE577b Extra Credit Homework , Question 2 * * Behavioral model for the Hamming encoder */ module ham_15_11_encoder (input d[10:0],output c[14:0]); // Output signals representing the 15-bit encoded vector output reg [14:0] c; // Input signals representing the 15-bit...
/*There is no salvation without suffering*/ #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #include<iostream> #include<string> #include<algorithm> #include<numeric> #include<cmath> #include<vector> #include<iomanip> #include<map> #include<set> #include<stack> #include<queue> ...
// this test was yanked from another file and may require // a few syntax error fixes. // module test_mesh_to_ring_stitch #( parameter cycle_time_p = 20, localparam num_tiles_x_p = 8, localparam num_tiles_y_p = 8, parameter reset_cycles_lo_p=1, parameter reset_cycles_hi_p=5 ); import bsg_noc_pkg ::*;...
/* * Zet processor top level file * Copyright (c) 2008-2010 Zeus Gomez Marmolejo <> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; ei...
#include <bits/stdc++.h> using namespace std; const long long UNDEF = -1; const long long INF = 1e18; template <typename T> inline bool chkmax(T& aa, T bb) { return aa < bb ? aa = bb, true : false; } template <typename T> inline bool chkmin(T& aa, T bb) { return aa > bb ? aa = bb, true : false; ...
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); int qq = 1; cin >> qq; for (int qqq = 0; qqq < qq; qqq++) { int n, first, v; cin >> n >> first; int maxx = 0; int maxxd = 0; for (int i = 0; i < n; i++) { cin ...
#include <bits/stdc++.h> using namespace std; signed main() { long long n, x, y; cin >> n >> x >> y; long long arr[n]; for (long long i = 0; i < n; i++) { cin >> arr[i]; } long long an = -1; for (long long i = 0; i < n; i++) { bool ans = true; for (long long j = i - 1; ...
#include <bits/stdc++.h> using namespace std; char a[1001][1001]; int vis[1001][1001]; int n, m; void dfs(int x, int y) { vis[x][y] = 1; if (x - 1 >= 0 && !vis[x - 1][y] && a[x - 1][y] == # ) { dfs(x - 1, y); } if (x + 1 < n && !vis[x + 1][y] && a[x + 1][y] == # ) { dfs(x + 1, y)...
#include <bits/stdc++.h> using namespace std; int main() { int n, col, row; cin >> n; col = sqrt(n); while (1) { if (n % col == 0) { int a, b; a = n / col; b = col; if (a >= b) cout << b << << a << endl; else cout << a << << b...
// *************************************************************************** // *************************************************************************** // Copyright 2014(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; int n, m, a[N], b[N], t[N]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) scanf( %d%d , &a[i], &b[i]); int x = a[1], cnt = 0; for (int i = 1; i <= m; i++) if (a[i] == x || b[i] == x) cnt++; for (in...
#include <bits/stdc++.h> using namespace std; long long read() { long long x = 0, f = 0; char c = getchar(); while (!isdigit(c)) f |= c == - , c = getchar(); while (isdigit(c)) x = x * 10 + c - 0 , c = getchar(); return f ? -x : x; } inline int max(int a, int b, int c) { return max(a, max(...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,unroll-loops ) #pragma GCC target( avx,avx2,fma ) using namespace std; const long long mod1 = 998244353; const long long mod = 1e9 + 7; long long mod_mul(long long a, long long b) { a = a % mod; b = b % mod; return (((a * b) % mod) + mod) % mo...
#include <bits/stdc++.h> using namespace std; inline void Routine() { srand(time(NULL)); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } template <class T, class U> istream &operator>>(istream &in, pair<T, U> &p) { in >> p.fi >> p.se; return in; } template <class...
#include <bits/stdc++.h> using namespace std; long long MOD = 998244353; inline long long Msum(long long x) { return x; } template <typename... Rest> inline long long Msum(long long x, Rest... rest) { return (x + Msum(rest...)) % MOD; } inline long long Mprod(long long x) { return x; } template <typ...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.3 (lin64) Build Wed Oct 4 19:58:07 MDT 2017 // Date : Tue Oct 17 18:54:09 2017 // Host : TacitMonolith running 64-bit Ubuntu 16.04.3...
#include <bits/stdc++.h> using namespace std; int t, n, bt[1000001] = {}, ar[1000001] = {}; vector<int> v; int main() { ios ::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; i++) { cin >> ar[i]; ar[i] = i - ar[...
#include <bits/stdc++.h> using namespace std; int main() { string str, result = , tmp; map<string, int> array; cin >> str; for (long long i = 0; i < 10; i++) cin >> tmp, array[tmp] = i; tmp = ; for (long long i = 0; i < 80; i++) { tmp += str[i]; if ((i + 1) % 10 == 0) result ...
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <sys/types.h> #include <unistd.h> #include <unord...
////////////////////////////////////////////////////////////////////// //// //// //// CLK_DIV2.v //// //// //// //// This file is part of the Ether...
#include <bits/stdc++.h> using namespace std; int vis[400000], cur, path[500000], block[500000], x, y, n, m, q, k, s, t, seen[400010], ans[400010]; vector<int> g[4000]; map<pair<int, int>, vector<pair<int, int> > > M; void color(int x) { if (block[x]) return; block[x] = 1; for (int i = 0; i ...
#include <bits/stdc++.h> using namespace std; const int oo = 10000000; int n, m, x, y, a, b; int vabs(int t) { return (t > 0) ? t : (-t); } int calc(int cx, int cy) { int dx = vabs(cx - x); int dy = vabs(cy - y); if (dx == 0 && dy == 0) return 0; if (dx % a != 0 || dy % b != 0) return oo; ...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { long long int temp; while (b > 0) { temp = b; b = a % b; a = temp; } return a; } int main() { long long int N, m; cin >> N >> m; long long int a[N], B[m]; for (lo...
#include <bits/stdc++.h> const int MAXN = 1000000; int N; long long Ans; std::vector<int> G[MAXN + 5]; long long Val[MAXN + 5]; int Size[MAXN + 5]; int Fa[MAXN + 5], Dep[MAXN + 5]; void Dfs(int u, int fa, int dep) { Size[u] = 1; Fa[u] = fa; Dep[u] = dep; for (int i = 0; i < int(G[u].size...
(************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010 *) (* \VV/ **************************************************************) (* // * Th...
/*************************************************************************************************** ** fpga_nes/hw/src/cpu/apu/apu_triangle.v * * Copyright (c) 2012, Brian Bennett * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided th...
#include <bits/stdc++.h> using namespace std; map<vector<int>, int> mp; map<int, int> dp[100050]; set<int> ans; vector<int> vec[100050]; int n, cnt = 0; int getid(vector<int> t) { if (mp.find(t) == mp.end()) return mp[t] = ++cnt; else return mp[t]; } int getv(int x, int y) { if...
module main; reg [2:0] Q; reg clk, clr, up; (*ivl_synthesis_off *) initial begin clk = 0; up = 0; clr = 1; #1 clk = 1; #1 clk = 0; if (Q !== 0) begin $display("FAILED"); $finish; end up = 1; clr = 0; #1 clk = 1; #1 clk = 0; ...
#include <bits/stdc++.h> using namespace std; const int MAX = 200005; int visited[MAX]; int a[MAX], dis[MAX]; int n; void bfs() { queue<int> q; int b; visited[1] = 1; dis[1] = 0; q.push(1); while (!q.empty()) { b = q.front(); q.pop(); if (!visited[b + 1] && b + 1 <=...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; vector<int> ans; char s1[maxn], s2[maxn]; int n; void op(int x) { for (int i = 1; i <= x; ++i) { s1[i] = s1[i] == 0 ? 1 : 0 ; } reverse(s1 + 1, s1 + 1 + x);...
#include <bits/stdc++.h> struct DSU { private: int32_t* parents; int32_t* sizes; std::vector<std::pair<int32_t, int32_t> > actions; int32_t get_root(int32_t v) { if (parents[v] == v) return v; return get_root(parents[v]); } public: DSU(int32_t n) { parents = new int3...
#include <bits/stdc++.h> using namespace std; vector<int> tab[100100], ans; int n, ls[10]; bool used[100100]; bool chek(int a, int b) { for (int i = 0; i < 4; i++) if (tab[a][i] == b) return true; return false; } int main() { scanf( %d , &n); for (int i = 0; i < n + n; i++) { i...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const long long mod = 1e9 + 7; long long powr(long long a, long long b) { long long x = 1 % mod; a %= mod; while (b) { if (b & 1) x = (x * a) % mod; a = (a * a) % mod; b >>= 1; } return x; } long l...
#include <bits/stdc++.h> using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2510; int sum[maxn][maxn]; char s[maxn][maxn]; int n, m, K; long long ans; int p1[10], p2[10]; int cal(int x1, int y1, int x2, int y2) { return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1]; } void div(int x1,...
#include <bits/stdc++.h> using namespace std; ifstream in; ofstream out; const long long kk = 1000; const long long MOD = 10e9 + 7; long long a, b, x, y; long long GCD(long long n, unsigned long long m) { while (n != 0 && m != 0) { if (n > m) { n %= m; } else { m %= n; ...
//------------------------------------------------------------------- // // COPYRIGHT (C) 2011, VIPcore Group, Fudan University // // THIS FILE MAY NOT BE MODIFIED OR REDISTRIBUTED WI...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f, N = 2e5 + 5; inline int read() { int sum = 0, f = 1; char c = getchar(); while (c > 9 || c < 0 ) { if (c == - ) f = -f; c = getchar(); } while (c >= 0 && c <= 9 ) sum = sum * 10 + c - 48, c = getchar()...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long oo = 1e9 + 7; const int mod = 1e9 + 7; double x, y, tmp; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> x >> y; tmp = log(x) / log(y); if (tmp * y * 1.00 < x) ...