text
stringlengths
59
71.4k
/* Copyright (c) 2015-2017 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, distri...
#include <bits/stdc++.h> using namespace std; vector<int> final; void seive(int n) { vector<bool> prime(n + 1, true); prime[0] = false; prime[1] = false; for (long long int i = 2; i <= (long long int)sqrt(n); ++i) { if (prime[i]) { for (int j = i * i; j <= n; j += i) prime[j] = false...
#include <bits/stdc++.h> using ll = long long; int n, q; namespace BIT { int seg[100005]; inline void modify(int pos, int val) { for (; pos <= n; pos += pos & -pos) seg[pos] += val; } inline int query(int pos) { int res = 0; for (; pos; pos -= pos & -pos) res += seg[pos]; return res; } ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000100; const long long MOD = 1e9 + 7; int N, M; string P; int y[MAXN], fail[MAXN]; bool good[MAXN]; int main() { ios_base::sync_with_stdio(0); cin >> N >> M >> P; for (int i = 0; i < M; i++) { cin >> y[i]; y[i]--; ...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); int i, n, e; double x1, y1, x2, y2, vmax, t, vx, vy, wx, wy; cin >> x1 >> y1 >> x2 >> y2; cin >> vmax >> t; cin >> vx >> vy; cin >> wx >> wy; double sid; double l = 0.0, r = (double)1e9; double eps = 1e-7;...
#include <bits/stdc++.h> using namespace std; const long long maxn = 2000005; const long long mod = 998244353; long long n, ans, cn[maxn], pow3[maxn], pow1m[maxn]; void exgcd(long long a, long long b, long long &x, long long &y) { if (!b) { x = 1, y = 0; } else { exgcd(b, a % b, y, x); ...
/* Copyright (c) 2014-2018 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, distri...
// (C) 2001-2016 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; const long long int mxn = 1e5 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t = 1; while (t--) { long long int i, j, k, n, m; cin >> n; map<long long int, long long int> mp, diff; for (i = 0; i...
#include <bits/stdc++.h> using namespace std; int a[200005], f[200005], t[2000006], mx, mxbr; bool bio[2000006], p[2000006]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; p[a[i]] = 1; mxbr = max(mxbr, a[i]); } for (int i = 2; i <= 2 * mxbr; i++) ...
#include <bits/stdc++.h> const double PI = acos(-1.0); const double e = exp(1.0); const int INF = 0x7fffffff; ; template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <class T> inline T Min(T a, T b) ...
/** * 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 t; int n, k; int siz[100086]; int c, x; int id[100086]; int mx; char s[100086]; inline int get(int l, int r) { printf( ? %d , r - l + 1), fflush(stdout); for (int i = l; i <= r; i++) printf( %d , i), fflush(stdout); puts( ); fflush(st...
// (C) 2001-2013 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...
(************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *) (* \VV/ **************************************************************) (* // * Th...
/************************************************************************* * This file is part of Stierlitz: * * https://github.com/asciilifeform/Stierlitz * *************************************************************************/ /**************...
#include <bits/stdc++.h> const int maxn = 105; int a[maxn]; inline int max(int a, int b) { return a > b ? a : b; } int main() { int n, ans = 0, temp; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); if (n < 3 || n % 2 == 0) puts( -1 ); else { for (int i = (n - 1)...
#include <bits/stdc++.h> const int MAXN = 2e5 + 5; int n, a[MAXN]; long long sm[MAXN]; int ans = 0; int pc[MAXN]; inline bool check(int l, int r) { return (a[l] ^ a[r]) == sm[r - 1] - sm[l]; } int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , a + i), sm[i] = sm[i - 1] + a[i]; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 5; int a[N], b[N]; long long check(long long x, int n, int c) { long long ans = 0; for (int i = 1; i <= n; ++i) { ans += x * a[i] / b[i] + 1; if (ans > c) ans = c + 1; } return ans; } int main() { int n, c; ...
//date:2016/3/12 //engineer:ZhaiShaoMin //module name :excution stage of core module core_ex(//input alusrc_a, alusrc_b, aluop, // inst_lo, regdst, alusrc, id_ex_rs, id_ex_rt,...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, a, b, c, d; cin >> t; while (t--) { cin >> n >> a >> b >> c >> d; int diff = n * (a - b), sum = n * (a + b); if ((diff > c + d) || (sum < c - d)) cout << No << endl; else cout << Yes << endl;...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; long long M[maxn << 2], tag[maxn << 2]; void gather(int p) { M[p] = max(M[p << 1], M[p << 1 | 1]); } void push(int p) { if (tag[p]) { tag[p << 1] += tag[p]; tag[p << 1 | 1] += tag[p]; M[p << 1] += tag[p]; M[p ...
//----------------------------------------------------------------------------- // Jonathan Westhues, March 2006 // iZsh <izsh at fail0verflow.com>, June 2014 //----------------------------------------------------------------------------- `include "lo_read.v" `include "lo_passthru.v" `include "lo_edge_detect.v" `inclu...
// $Revision: #70 $$Date: 2002/10/19 $$Author: wsnyder $ -*- Verilog -*- //==================================================================== module CmpEng (/*AUTOARG*/ // Inputs clk, reset_l ); input clk; input reset_l; // *******...
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; const double sn = 1e-9; const long double PI = 3.141592653589793238L; int n, c, d; int mc[100005]; int md[100005]; vector<pair<int, int>> ac; vector<pair<int, int>> ad; bool cmp(pair<int, int> p1, pair<int, int> p2) { return p...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int *arr = new int[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int j, k; for (int i = 0; i < n; i++) { if...
#include <bits/stdc++.h> using namespace std; long long int pi = 10000000; vector<long long int> prime(pi), pri; void seive() { long long int i, j, k, l; for (i = 4; i <= pi; i += 2) prime[i] = 1; pri.push_back(2); for (i = 3; i <= pi; i += 2) { if (prime[i] == 0) pri.push_back(i); f...
#include <bits/stdc++.h> using namespace std; inline int Getlen(int x) { int res = 0; while (x) { res++; x /= 10; } return res; } int PP[5]; int a[51], len[51], n, p; int id[51]; int res[51], tot; inline void dfs(int now, int Gmod, int Gxor) { if (Gmod == 0 && Gxor == 0 &...
//---------------------------------------------------------------------------- // // COPYRIGHT (C) 2011, VIPcore Group, Fudan University // // THIS FILE MAY NOT BE MODIFIED OR REDISTRIBUT...
#include <bits/stdc++.h> using namespace std; const int INF = 1e8 + 1; vector<vector<int> > adj; vector<bool> visited; int contadorNodos = 0; void DFS(int nodo) { contadorNodos++; for (auto it : adj[nodo]) { DFS(it); } } void letras(string &s) { for (int i = 0; i < s.size(); i++) {...
// DGS 3/2/2018 // // Async 1 read-port and 1 write port ram. // `define bsg_mem_1r1w_macro(bits,words) \ if (els_p == words && width_p == bits) \ begin: macro \ saed90_``bits``x``words``_2P_ASYNC mem \ (.CE1 (w_clk_i) \ ,.OEB1 (1'b...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; vector<int> g[N]; int c[N], val[N], ans[N]; void merge(vector<int> &vc, vector<int> &tmp) { for (auto u : tmp) vc.push_back(u); } vector<int> dfs(int u) { vector<int> vc, tmp; for (auto v : g[u]) { tmp = dfs(v); ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 00:18:54 03/22/2015 // Design Name: inverter // Module Name: C:/Users/Joseph/Documents/Xilinx/HW1/gate_test.v // Project Name: HW1 // Target Device: // ...
`timescale 1 ns / 1 ps module axis_bram_writer # ( parameter integer AXIS_TDATA_WIDTH = 32, parameter integer BRAM_DATA_WIDTH = 32, parameter integer BRAM_ADDR_WIDTH = 10 ) ( // System signals input wire aclk, input wire aresetn, output wire [BRAM_ADDR_WI...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; cin >> s; int n = s.size(); vector<int> seq(n + 1, 0); vector<int> ind; for (int i = 1; i <= n; i++) { if (s[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 la...
#include <bits/stdc++.h> const int P = 29; using namespace std; inline int read() { int x = 0, f = 1; char 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(); ...
#include <bits/stdc++.h> using namespace std; long long int powr(long long int a, long long int b) { long long int res = 1; while (b) { if (b % 2) res = (a * res) % 1000000007; a = (a * a) % 1000000007; b /= 2; } return res; } void extentded_eucledian(long long int a, long long...
#include <bits/stdc++.h> using namespace std; long long mul(long long a, long long b, long long M) { return a * b % M; } long long add(long long a, long long b, long long M) { return (a + b) % M; } vector<vector<long long> > eye(int n) { vector<vector<long long> > I(n, vector<long long>(n)); for (int i ...
#include <bits/stdc++.h> using namespace std; int n; vector<pair<int, int> > white, black; int main() { cin >> n; for (int i = 0; i < n; i++) { int c, s; cin >> c >> s; if (c) { black.push_back(make_pair(s, i + 1)); } else { white.push_back(make_pair(s, i + 1)); ...
#include <bits/stdc++.h> using namespace std; int n; long long a[1010]; long long ans; long long vis[1010]; map<long long, long long> mp; void dfs(long long x, long long y, long long cnt) { ans = max(cnt, ans); if (mp[x + y]) { mp[x + y]--; dfs(y, x + y, cnt + 1); mp[x + y]++; ...
#include <bits/stdc++.h> using namespace std; const int N = 2 * 1000 * 100 + 100; int n, m, w[N], deg[N], ans[N]; vector<pair<int, int>> adj[N]; bool vis[N]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> w[i]; 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; const int maxn = 2000 + 50; int n, cnt[maxn], a[maxn]; vector<int> q; int main() { cin >> n; int sign = 0; for (int i = 1; i < n; i++) { int x, y; cin >> x >> y; if (x > y) swap(x, y); if (y != n) sign = 1; cnt[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; int main() { long long i, n, c = 1; cin >> n; char s[n + 2]; vector<long long> d(n + 1); cin >> (s + 1); for (i = 1; i <= n; ++i) { cin >> d[i]; } for (i = 1;;) { if (s[i] == > ) i += d[i]; else i -= d[i...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: sctag_sig_rptr.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...
// /** // * This Verilog HDL file is used for simulation and synthesis in // * the chaining DMA design example. It contains the descriptor header // * table registers which get programmed by the software application. // */ // synthesis translate_off `include "altpcierd_dma_dt_cst_sim.v" `timescale 1ns / 1ps // synt...
`default_nettype none module nkmd_uart( input wire clk, input wire rst, input wire rx, output wire tx, input wire [31:0] data_i, output wire [31:0] data_o, input wire [31:0] addr_i, input wire we_i); wire [7:0] uart_data_o; wire uart_ack_o; wire [7:0] uart_data_i; wire uart_ack_i; wi...
/**************************************************************************** * 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 ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2013. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; // Take CRC data and apply to testblock inputs w...
#include <bits/stdc++.h> using namespace std; const int N = 11; const int B = 1 << 10; long long dp[B][B][N]; bool can[N][N]; vector<int> v[N + 1]; int countBits(int n) { int res = 0; while (n) { res += n % 2; n >>= 1; } return res; } bool bit(int n, int pos) { return n & (...
#include <bits/stdc++.h> using i64 = long long; int n; std::vector<std::vector<int>> g; std::vector<int> sz, d; int dfs(int v, int p) { return sz[v] = std::accumulate(g[v].begin(), g[v].end(), 1, [=](int s, int c) { return s + (d[c] >= 0 || c == p ? 0 : dfs(c, v)); ...
#include <bits/stdc++.h> using namespace std; int kval(int a) { if (a == 0) return 10; int kvala = a; if (kvala % 10) kvala = 10 + ((kvala / 10) * 10) - kvala; else kvala = 0; return kvala; } int compare(int a, int b) { if (kval(a) >= kval(b)) return 0; else r...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; string a; cin >> a; string b; cin >> b; string c = a; int flag = 0; int count = 0; vector<int> ans; int s = 1; int e = n; ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( -O2 ) using namespace std; const long long N = 500000 + 10; const long long MOD = 1000000000 + 7; const long long INF = 100000000000000010; const long long LOG = 25; long long dp[N], n, a[...
#include <bits/stdc++.h> struct Point { int x, y; Point* next; bool operator<(const Point& p) const { return 1ll * p.x * y < 1ll * x * p.y; } } P[200010], *np = P; std::map<long long, Point*> fir; std::map<Point, int> M; int main() { int q, s = 0; scanf( %d , &q); while (q--) { i...
#include <bits/stdc++.h> using namespace std; int g2[1002][1002]; int main() { int n, m; cin >> n >> m; for (int i = n; i <= m; i++) { int ind = 0; string s = to_string(i); string m = s; sort(s.begin(), s.end()); for (int p = 1; p < s.size(); p++) if (s[p] == s[p ...
/** * 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() { long long int n, k, i, j; cin >> n >> k; long long int x = 1; long long int ans = n - 1; for (i = 0; i < k; i++) { vector<long long int> v; long long int m; cin >> m; long long int t = -1; for (j = 0; j < m;...
/* * 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 maxn = 105; map<string, int> H1[maxn], H2[maxn]; vector<char> ans; char getA(string a, string b) { int c[30]; for (int i = 0; i < 26; i++) c[i] = 0; for (int i = 0; i < a.size(); i++) c[a[i] - a ]++; for (int i = 0; i < b.size(); i++) c[...
/** * 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; bool deb_mode = 0; class debugger { vector<string> vars; public: template <typename T> debugger &operator,(const T v) { stringstream ss; ss << v, vars.push_back(ss.str()); return *this; } void printall() { int j = 0, l...
/** * 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; long long x[1000006] = {}, y[1000006] = {}, a[1000006] = {}, b[1000006] = {}, x2[1000006][3], y2[1000006][3]; long long dfs(int i, long long xx, long long yy, long long px[4][2]) { int k = i % 4; for (int jj = 0; jj < k - 1; jj++) { if (xx ==...
#include <bits/stdc++.h> using namespace std; int AR[1000000 + 7]; int main() { int cnt = 0, k; string s; cin >> k >> s; AR[0] = 1; int64_t r = 0; for (int i = 0; s[i] != 0 ; i++) { if (s[i] == 1 ) cnt++; if (cnt >= k) r += AR[cnt - k]; AR[cnt]++; } printf( %I6...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; cout << a * b / 2 << endl; }
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, m; cin >> n; long long int ans = ((n % 10) - 1) * 10; m = 1; while (n > 0) { ans += (m); m++; n /= 10; } cout << ans << n ; } int main() { ios_base::sync_with_stdio(false); cin.t...
#include <bits/stdc++.h> using namespace std; template <typename T, typename V> ostream &operator<<(ostream &out, const pair<T, V> x) { out << { << x.first << : << x.second << } ; return out; } template <typename T> ostream &operator<<(ostream &out, const set<T> x) { for (auto &it : x) { ...
#include <bits/stdc++.h> using namespace std; int T, ans; int dfs(vector<int> G[], int node, bool visit[], int k, bool first) { if (!visit[node]) { visit[node] = true; int counti = 0; for (auto it : G[node]) { if (!visit[it]) counti += dfs(G, it, visit, k, false); } ans +...
#include <bits/stdc++.h> using namespace std; constexpr int INF = 2e9; int main() { int t; t = 1; while (t--) { int n; string s; cin >> n; cin >> s; int res = 0; for (int d = 25; d >= 0; d--) { string tmp = ; for (int i = 0; i < s.size(); i++) { ...
#include <bits/stdc++.h> using namespace std; string Levelcheck(vector<vector<int> > vec) { int n; n = vec.size(); if (vec[0][0] < vec[0][1]) { return NO ; } for (int i = 1; i < n; i++) { if (vec[i][0] < vec[i][1]) { return NO ; } if (vec[i][0] < vec[i - 1][0]) ...
#include <bits/stdc++.h> using namespace std; const int N = 1000010, mod = 1e9 + 7, INF = 0x3f3f3f3f; const double eps = 1e-6; int n, m; int id[N]; vector<int> v[N]; bool st[N]; bool check() { int cnt = 0; for (int i = 1; i <= n; i++) if (!id[i]) { cnt++; id[i] = cnt; ...
#include <bits/stdc++.h> using namespace std; void solve() { long long int a, b, c; cin >> a >> b >> c; long long int x = min(a, min(b, c)); long long int z = max(a, max(b, c)); long long int y = a + b + c - x - z; long long int xi = a == x ? 1 : b == x ? 2 : 3; long long int yi = a == y...
#include <bits/stdc++.h> using namespace std; const int N = 1005; const int inf = 1000 * 1000 * 1000; const int mod = 1000 * 1000 * 1000 + 7; mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count()); int n, s, d; bitset<N> a[(1 << 20) + 2]; bitset<N> b[(1 << 10) + 2]; bitset<N> mas[33]; ...
/* * 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...
// // dsk.v -- parallel ATA (IDE) disk interface // module dsk(clk, reset, en, wr, addr, data_in, data_out, wt, irq, ata_d, ata_a, ata_cs0_n, ata_cs1_n, ata_dior_n, ata_diow_n, ata_intrq, ata_dmarq, ata_dmack_n, ata_iordy); // internal interface si...
`timescale 1 ps / 1 ps module alt_mem_ddrx_input_if #(parameter CFG_LOCAL_DATA_WIDTH = 64, CFG_LOCAL_ID_WIDTH = 8, CFG_LOCAL_ADDR_WIDTH = 33, CFG_LOCAL_SIZE_WIDTH = 3, CFG_MEM_IF_CHIP = 1, CFG_AFI_INTF_PHASE_NUM = 2, CFG_CTL_ARBITER_TYPE = "ROWCOL" ) (...
//Legal Notice: (C)2010 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 (c) Mercury Federal Systems, Inc., Arlington VA., 2009-2010 * * Mercury Federal Systems, Incorporated * 1901 South Bell Street * Suite 402 * Arlington, Virginia 22202 * United States of America * Telephone * FAX * * This file is part of OpenCPI (www.opencpi.org). * ...
#include <bits/stdc++.h> using namespace std; const int N = 107; const long long mod = 1e9 + 7; const int rx[8] = {1, -1, 0, 0, 1, 1, -1, -1}; const int ry[8] = {0, 0, 1, -1, 1, -1, 1, -1}; const long double pi = acos(-1.0); const int B = (int)sqrt(N); int d[16 / 2][2 * 4]; int main() { ios_base::...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define fill0(a) memset(a,0,sizeof(a)) #define fill1(a) memset(a,-1,sizeof(a)) #define fillbig(a) memset(a,63,sizeof(a)) #define pb push_back #define ppb pop_back #define mp make_pair #define mt make_tuple #define epr...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
/* * 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...
//----------------------------------------------------------------------------- // qmfir_0_wrapper.v //----------------------------------------------------------------------------- (* x_core_info = "qmfir_v1_00_a" *) module qmfir_0_wrapper ( SPLB_Clk, SPLB_Rst, PLB_ABus, PLB_UABus, PLB_PAValid,...
/** * @module EX_MEM * @author sabertazimi * @email * @brief EX_MEM pipeline register * @input clk clock signal * @input rst reset signal * @input en load enable signal * @input EX_PC PC value in EX stage * @input EX_IR instruction value in EX stage * @input EX_writetolo writetolo signal in EX stage * @inpu...
#include <bits/stdc++.h> using namespace std; int read() { char c = getchar(); int d = 0, f = 1; for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) f = -1; for (; c >= 0 && c <= 9 ; d = d * 10 + c - 48, c = getchar()) ; return d * f; } const int mod = 1e9 + 7; const int...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> a(n, 0); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); int s = 0, cnt = 0; for (int i = 0; i < n; i++) { if (m == 0) break; if (a[i] < 0) { s += abs(a[...
/* -- ============================================================================ -- FILE NAME : clk_gen.v -- DESCRIPTION : ƒNƒƒbƒN¶¬ƒ‚ƒWƒ…[ƒ‹ -- ---------------------------------------------------------------------------- -- Revision Date Coding_by Comment -- 1.0.0 2011/06/27 suito V‹Kì¬ -- =...
//Legal Notice: (C)2016 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 associate...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n1 = 0; int n2 = 0; int n4 = 0; int n8 = 0; int n16 = 0; int n32 = 0; int n64 = 0; int n128 = 0; int n256 = 0; int n512 = 0; int n1024 = 0; ...
#include <bits/stdc++.h> using namespace std; template <typename T> inline T abs(T t) { return t < 0 ? -t : t; } const long long modn = 1000000007; inline long long mod(long long x) { return x % modn; } const int MAXN = 100010; int n, s[MAXN]; int main() { scanf( %d , &n); printf( %d , n /...
/** * 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> const double PI = acos(-1); using namespace std; template <class T> ostream& operator<<(ostream& out, vector<T> v) { out << v.size() << n ; for (auto e : v) out << e << n ; return out; } struct point { long long x, y; point() {} point(const point& a) { x ...
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; int f[maxn], n; struct struc { long long a[maxn]; int go[19][maxn], nxt[maxn]; void build(int ty = 0) { if (!ty) { for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); for (int i = n; i; i--) a[i] += a[i + 1];...
#include <bits/stdc++.h> using namespace std; int main() { int x, a, b = 0; cin >> x; for (int i = 1; i <= x; i++) { int k = 1; while (i * k <= x) { if (i * i * k > x && k < x) { a = i * k; b = i; break; } else k = k + 1; } } ...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int N = 700, COLOR = 3; int n; char s[N + 1]; int mch[N + 1]; int dp[N + 2][N + 1][COLOR][COLOR]; int main() { scanf( %s , s + 1); n = strlen(s + 1); stack<int> stk; for (int i = 1; i <= n; i++) if (s[i...
#include <bits/stdc++.h> using namespace std; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << ; cout << endl; } template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() ...
//Blitter barrel shifter //This module can shift 0-15 positions to the right (normal mode) or to the left (descending mode). //Multipliers are used to save logic. module agnus_blitter_barrelshifter ( input desc, // select descending mode (shift to the left) input [3:0] shift, // shift value (0 to 15) input [15:...