text
stringlengths
59
71.4k
#include <bits/stdc++.h> int cicle[300] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, ...
#include <bits/stdc++.h> static inline void setio(void); int main(void) { setio(); long long n; std::cin >> n; std::vector<long long> vec(n); std::vector<char> neg(n); for (long long i = 0; i < n; ++i) { std::cin >> vec[i]; if (vec[i] < 0) { neg[i] = true; vec[i] ...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003,2004 Matt Ettus // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the Li...
#include <bits/stdc++.h> using namespace std; const int INF = (int)2e9; const long long INFL = (long long)9e18; const int MAXINT = ((~0) ^ (1 << 31)); const long long MAXLL = ((~0) ^ ((long long)1 << 63)); template <class T> inline T pow2(T a) { return a * a; } template <class T> inline bool min...
//-------------------------------------------------------------------------------- // controller.vhd // // Copyright (C) 2006 Michael Poppitz // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Fo...
#include <bits/stdc++.h> using namespace std; using ld = long double; using ll = long long; void solve() { int n; cin >> n; vector<int> v(n); vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) { cin >> v[i]; a[i] = {v[i], i}; } sort(a.begin(), a.end()); vector<i...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int maxn = 2e3 + 1; const int maxm = 2e3 + 1; char a[maxn], b[maxn]; int num[maxn]; int m, d; long long dp[maxn][maxm]; int len; int judge(const char* s, int lena) { int mod = 0; for (int i = 1; i <= lena; i++) { ...
module FrameTrans(Reset,Clock100M,Mode,Clock,DataIn); input Reset; input Clock100M; input [1:0] Mode; output Clock; output reg DataIn; reg [31:0] Counter; reg Clk_10ms; reg [7:0] StateCnt256; reg [1:0] FrameCnt4; reg FrameStart; reg ScrambEn; wire ScrambOut; parameter ...
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n >> a >> b; string s; cin >> s; for (int cnt1 = 0; cnt1 <= n / a; ++cnt1) { for (int cnt2 = 0; cnt2 <= n / b; ++cnt2) if (a * cnt1 + b * cnt2 == n) { cout << cnt1 + cnt2 << endl; for...
/////////////////////////////////////////////////////////////////////////////// // $Id: small_fifo.v 1998 2007-07-21 01:22:57Z grg $ // // Module: fallthrough_small_fifo.v // Project: utils // Description: small fifo with fallthrough i.e. data valid when rd is high // // Change history: // 7/20/07 -- Set nearly full ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, int> p[n]; int t = 0; for (int i = 0; i < n; i++) { cin >> p[i].first >> p[i].second; } sort(p, p + n); int start = 0, l = 0, r = 0, s = 0; for (int i = 0; i < 2 * n; i++) { if (i < ...
#include <bits/stdc++.h> using namespace std; int n, arr[1042], cc[1042]; vector<pair<int, int> > path; vector<pair<int, int> > ans; map<pair<long long, long long>, pair<int, int> > m; long long base = 1031, mod = 1000000007LL, mod2 = 1000000009LL; long long pows[1042] = {1}; pair<long long, long long> ...
/** * 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 long long mod = 998244353; long long n, m, l, r; long long binpow(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1; } return res % mod; } long long inv(lon...
// *************************************************************************** // *************************************************************************** // Copyright 2013(c) Analog Devices, Inc. // Author: Lars-Peter Clausen <> // // All rights reserved. // // Redistribution and use in source and binary forms, ...
// // (C) 1992-2014 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simul...
//Legal Notice: (C)2017 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
/** * 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 <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << { ; string sep; for (const auto &x : v) os << sep << x, sep = , ; return os << } ; } template <typename T> ostream &operator<<(ostream &os, const set<T> &v) { ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: dram_sc_0_rep2.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 an...
// Build a test bench to test the design module testBench; wire [12:0] pc; // connect the pc wire clock; // connect the clock hal1 aComputer (clock, pc); // build an instance of the computer test_it aTester(clock, pc); // build a tester initial begin $dumpfile("hal1.vcd"); $d...
#include <bits/stdc++.h> using namespace std; template <class temp> inline void Rd(temp &p) { p = 0; char c; while (c = getchar(), c < 48) ; do p = p * 10 + (c & 15); while (c = getchar(), c > 47); } int pow(int n, int m) { int ans = 1; while (m) { if (m & 1) ans = 1ll ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; const ll MOD = 1e9 + 7, N = 1e5 + 10; void test() { ll n; cin >> n; vector<ll> a(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } vector<ll> ans; sort(a.begin(), a.end()); ll l = ...
#include <bits/stdc++.h> using namespace std; const int MAX = 1000000; const int MAX_N = 50000; const int oo = 1e9; const int LOGN = 20; const int Z = 230; int f[MAX + 1], n, m, a[MAX_N], ans[MAX_N]; struct node { int nxt[2], val; multiset<int> mst; node() { memset(nxt, -1, sizeof nxt)...
// -*- Mode: Verilog -*- // Filename : system_controller_altera.v // Description : System Controller for Altera FPGA // Author : Philip Tracton // Created On : Sat Jan 7 21:51:18 2017 // Last Modified By: Philip Tracton // Last Modified On: Sat Jan 7 21:51:18 2017...
#include <bits/stdc++.h> using namespace std; long long n, x, a, s; vector<pair<int, long long> > v, u; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x >> a; if (x < 0) v.push_back(make_pair(-x, a)); else u.push_back(make_pair(x, a)); s += a; } ...
#include <bits/stdc++.h> using namespace std; const int max_n = 100; int a[max_n], tmp[max_n]; bool vis[max_n]; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int main() { int n; cin >> n; for (int i = 0; i < (n); i++) { cin >> a[i]; a[i]--; tmp[i] = ...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: fifo_39x256.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ===========================================...
// Copyright (c) 2014, Segiusz 'q3k' Bazanski <> // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // 1. Redistributions of source code must retain the above copyright notice, // this l...
#include <bits/stdc++.h> using namespace std; int n, i, j, k, e, x, l[7], r[7]; double p, c, res, f[7][7][3]; int main() { scanf( %d , &n); for (i = 0; i < n; i++) scanf( %d%d , &l[i], &r[i]); for (i = 1; i <= 10000; i++) { memset(f, 0, sizeof(f)); f[0][0][0] = 1; for (j = 0; j < n...
#include <bits/stdc++.h> using namespace std; template <typename T> T load() { T r; cin >> r; return r; } template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; } struct StrInt { StrInt(const string& ref) : ref(...
#include <bits/stdc++.h> using namespace std; int n, m; int visited[200001]; int colour[200001]; vector<int> adj_list[200001]; int* graph[1000001]; int* finalcolour[1000001]; int size[1000001]; int check; int count1 = 0; int k[9]; int l[9]; int dp[9][1001]; int A[9][11]; int c[9][10]; bo...
// Author: Adam Nunez, // Copyright (C) 2015 Adam Nunez // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // //...
#include <bits/stdc++.h> using namespace std; const int N = 1e7 + 10; int n; vector<string> a; vector<pair<pair<int, int>, int> > pos; char s[N]; int main() { scanf( %d , &n); for (int i = (0); i < (n); i++) { int m; string t; cin >> t; a.push_back(t); scanf( %d , &m)...
/* * Copyright 2015, Stephen A. Rodgers. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version...
/** * 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...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.3 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1ns/1ps ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> v; vector<int> vn; for (int i = 0; i < n; i++) { string a; cin >> a; bool cn = false; int y = 0; for (int j = 0; j < v.size(); j++) { if (a == v[j]) { y = j;...
#include <bits/stdc++.h> using namespace std; template <class node> struct link_cut_tree { bool connected(node* u, node* v) { return lca(u, v) != NULL; } int depth(node* u) { access(u); return get_sz(u->ch[0]); } node* get_root(node* u) { access(u); while (u->ch[0]) u = u->...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, x, p, q, ans = 0, cnt = 0; ; cin >> n >> k >> x; int a[n + 5]; for (int i = 1; i <= n; i++) { cin >> a[i]; } if (n == 1) { cout << x << endl; return 0; } for (int i = n; i > 1; i--) { if ...
module RM_ctrl ( input rst, input[`ByteSlctWidth-1:0] byte_slct, input[`OpcodeWidth-1:0] opcode, input[`RegDataWidth-1:0] raw_mem_data, output reg[`RegDataWidth-1:0] data_to_reg ); reg[`ByteBus] read_byte; reg[`HalfWordBus] read_half_word; always @(*) begin : proc_read_byte case (byte_slct...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.1 (lin64) Build 881834 Fri Apr 4 14:00:25 MDT 2014 // Date : Thu May 1 14:04:03 2014 // Host : macbook running 64-bit Arch Linux // ...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; int n; string s; int main() { cin >> n; cin >> s; bool tmp = false; for (int i = 0; i <= s.size() - 1; i++) { if (s[i] > s[i + 1]) { tmp = true; s.erase(i, 1); break; } } if (!tmp) ...
#include <bits/stdc++.h> using namespace std; template <class T> inline T mod_v(T num) { if (num >= 0) return num % 1000000007; else return (num % 1000000007 + 1000000007) % 1000000007; } template <class T> inline T gcd(T a, T b) { a = abs(a); b = abs(b); while (b) { a ...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1, ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x *...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2005 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=1; reg b; wire vconst1 = 1'b0; wire vconst2 = !(vconst...
#include <bits/stdc++.h> using namespace std; vector<bool> visited; vector<vector<long long> > adj; vector<vector<long long> > rev; vector<long long> order; vector<char> col; void dfs1(long long x) { visited[x] = true; for (auto y : adj[x]) { if (!visited[y]) dfs1(y); } order.push_ba...
#include <bits/stdc++.h> using namespace std; template <class T, class L> bool smax(T &x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> bool smin(T &x, L y) { return y < x ? (x = y, 1) : 0; } const int maxn = 20, maxm = 1e5 + 17; char c[maxm]; int n, m, col[maxm]; int...
#include <bits/stdc++.h> using namespace std; const int mxn(3e5 + 10), mxm(4e5 + 10); const long long modl(998244353); int nm, n, m, p, t, k; int ans; int a[mxn], b[mxn], c[mxn]; int main() { ios_base::sync_with_stdio(false); cin >> nm; while (cin >> n >> m) { ans = max(0, n + m - 3) / m...
// *************************************************************************** // *************************************************************************** // Copyright 2011(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; long long resp, n, m, tt; int main() { cin >> n >> m; if (m % 2 == 0) { tt = m / 2; tt = tt * (tt + 1) - tt; } else { tt = m / 2; tt = tt * (tt + 1); } for (long long i = 2; i <= n; i += 2) { resp += tt * (n - i + 1); ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1005; const int INF = 0x3f3f3f3f; int a[MAXN]; int book[MAXN * 2]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) { int tmp; scanf( %d , &tmp); a[tmp] = 1; } queue<int> Q; mem...
#include <bits/stdc++.h> using namespace std; int main() { double a, b, m, vx, vy, vz; cin >> a >> b >> m >> vx >> vy >> vz; double X = a / 2 - m / vy * vx; double Z = -m / vy * vz; while (X < 0 || X > a) if (X > a) X = 2 * a - X; else X = -X; while (Z < 0 || Z > ...
/* * 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; vector<long long> v[2000006], pp[2000006]; long long first[2000006], cur = 0, w[2000006], n, m, i, xx, second, d, h, ans, w1, p, tt, o, temp, t; void dfs(long long node, long long l) { if (node > n) return; long long i, j; fir...
/*------------------------------------------------------------------------------ * 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...
/** * 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 MAX_N = 300 * 1000 + 10; long long dist[MAX_N], dist1[MAX_N]; vector<pair<int, int>> adj[MAX_N]; set<pair<long long, int>> s; bool inPath[MAX_N]; pair<int, int> mx; int nxt[MAX_N]; bool dfs_path(int u, int par = -1) { for (auto x : adj[u]) { ...
#include <bits/stdc++.h> using namespace std; int setbit(int n, int pos) { return n = n | (1 << pos); } int resetbit(int n, int pos) { return n = n & ~(1 << pos); } bool checkbit(int n, int pos) { return (bool)(n & (1 << pos)); } template <typename T> T modMul(T x, T y, T mod = 1e9 + 7) { x %= mod; ...
/** * 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; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; string s; cin >> s; int cnt = 0; for (int i = 0; i < n; i++) { int up = 0, le = 0; for (int j = i; j < n; j++) { if (s[j] == U ) up++; if (s[j] == D ) u...
#include <bits/stdc++.h> using namespace std; const int C = 10005, N = 1005; int n, w, b, x, c[N], cost[N]; long long dp[2][C]; template <class T> void maxz(T &a, T b) { if (a < b) a = b; } int main() { int i, j, k, ub; long long mn; scanf( %d%d%d%d , &n, &w, &b, &x); for (i = 1; i <...
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7; int p[11]; vector<int> operator*(const vector<int> &lhs, const vector<int> &rhs) { vector<int> ret; ret.resize(lhs.size() + rhs.size() - 1, 0); for (int i = 0; i < lhs.size(); i++) { for (int j = 0; j < rhs.size(); j++) { ...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.3 (win64) Build Wed Oct 4 19:58:22 MDT 2017 // Date : Fri Nov 17 14:49:55 2017 // Host : egk-pc running 64-bit major release (build...
/* * Wishbone Flash RAM core with delayed ack for Altera DE0 board * Copyright (C) 2010 Donna Polehn <> * delayed ack added 2014 by Charley Picker <> * * 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...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2013.4 // Copyright (C) 2013 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps mod...
#include <bits/stdc++.h> using namespace std; int main() { ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long i, j, k, n, m, ans = 0, sum = 0, a[100005] = {0}, mn = 2e9, mx = 0, x, y, z, cnt = 0; string s; set<long long> zero, one; se...
#include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; } template <class T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; } inline int nxt() { int wow; scanf( %d , &wow); return wo...
///////////////////////////////////////////////////////////////////// //// //// //// WISHBONE AC 97 Controller Reset Module //// //// //// //// ...
#include <bits/stdc++.h> using namespace std; const int MAX = 200000; int n; string s1, s2; int main() { cin >> n >> s1 >> s2; int K = 7; long long H = 0, HH = 0, D = 1; n--; for (int(i) = (1); i < (n + 1); ++(i)) { int p = 0, pp = 0; if (s1[n - i] == N ) p = 1; if (s1[n...
#include <bits/stdc++.h> using namespace std; inline void intialize() { cin.tie(0); ios_base::sync_with_stdio(0); cout.tie(0); } void clearArr(int arr[], int n); bool arr[105][105]; bool farr[105]; queue<int> q; queue<int> done; int main() { intialize(); string ans[2] = { No , Yes...
#include <bits/stdc++.h> const int maxn = 200001, maxf = 19; const long long INF = 0x3f3f3f3f3f3f3f3fLL; int n, q, tot, lnk[maxn], dep[maxn], fa[maxn][maxf]; struct Edge { int v, nxt; } e[maxn << 1]; template <class T> void swap(T& x, T& y) { const T t = x; x = y; y = t; } template <cl...
`timescale 1ns / 1ps `define clkperiodby2 10 ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 05/04/2015 02:52:37 PM // Design Name: // Module Name: tb_mult // Project Name: // Target Devices: // Tool Versions: // Description: // //...
#include <bits/stdc++.h> using namespace std; int n; string s; int main() { cin >> n >> s; int sol = n; for (int i = 1; i < n; i++) { if (s[i] != s[i - 1] and s[i - 1] != D ) { sol--; s[i] = D ; } } cout << sol << endl; }
#include <bits/stdc++.h> const int inf = (1ll << 30) - 1; const int maxn = (int)1e5 + 10; using namespace std; int dp[150][(1 << 16) + 100]; int c[111]; int r[111]; int b[111]; char temp[111]; int cntR[(1 << 16) + 10]; int cntB[(1 << 16) + 10]; int n; void solve() { memset(dp, -1, sizeof dp)...
#include <bits/stdc++.h> using namespace std; int A[10010] = {0}; int D; int N, M, P; int g; int fact[20010] = {0}; int fp = 0; int Hash[20010] = {0}; int place[10010] = {0}; int F[20010] = {0}; long long power(long long a, long long k, long long Mod) { long long o = 1; for (; k > 0; k >>=...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty. // bug998 interface intf #(parameter PARAM = 0) (); logic val; function integer func (); return 5; endfunction endinterface module t1(intf mod_intf); initial begin ...
`include "../lib/mux32bits_32to1.v" module test; reg [4:0] s; reg [31:0] i31, i30, i29, i28, i27, i26, i25, i24, i23,i22, i21, i20, i19, i18, i17, i16; reg [31:0] i15, i14, i13, i12, i11, i10, i9, i8, i7,i6, i5, i4, i3, i2, i1, i0; wire [31:0] z; reg [31:0] val, expect; mux32bits_32to1 mux( .s (s...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3fffffff; const int maxn = 100000 + 5, maxh = 800; int n, k; int f[maxh], g[maxh]; vector<int> P[maxn]; int main() { scanf( %d%d , &n, &k); for (int i = 1, iend = k; i <= iend; ++i) { int x, y; scanf( %d%d , &x, &y); ...
#include <bits/stdc++.h> using namespace std; long long n, i, p[202020], ki[202020], ka[202020], ta, tb, taa, tbb, nx[202020]; void gab(long long aa, long long bb) { nx[ka[aa]] = ki[bb]; ka[aa] = ka[bb]; ki[bb] = ki[aa]; p[aa] = bb; } long long car(long long aa) { if (p[aa] == aa) re...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long a, b; cin >> a >> b; long long sum = 0; long long notes = 0; while (sum + notes + 1 <= a + b) { ++notes; sum += notes; } set<int> possible; for (int ...
// (C) 2001-2011 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated doc...
#include <bits/stdc++.h> using namespace std; double p[8][10020]; int main() { int n; int l[8], r[8]; scanf( %d , &n); double ex = 0; double all = 1.0; for (int i = 0; i < n; i++) { scanf( %d %d , &l[i], &r[i]); all *= (r[i] - l[i] + 1); } for (int i = 1; i <= 10000; ++...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; double memo[105][105][105]; double dp(int R, int S, int P) { if (R == 0) return 0; if (S + P == 0) return 1; double& ret = memo[R][S][P]; if (memo[R][S][P] >= 0) return ret; ret = 0; i...
#include <bits/stdc++.h> const int maxnm = 9 + 2; int n, m; char map[maxnm][maxnm], best[maxnm][maxnm]; bool shape[4][3][3] = {{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}}, {{0, 1, 0}, {0, 1, 0}, {1, 1, 1}}, {{1, 0, 0}, {1, 1, 1}, {1, 0, 0}}, {{0, ...
module data_test2 ( input rst, //reset input clk, output reg din_stb, input [1:0] din_ready, output reg [1:0] din_activate, output reg [31:0] din, input [23:0] din_size, input dout_ready, output reg ...
#include <bits/stdc++.h> using namespace std; const long long INF = 0x3f3f3f3f; const int N = 3e5 + 10; const long long mod = 1e9 + 7; const double PI = acos(-1); inline long long mm(long long x, long long p) { return x >= p ? x -= p : ((x < 0) ? x += p : x); } inline long long ab(long long x) { ret...
//I ll always miss you like a darling. #include <bits/stdc++.h> using namespace std; #define LL long long #define LD long double #define ull unsigned long long #define x first #define y second #define pb push_back #define pf push_front #define mp make_pair #define Pair pair<int,int> #define p...
`include "CLA.v" module tb4CLA; wire C_OUT; wire [15:0] SUM; reg C_IN; reg [15:0] A, B; CLA CLA00 (A, B, C_IN, SUM, C_OUT); initial begin C_IN = 1'd1; A = 16'd21; B = 16'd56; #5 C_IN = 1'd0; A = 16'd23; B = 16'd198; #5 C_IN = 1'd1; A = 16'd4...
// DESCRIPTION: Verilator: Verilog Test module // // Copyright 2010 by Wilson Snyder. This program is free software; you can // redistribute it and/or modify it under the terms of either the GNU // Lesser General Public License Version 3 or the Perl Artistic License // Version 2.0. `ifdef USE_VPI_NOT_DPI //We call it ...
/* wb_upsizer_tb. Part of wb_intercon * * ISC License * * Copyright (C) 2019 Olof Kindgren <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies....
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Jafet Chaves Barrantes // // Create Date: 11:45:21 03/21/2016 // Design Name: // Module Name: timing_generator_VGA // Project Name: // Target Devices: // Tool versions: // Descr...
#include <bits/stdc++.h> using namespace std; int a[100010]; int b[100010]; int ans[100010]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; b[a[i]] = i; } ans[b[n]] = 0; for (int i = n - 1; i >= 1; i--) { int idx = b[i]; int flag = 0; ...
/* * Copyright (c) 2013, Stefan Kristiansson <> * All rights reserved. * * Redistribution and use in source and non-source forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, th...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; long long n_r, n_g, n_b, r[maxn], g[maxn], b[maxn], ans; void cal(long long n_r, long long n_g, long long n_b, long long r[], long long g[], long long b[]) { long long x, y, z, i, j = 1, k = 1; for (i = 1; i <= n_g; ++i...
module wb_7seg_new (clk_i, nrst_i, wb_adr_i, wb_dat_o, wb_dat_i, wb_sel_i, wb_we_i, wb_stb_i, wb_cyc_i, wb_ack_o, wb_err_o, wb_int_o, DISP_SEL, DISP_LED); input clk_i; input nrst_i; input [24:1] wb_adr_i; output [15:0] wb_dat_o; input [15:0] wb_dat_i; input [1:0] wb_sel_i; input wb_we_i; inpu...
#include <bits/stdc++.h> using namespace std; const long long inf(101010101010101010LL); int n; struct uf { int par[1005]; uf() { for (int i(0); i < (n); i++) par[i] = i; } int ff(int x) { return par[x] == x ? x : par[x] = ff(par[x]); } void uu(int x, int y) { x = ff(x), y = ff(y...
/* * Copyright (C) 2011 Kiel Friedt * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This p...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Fri Mar 31 18:24:55 2017 // Host : LAPTOP-IQ9G3D1I running 64-bit major releas...