text
stringlengths
59
71.4k
/* * Copyright 2013-2021 Robert Newgard * * This file is part of fcs. * * fcs 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. ...
#include <bits/stdc++.h> using namespace std; void fft(vector<complex<double> > &a, bool invert) { int n = a.size(), lg = 0; while (1 << lg < n) ++lg; assert(1 << lg == n); for (int i = 0; i < n; ++i) { int rev = 0; for (int j = 0; j < lg; ++j) if ((i & 1 << j) != 0) rev |= 1 << ...
#include <bits/stdc++.h> using namespace std; int main() { int t, tc; cin >> t; for (tc = 0; tc < t; tc++) { int n, i; cin >> n; vector<int> v(n), mx(n + 1, 0), mn(n + 1, n + 5); for (i = 0; i < n; i++) { cin >> v[i]; mx[v[i]] = i; mn[v[i]] = i; } ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vpii = vector<pii>; using vpll = vector<pll>; template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (const auto &x : v) os << x << ; retur...
//----------------------------------------------------------------------------- // Copyright (C) 2014 iZsh <izsh at fail0verflow.com> // // This code is licensed to you under the terms of the GNU GPL, version 2 or, // at your option, any later version. See the LICENSE.txt file for the text of // the license. //--------...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2000000; char a[MAXN + 10], b[MAXN + 10]; int main(void) { int n; scanf( %d%s%s , &n, a, b); int cnt[2][2]; for (int i = 0; i < (2); ++i) { for (int j = 0; j < (2); ++j) { cnt[i][j] = 0; } } n *= 2; fo...
#include <bits/stdc++.h> using namespace std; string tobinary(long long x) { string ret; char ch; while (x) ch = 0 + (x % 2), ret = ch + ret, x /= 2; return ret; } long long todecimal(string s) { int sz = s.size(); long long ret = 0; for (int i = 0; i < sz; i++) ret = 2 * ret + (s[...
module daala_idct4_stream_v1_0_M00_AXIS # ( // Users to add parameters here // User parameters ends // Do not modify the parameters beyond this line // Width of S_AXIS address bus. The slave accepts the read and write addresses of width C_M_AXIS_TDATA_WIDTH. parameter integer C_M_AXIS_TDATA_WIDTH = 32, ...
// 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 : Sun Apr 09 08:26:59 2017 // Host : GILAMONSTER running 64-bit major release (...
/* * 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; using ull = unsigned long long; using ll = long long; using ld = long double; const int mod = 1e9 + 7; const double pi = acos(-1.0); const int inf = INT_MAX; const int N = (1 << 22); int h, g, a[N]; bool ok(int i) { while (true) { if (a[i << 1]...
/* * 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 fp(long long x, long long y, long long m = 998244353) { long long ANS = 1; while (y) { if (y & 1) ANS = (ANS * x) % 998244353; x = (x * x) % 998244353; y >>= 1; } return ANS; } long long inv(long long x, long long m = 9982...
#include <bits/stdc++.h> using namespace std; struct node { int a, b; bool operator<(const node& r) const { return r.b < b; } } e[105]; int dp[10005][105]; int main() { int n, sum = 0, num = 0, sum2 = 0; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &e[i].a); sum +...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); string s, t, p = ; cin >> s >> t; int n = s.size(); int c = 0; for (int i = 0; i < n; i++) if (s[i] != t[i]) c++; if (c % 2) { cout << impossible ; return 0; } for (i...
`timescale 1ns/1ps //----------------------------------------------------------------------------- // Title : KPU interrupt controller // Project : KPU //----------------------------------------------------------------------------- // File : kpu.v // Author : acorallo <> // Created : 12.3.2017 //----------------...
#include <bits/stdc++.h> using namespace std; int main() { int T, n, i, j, k; cin >> T; while (T--) { cin >> n; string str[51]; for (i = 0; i < n; i++) { cin >> str[i]; } if (n == 1) { cout << YES << endl; continue; } for (i = n - 1; i ...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2015.1 // Copyright (C) 2015 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1ns/1ps modul...
#include <bits/stdc++.h> int n, m; std::vector<std::vector<int> > gr; std::vector<int> par; std::vector<bool> vis; std::vector<int> lev; void dfsgr(int v) { vis[v] = true; for (auto& ch : (gr[v])) { if (vis[ch]) continue; lev[ch] = lev[v] + 1; par[ch] = v; dfsgr(ch); } ...
#include <bits/stdc++.h> using namespace std; long long int eet(long long int a, long long int b, long long int *x, long long int *y) { if (a == 0) { *x = 0; *y = 1; return b; } long long int x1, y1; long long int gcd = eet(b % a, a, &x1, &y1); *x = y1 - (b ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; long long t = 1; if (n < 30) { for (int i = 0; i < n; i++) { t *= 2; } cout << m % t; } else { cout << m; } return 0; }
#include <bits/stdc++.h> using namespace std; const int maxVal = 200005; int arr[maxVal]; int tree[4 * maxVal]; void build(int node, int start, int endd, int k) { if (start == endd) { if (arr[start] >= k) tree[node] = 1; else tree[node] = 0; } else { int mid = (start ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016 // Date : Fri Sep 22 10:48:49 2017 // Host : vldmr-PC running 64-bit Service Pack 1 ...
#include <bits/stdc++.h> using namespace std; int n, k; vector<int> g[100005]; int siz[100005]; bool era[100005]; long long rans; int col[100005]; int calc(int v, int p) { int cnt = 1; for (int i = 0; i < (int)g[v].size(); i++) { int to = g[v][i]; if (to == p || era[to]) continue; ...
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, q, a[N], c[N], l[N], r[N]; vector<int> s[N], p[N], b; set<int> s1, s2, s3, s4, s5, s6, s7; int main() { scanf( %d%d , &n, &q); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= q; i++) { scanf( %...
#include <bits/stdc++.h> using namespace std; int n, m, j, s; int k[100000], a[100000], b[100000]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> k[i]; for (int i = 0; i < m; i++) { int x, y, z; cin >> x >> y; if (x == 1) { cin >> z; k[y - 1] = z; ...
#include <bits/stdc++.h> using namespace std; const int _ = 1e5 + 7; const int __ = 4e5 + 7; const int L = 11; int n, Q; long long a[_], pw[L + 7]; namespace SGT { long long num[__], minx[__], tag[__]; bool cov[__]; bool flag; void Build(int k, int l, int r) { if (l == r) { int j = 0; ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 09:28:48 05/31/2011 // Design Name: upd77c25 // Module Name: /home/ikari/prj/sd2snes/verilog/sd2snes/updtest.tf // Project Name: sd2snes // Target Device: // Tool ver...
`timescale 1ns/10ps module PushBtnSim; reg clock; reg reset; reg [11:0] inst; reg inst_en; reg button; wire button_status; initial begin #0 $dumpfile(`VCDFILE); #0 $dumpvars; #10000 $finish; end initial begin #0 clock = 1; ...
// megafunction wizard: %RAM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: HeapRAM.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ================================...
/* * 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; const int mod = 1e9 + 7; long long int dp[100000 + 5] = {0}; void fun(long long int *A, long long int N) { dp[0] = 0; long long int a = 0; for (long long int i = 1; i <= 100000; ++i) { while (a < N and A[a] <= i) ++a; dp[i] = a; } } v...
#include <bits/stdc++.h> using namespace std; int long long x, y, l, r, k, i, j, ans; vector<int long long> mex, mey, my; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> x >> y >> l >> r; for (k = 1; k <= 1e18 / x; k *= x) mex.push_back(k); if (k <= 1e18)...
//----------------------------------------------------------------------------- //-- Baudrate generator //-- It generates a square signal, with a frequency for communicating at the //-- given baudrate //-- The output is set to 1 only during one clock cycle. The rest of the // time is 0 //-- Once enabled, the pulse is g...
#include <bits/stdc++.h> using namespace std; int a[110], b[110]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + 1 + n); int aa = a[n]; cin >> n; for (int i = 1; i <= n; ++i) cin >> b[i]; sort(b + 1, b + 1 + n); int bb = b[n]; cout <...
#include <bits/stdc++.h> using namespace std; int main() { const long long MOD = 1000003; int n; cin >> n; long long g = 1; for (int i = 1; i < n; i++) { g = (g * 3) % MOD; } cout << g; }
/* * Milkymist VJ SoC * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * * 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, version 3 of the License. * * This program is distributed ...
/** * 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 N = 1e5 + 5; int arr[N]; long long seg[N << 2], mn[N << 2], lazy[N << 2]; bool flag[N << 2]; int n, q; vector<long long> v; void push_down(int id) { if (flag[id]) { lazy[id] = lazy[((id << 1) + 1)] = lazy[((id << 1) + 2)] = 0; seg[(...
/**************************************************************************** * Copyright (c) 2009 by Focus Robotics. All rights reserved. * * This program is an unpublished work fully protected by the United States * copyright laws and is considered a trade secret belonging to the copyright * holder. No part of ...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 100; template <class nmsl> inline void read(nmsl &x) { x = 0; char ch = getchar(), w = 0; while (!isdigit(ch)) w = (ch == - ), ch = getchar(); while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); x = w ? -...
//---------------------------------------------------------------------------- // bfm_system_tb.v - module //---------------------------------------------------------------------------- // // *************************************************************************** // ** Copyright (c) 1995-2012 Xilinx, Inc. All...
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 100; const int D = 19; struct QUE { int l, r, len, id; QUE(int _l, int _r, int _len, int _id) { l = _l; r = _r; len = _len; id = _id; } }; struct OPT { int x, y; OPT(int _x, int _y) { x = _x; ...
/** * 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 = 1e9 + 7; const long double PI = 4 * atan((long double)1); const long long INF = 1e18; const long long NINF = -1e18; long long get_hash(string s) { long long N = 1000001; long long base[N], A = 11, MD = 1110111110111; base[0] = 1...
#include <bits/stdc++.h> using namespace std; const int kMaxN = 1000005; int aib[2 * kMaxN]; int x[kMaxN], poz[kMaxN]; int el[2 * kMaxN]; bool first[kMaxN]; void aib_update(int ind, int val) { while (ind < 2 * kMaxN) { aib[ind] += val; ind += ind & (-ind); } return; } int aib_s...
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_str...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; const int N = 207; const int K = 1007; const long long mod = 1e9 + 7; long long dp[2][N][K]; long long a[N]; int n, k; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) scanf...
#include <bits/stdc++.h> using namespace std; int N, K; string s; bool dp[1010][1010]; bool dfs(int i, int j) { if (i == N && abs(j) == K) return true; if (i != N && abs(j) == K) return false; if (i == N && abs(j) != K) return false; if (dp[i][j] == 1) return false; dp[i][j] = 1; if (s...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 500; const int LN = 21; const long long mod = 1e9 + 7; const long long INF = 1LL << 57; long long n, m, u, v, k, t, q, a, x, d; int tree[4 * N]; int sum[4 * N]; int lim = 1e6 + 2; int arr[N], brr[N]; bool print = false; void modif...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2013 Altera Corporation, San Jose, California, USA. * ...
#include <bits/stdc++.h> const int maxn = 1e5 + 100; const double eps = 1e-7; const int INF = 1e9; using namespace std; bool f[maxn]; int a[maxn]; struct Node { int i, num; bool operator<(const Node &rhs) const { return i < rhs.i || (i == rhs.i && num < rhs.num); } }; int main() { ...
#include <bits/stdc++.h> using namespace std; const int inf = 1e5 + 9; int n; int mp[9]; bool done[109]; vector<pair<long long, pair<long long, long long> > > v[109]; void dfs(int node) { done[node] = 1; for (int i = 0; i < v[node].size(); i++) { int u = v[node][i].first; int e = v[nod...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( -ffloat-store ) #pragma GCC optimize( -fno-defer-pop ) long long int power(long long int a, long long int b, long long int m) { if (b == 0) return 1; if (b == 1) ret...
#include <bits/stdc++.h> using namespace std; const int maxn = 5 * 1000000 + 100; char str[maxn << 1], s[maxn]; int p[maxn << 1]; int ans; int n; int f[maxn << 1]; void Init(void) { str[0] = $ , str[1] = # ; for (int i = 0; i < n; i++) { str[i * 2 + 2] = s[i]; str[i * 2 + 3] = # ;...
/* * NAME * * cpu_tb.v - generic cpu test bench * * DESCRIPTION * * This generic cpu test bench can be used to run a program, which is in * ASCII hex format, and output the results. * * Configuration is done by setting preprocessor defines at compile * time. The result is an executable for that specific tes...
// ---------------------------------------------------------------------- // HLS HDL: Verilog Netlister // HLS Version: 2011a.126 Production Release // HLS Date: Wed Aug 8 00:52:07 PDT 2012 // // Generated by: fyq14@EEWS104A-002 // Generated date: Tue Mar 03 15:18:42 2015 // -------------------...
#include <bits/stdc++.h> using namespace std; int n, m, zz; string s; int a[28]; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ntest; cin >> ntest; while (ntest--) { cin >> n >> m >> zz >> s; for (int i = 0; i < 28; ++i) a[i] = 0; for (in...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-9; const long double PI = 3.141592653589793238462643383279502884197; const int MOD = 666013; const int NMax = 350000; int N, C, D; int lastIndexForSearch; long long ans = 0LL; struct Punct; long long diferente[NMax], diferenteP...
/** * 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() { string x, y; cin >> x >> y; int sum = atoi(x.c_str()) + atoi(y.c_str()); int p = 0, now = 1; for (; sum; sum /= 10) { if (sum % 10 != 0) { p += (sum % 10) * now; now *= 10; } } x.erase(remove(x.begin()...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const long double PI = 4 * atan((long double)1); long long power(long long a, long long n) { long long res = 1; while (n) { if (n % 2) res *= a; a *= a; n /= 2; } return res; } string bits(long long int ...
#include <bits/stdc++.h> using namespace std; int main() { fixed(cout); cout << setprecision(10); ; long long int n, h; cin >> n >> h; for (int i = 1; i <= n - 1; i++) { double x = (h * h * i) / double(n); x = sqrt(x); if (i == n) break; cout << x << ; } co...
#include <bits/stdc++.h> using namespace std; int n, m, p, len; int pos[500020]; int Left[500020]; int Right[500020]; string str; void Work() { int t = p; char op; int rt; for (int i = 0; i < m; i++) { cin >> op; if (op == L ) p = Left[p]; else if (op == R ) ...
#include <bits/stdc++.h> using namespace std; const unsigned long long hash1 = 201326611; const int inf = 0x3f3f3f3f; const int _inf = 0xc0c0c0c0; const long long INF = 0x3f3f3f3f3f3f3f3f; const long long _INF = 0xc0c0c0c0c0c0c0c0; const long long mod = (int)1e9 + 7; long long gcd(long long a, long long...
#include <bits/stdc++.h> using namespace std; const double PI = acos(double(-1)); const double INF = 1e10; const double EPS = 1e-8; inline double sqr(double x) { return x * x; } struct PT { double x, y; PT() {} PT(double x, double y) : x(x), y(y) {} void in() { double _x, _y; sca...
#include <bits/stdc++.h> using namespace std; int n, m, a[105]; int main() { int s = 0, t = 0; ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (int i = 0; i < n; i++) { if (s >= m) break; else { ...
#include<bits/stdc++.h> using namespace std; #define ll long long ll gcd(ll a, ll b){ return b?gcd(b,a%b):a; } ll a[200005],b[200005],c,d; int main(){ ll n,m; scanf( %lld%lld ,&n,&m); ll d=0; cin>>a[1]; for(ll i=2;i<=n;i++){ //从a[2]-a[1]开始 scanf( %lld ,&a[i]); d=gcd(d,a[i]-a[...
#include <bits/stdc++.h> int a[100006]; int vis[100006]; int visyu[100006]; int main() { int n, x; scanf( %d%d , &n, &x); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); vis[a[i]]++; if (vis[a[i]] == 2) { printf( 0 n ); return 0; } } int mans = -1; ...
#include <bits/stdc++.h> using namespace std; const int N = 2e6; int cost[N], n, a, b, T; string s; long long l[N], r[N]; bool check(int d) { --d; long long bst = min(l[d], r[d]); for (int i = 1; i < d; ++i) { bst = min(bst, l[i] + r[d - i] + a * i); bst = min(bst, r[i] + l[d - 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...
module BRAMInterconnect(rddata_bo,s1_addr_bo,s1_wrdata_bo,s1_en_o,s1_we_bo,s2_addr_bo,s2_wrdata_bo,s2_en_o,s2_we_bo,s3_addr_bo,s3_wrdata_bo,s3_en_o,s3_we_bo,addr_bi,clk_i,wrdata_bi,en_i,rst_i,we_bi,s1_rddata_bi,s2_rddata_bi,s3_rddata_bi); output [31:0] rddata_bo; output [12:0] s1_addr_bo; output [31:0] s1_wrdata_bo; ou...
#include <bits/stdc++.h> using namespace std; int32_t main() { long long int n; std::cin >> n; long long int ans[n]; for (long long int i = 0; i < n; i++) { std::cin >> ans[i]; } long long int count[n]; memset(count, 0, sizeof(count)); for (long long int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T x, T y) { if (x < y) swap(x, y); while (y > 0) { T f = x % y; x = y; y = f; } return x; } template <typename T> pair<T, T> exgcd(T x, T y) { int sw = 0; if (x < y) sw = true, swap(x, y); ...
/** * 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 (c) 1995/2009 Xilinx, Inc. // // 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 // //...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 23:03:36 09/24/2013 // Design Name: Comparador // Module Name: C:/Users/Fabian/Documents/GitHub/taller-diseno-digital/Lab3/laboratorio3/test_comparador.v // Project N...
//***************************************************************************** // (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 // ...
// Copyright 2020-2022 F4PGA 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed...
`ifndef _sixbitdiv_incl `define _sixbitdiv_incl `include "sixbitsub.v" module sixbitdiv (dividend, divisor, quotient, remainder, err); input[5:0] dividend; input[5:0] divisor; output[5:0] quotient; output[5:0] remainder; output err; wire[5:0] posdividend; wire[5:0] posdivisor; wire[5:0] posquotient; ...
#include <bits/stdc++.h> #pragma GCC optimize(3, Ofast , inline ) #pragma GCC target( avx,avx2 ) using namespace std; template <class t> inline t read(t &x) { char c = getchar(); bool f = 0; x = 0; while (!isdigit(c)) f |= c == - , c = getchar(); while (isdigit(c)) x = (x << 1) + (x << ...
#include <bits/stdc++.h> using namespace std; int n, arr[3], ans, a, b, c, ma, t; multiset<int> s; int main() { scanf( %d , &n); for (int i = 0; i < 3; i++) scanf( %d , arr + i); for (int i = 0; i < n; i++) { scanf( %d , &t); s.insert(t); ma = max(t, ma); } sort(arr, arr + ...
#include <bits/stdc++.h> using namespace std; int getint() { unsigned int c; int x = 0; while (((c = getchar()) - 0 ) >= 10) { if (c == - ) return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - 0 ); } while (((c = getchar()) - 0 ) < 10); return x...
#include <bits/stdc++.h> using namespace std; const int N = 2005, P = 998244353; using ll = long long; ll qpow(ll a, ll b) { ll ret = 1; while (b) { if (b & 1) ret = ret * a % P; a = a * a % P; b >>= 1; } return ret; } int n, a, b; ll pw[N * N], pw1[N * N]; ll dp[N][N],...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Xilinx // Engineer: bwiec // Create Date: Mon Jun 05 07:43:03 MDT 2015 // Design Name: dma_controller // Module Name: tlast_gen // Project Name: DMA Controller // Target Devices: A...
/** * 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 la...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 10; long long par[maxn], t[maxn], c[maxn]; const long long inf = 1000000000000ll; long long dist[maxn][maxn], dis[maxn]; bool mark[maxn]; vector<int> v[maxn], u[maxn]; set<pair<long long, int> > s; vector<long long> cost1[maxn], cos...
#include <bits/stdc++.h> using namespace std; void out() { cout.flush(); cerr << endl << OUT << endl; int bred; cin >> bred; exit(0); } void updMax(int& x, int y) { if (y > x) x = y; } int sum10(int x, int y) { x += y; if (x >= 10) x -= 10; return x; } int cs[10]; ...
#include <bits/stdc++.h> using namespace std; long long x, y, l, r; long long xx[105], yy[105]; vector<long long> ans; void readcase() { cin >> x >> y >> l >> r; xx[0] = 1; yy[0] = 1; int lena = 1; int lenb = 1; while (r / x >= xx[lena - 1]) { xx[lena] = xx[lena - 1] * x; l...
#include <bits/stdc++.h> using namespace std; bool adj[110][110]; short color[110]; bool ok = true; int n, m; void dfs(int node, int ccolor) { color[node] = ccolor; for (int i = 0; i < m; i++) { if (adj[node][i]) { if (color[i] == 0) { dfs(i, ccolor * (-1)); } else if...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int a, b, c; cin >> a >> b >> c; if (!c) return cout << (a == b ? YES : NO ), 0; if (c > 0 && b < a || c < 0 && b > a) return cout << NO , 0; cout << ((a % c + c) % c == (b % c + c) % c ? YES : NO ); re...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = n - 1; i >= 0; i--) cout << arr[i] << ; cout << endl; } return 0; }
module \$mem (RD_CLK, RD_EN, RD_ADDR, RD_DATA, WR_CLK, WR_EN, WR_ADDR, WR_DATA); parameter MEMID = ""; parameter SIZE = 256; parameter OFFSET = 0; parameter ABITS = 8; parameter WIDTH = 8; parameter signed INIT = 1'bx; parameter RD_PORTS = 1; parameter RD_CLK_ENABLE = 1'b1; parameter RD_CLK_POLARITY = 1'b1; ...
#include <bits/stdc++.h> using namespace std; int tata[2010], g[2010]; vector<pair<int, int>> edges; bitset<2001> secret[2001]; int find(int x) { return (tata[tata[x]] == tata[x] ? tata[x] : tata[x] = find(tata[x])); } void unite(int a, int b) { a = find(a); b = find(b); assert(a != b); ...
#include <bits/stdc++.h> using namespace std; using lld = int64_t; struct PT { lld x, y; PT() : x(0), y(0) {} PT(lld a, lld b) : x(a), y(b) {} PT operator-(const PT& a) const { return PT(x - a.x, y - a.y); } }; lld dot(const PT& a, const PT& b) { return a.x * b.x + a.y * b.y; } lld cross(con...
#include <bits/stdc++.h> using namespace std; struct item_t { int cost; int gain; int when; bool operator<(const item_t& other) const { return when < other.when; } bool operator<(const int t) const { return when < t; } } item[4000]; bool operator<(int v, const item_t& item) { return v < item...
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const double EPS = 1e-9; int ar[] = {1, -1, 0, 0, 1, 1, -1, -1}; int ac[] = {0, 0, 1, -1, 1, -1, 1, -1}; int p[200005]; int q[200005]; void solve1(int n) { int k = 1; if (n & 1) { cout << NO n ; return; ...
#include <bits/stdc++.h> using namespace std; int n, k, x, m, s; vector<int> f, t, f1; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (int i = 0; i < n; i++) { cin >> x >> m; f.push_back(x); t.push_back(m); } for (int i = 0; i < n; i++) { if ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n; int p[N]; pair<int, int> v[N]; void solve(int nx, int nnx) { int curr = 1; for (int i = 1; i <= n; i++) p[i] = 0; p[curr] = nx; p[nx] = nnx; curr = nx; bool okay = true; for (int i = 2; i <= n; i++) { ...