text
stringlengths
59
71.4k
module relay_encode( clk, reset, mode, data_in, data_out ); input clk, reset, mode, data_in; output data_out; reg [0:0] data_out = 1'b0; reg [7:0] buffer_in = 8'b0; reg [7:0] data_out_counter = 8'b0; reg [6:0] data_out_delay_counter = 7'b0; reg [2:0] bit_counter = 3'b0...
#include <bits/stdc++.h> using namespace std; string slv(string s) { int sz = s.size(); if (sz % 2 == 1) return s; else { string a = slv(s.substr(0, sz / 2)); string b = slv(s.substr(sz / 2, sz)); return a < b ? a + b : b + a; } } int main() { string a, b; cin >> ...
//////////////////////////////////////////////////////////////////////////////// // // Filename: memops.v // // Project: Zip CPU -- a small, lightweight, RISC CPU soft core // // Purpose: A memory unit to support a CPU. // // In the interests of code simplicity, this memory operator is // susceptible to unknown result...
/** * 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...
/** * bsg_mesh_router.v * * * dims_p network * ------------------------ * 1 1-D mesh * 2 2-D mesh * 3 2-D mesh + half ruche x * 4 2-D mesh + full ruche * * ruche_factor_X/Y_p determines the number of hops that ruche links extend in the di...
/* * These source files contain a hardware description of a network * automatically generated by CONNECT (CONfigurable NEtwork Creation Tool). * * This product includes a hardware design developed by Carnegie Mellon * University. * * Copyright (c) 2012 by Michael K. Papamichael, Carnegie Mellon University * * ...
// *************************************************************************** // *************************************************************************** // 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 M = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; int a[n + 1]; for (int i = 0; i < n; i++) cin >> a[i]; map<int, int> mp; if (n ...
/* A simplistic test for OBUFDS. Two of them are instanciated and their outpus are connected to LEDs. Data inputs are controlled by switches. Truth tables: SW8 | LED3 LED2 0 | 1 0 1 | 0 1 SW10 | LED8 LED7 0 | 0 1 0 | 1 0 Couldn't use all switches and buttons at the same time as the diff...
#include <bits/stdc++.h> using namespace std; const int N = 500000; int n, m; vector<int> nei[N + 1]; bool vis[N + 1]; int fa[N + 1], dep[N + 1]; void dfs(int x = 1) { vis[x] = true; for (int i = 0; i < nei[x].size(); i++) { int y = nei[x][i]; if (vis[y]) continue; fa[y] = 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 law...
// ---------------------------------------------------------------------- // Copyright (c) 2015, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
/** * 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 f(int k, int n) { int s = k; while (k > 0) { s += k % 10; k /= 10; } return s == n; } int main() { int i, n; vector<int> ans; cin >> n; for (i = n - 100; i <= n + 100; ++i) { if (f(i, n)) { ans.push_back...
#include <bits/stdc++.h> using namespace std; int n; double ans[1024 * 1024], l, r, x[20], y[20], a[20], cosA[20], sinA[20], maxi; int main() { scanf( %d %lf %lf , &n, &l, &r); maxi = l; for (int i = 0; i < n; i++) { scanf( %lf %lf %lf , &x[i], &y[i], &a[i]); cosA[i] = cos(a[i] * 3.14159...
#include <bits/stdc++.h> using namespace std; const int INIT_SIZE_MAX = (1 << 29) + 10; const int INIT_SIZE_MIN = -(1 << 29) - 10; const int INIT_SIZE = 0; const int MAX = 8; const int DIR_SIZE = 12; const double PI = 3.1415926535897932384; template <class T, class U> void convert(T &t, U &u) { st...
`default_nettype none `timescale 1ns / 1ps `include "ipl_config.vh" // This core aims to implement a simple, reusable Wishbone B.4 compatible // bus master. EMPHASIS ON SIMPLE -- pipelined mode can get pretty complex // if you're not careful. // // Pipelined masters and slaves are really quite simple to implement ov...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 * 1000 + 7, MAX_LOG = 20; int n, m; vector<int> adj[MAXN]; bool isPassed[MAXN]; int par[MAXN][MAX_LOG], cycleCnt[MAXN], h[MAXN]; void pre(int root) { isPassed[root] = true; for (auto nei : adj[root]) { if (!isPassed[nei]) { ...
#include <bits/stdc++.h> using namespace std; int dp[505][505], dp2[505]; void solve() { int n; cin >> n; vector<int> a(n); for (auto &i : a) cin >> i; memset(dp, 0, sizeof(dp)); for (int i = 0; i < n; i++) dp[i][i] = a[i]; for (int i = 1; i < n; i++) { for (int j = i - 1; j >= 0...
#include <bits/stdc++.h> using namespace std; int n, m = 1; vector<vector<int> > edge(105); int from[105]; int to[105]; bool bfs(int a, int b) { int use[105] = {0}; queue<int> q; q.push(a); use[a] = 1; while (!q.empty()) { int cur = q.front(); q.pop(); for (int 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 law...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return x * f; } const int MAXN = 200010; const int INF = 1e9; con...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (!(n & 1)) cout << -1 << endl; else { for (int i = 0; i < n; i++) cout << i << ; cout << endl; for (int i = 0; i < n; i++) cout << i << ; cout << endl; for (int i = 0; i < n; i++)...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0; char zf = 1; char ch = getchar(); while (ch != - && !isdigit(ch)) ch = getchar(); if (ch == - ) zf = -1, ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return x * zf; ...
`default_nettype none module module_scope_Example(o1, o2); parameter [31:0] v1 = 10; parameter [31:0] v2 = 20; output [31:0] o1, o2; assign module_scope_Example.o1 = module_scope_Example.v1; assign module_scope_Example.o2 = module_scope_Example.v2; endmodule module module_scope_ExampleLong(o1, o2); ...
#include <bits/stdc++.h> using namespace std; char in[100000 + 1]; int main() { vector<array<int, 4> > cur, nex; cur.push_back(array<int, 4>{{}}); int n; scanf( %d , &n); scanf( %s , in); for (int i = 0; i < n; i++) { int p = -1; switch (in[i]) { case G : p =...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s, k; cin >> s; map<string, int> m; for (int i = 0; i < s.size() - 9; i++) { if (s[i] != - && s[i + 1] != - && s[i + 2] == - && s[i + 3] != - && s[i...
//----------------------------------------------------------------------------- // The FPGA is responsible for interfacing between the A/D, the coil drivers, // and the ARM. In the low-frequency modes it passes the data straight // through, so that the ARM gets raw A/D samples over the SSP. In the high- // frequency mo...
// file: Clock70HMz_tb.v // // (c) Copyright 2008 - 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 // laws. // // DISCLAIMER // This disclaimer is no...
#include <bits/stdc++.h> using namespace std; int N, V, M; int Size[310], Final[310], T[310]; vector<int> G[310]; vector<pair<pair<int, int>, int> > ANS; int source, sink, flow; void FindSource(int node) { if (Size[node] > Final[node]) { source = node; return; } for (vector<int>::i...
#include <bits/stdc++.h> using namespace std; const int N = 5050; const int inf = 0x37373737; int L[N], R[N], size[N], tot, n, i, a, b, cnt, j, k; int d[N], root; int dp[N][N]; vector<pair<int, int> > vec[N]; vector<int> e[N]; void dfs(int x, int fa) { int i, j, k; if (e[x].size() == 1) size[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 law...
`timescale 1ns/1ps module dpram_xlx #( parameter ADDRWIDTH = 4, parameter DATAWIDTH = 8, parameter [ADDRWIDTH:0] DEPTH = 16 ) ( clka, ena, wea, addra, dina, douta, clkb, enb, web, addrb, dinb, doutb ); input clka; input ena; input [0 : 0] wea; input [ADDRWIDTH-1 : 0...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t, n, i, x; cin >> t; while (t--) { cin >> n; i = n - 1; x = n; cout << 2 << endl; while (i != 0) { cout << i << ...
#include <bits/stdc++.h> using namespace std; long long f(string s, long long m) { map<char, long long> a; map<char, long long>::iterator ii; long long i; for (i = 0; i < s.size(); i++) { a[s[i]]++; } long long best = 0; for (ii = a.begin(); ii != a.end(); ii++) best = max(best, ii...
/* ------------------------------------------------------------------------------- * (C)2007 Robert Mullins * Computer Architecture Group, Computer Laboratory * University of Cambridge, UK. * ------------------------------------------------------------------------------- * * Virtual-Channel Buffers * ===========...
#include <bits/stdc++.h> using namespace std; bool comp[30000]; int P[30000]; int seive(int n, int* P) { int p, q, K = 0; comp[1] = true; char even = 1; for (p = 2; p * p <= n; p += 2) { if (!comp[p]) { for (q = p * p; q <= n; q += p * (2 - even)) comp[q] = true; } if (...
/* * 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...
// Filename: sevensegmentdecoder_assign.v // Author: Danny Dutton // Date: 03/03/15 // Version: 1 // Description: Decode 4-bit input and drive a seven segment using assignment module sevensegdecoder_always(digit, drivers); input [3:0] digit; output [6:0] drivers; // Take a to be the MSB of t...
`include "bsg_defines.v" module bsg_8b10b_shift_decoder ( input clk_i , input data_i , output logic [7:0] data_o , output logic k_o , output logic v_o , output logic frame_align_o ); // 8b10b decode running disparity and error signals wire decode_rd_r, decode_rd_n, d...
#include <bits/stdc++.h> using namespace std; int main() { char a, b; int A, B; cin >> a >> A; cin >> b >> B; int chess[9][9] = {0}; for (int i = 1; i < 9; i++) { chess[i][A] = 1; } for (int i = 1; i < 9; i++) { chess[a - 96][i] = 1; } if (b - 98 > 0) { if (...
#include <bits/stdc++.h> using namespace std; const int MAXN = 3010; const int MOD = 1000000007; int n, m; long long f[MAXN][MAXN], ans1, ans2, ans3, ans4; char a[MAXN][MAXN]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %s , a[i] + 1); if (a[1][2] == . ) f[1][2] = ...
/** * testbench.v * * mul_32 test * */ module testbench(); localparam width_p = 32; localparam ring_width_p = width_p*2; localparam rom_addr_width_p = 32; logic clk; logic reset; bsg_nonsynth_clock_gen #( .cycle_time_p(10) ) clock_gen ( .o(clk) ); bsg_nonsynth_reset_gen #( .reset_cycles_lo_p(4) ,...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const int maxm = 1e3 + 5; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; int a[maxn], ans[maxn], l[maxn][6], r[maxn][6]; inline void solve() { int n; scanf( %d , &n); for (int i = 1; i < n + 1; i++) scanf( %d , &a[i...
#include <bits/stdc++.h> const int N = 1e3 + 10; using namespace std; int a[N], b[N], c[N]; char str1[N], str2[N], str3[N]; int main() { int tc; cin >> tc; while (tc--) { long long n, k, sum{0}, suma{0}, sumb{0}; cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> a[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 law...
/* * 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...
#include <bits/stdc++.h> using namespace std; int n, k, q, x; map<int, int> M; map<int, int>::iterator it; int main() { scanf( %d %d , &n, &k); for (int i = (1); i <= (n); i++) { int a; scanf( %d , &a); for (int j = (0); j <= (k); j++) { if (!M.count(a * j)) M[a * j...
#include <bits/stdc++.h> using namespace std; int main() { int x, ans; string s; cin >> s; x = s.size(); for (int i = 1; i < x; i++) { if (s[i] == 1 ) { x++; break; } } cout << x / 2 << endl; return 0; }
/** * 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 N, M; const int MAX = 1e6; vector<int> edges[MAX]; int indeg[MAX]; vector<int> source; map<int, int> sink; int reachable[20]; const int BITMAX = 1 << 20; int dp[BITMAX]; void dfs(int start, int i) { if (sink.count(i)) { reachable[start] |...
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { ios::sync_with_stdio(false); cin.tie(nullptr); string s, t; cin >> s >> t; int ns = s.size() - 1; int nt = t.size() - 1; bool stop = true; while (stop && (ns >= 0 && nt >= 0)) { if (s[ns] != t[nt])...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:1000000000 ) static long long m1[70][70]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); m1[0][0] = 1; for (int i = 1; i <= 30; ++i) { m1[i][0] = 1; for (int j = 1; j <= 30; ++j) m1[i][j] = m1[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> using namespace std; const int maxn = 1e6 + 11; string s; bool vis[maxn]; int n; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> s; n = s.length(); vector<pair<int, int> > vec, tmp; for (int i = 0; i < n; i++) { if (vec.empty() ||...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n + 1]; vector<int> v; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] == 1) { v.push_back(1); } else { v[v.size() - 1] = max(arr[i], v[v.size() - 1]); } } ...
#include <bits/stdc++.h> using namespace std; const int N = 20005; const int M = 400005; vector<pair<int, int> > E[N]; int dep[N], fa[N][16], fav[N][16]; int n, m, S, T, nd, jud[N * 2]; int head[M], vis[M], tot = 1; int dis[M], q[M]; struct edge { int to, next, f; } e[M * 5]; void add(int x, i...
/////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2014 Francis Bruno, 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 Found...
#include <bits/stdc++.h> using namespace std; const long long inf = 2e9; const long long infll = 1e18; double eps = 0.0000001; ifstream in( input.txt ); ofstream out( output.txt ); ; long long n; vector<long long> c; vector<long long> t; void init() { cin >> n; c.resize(n); t.resize(n)...
#include <bits/stdc++.h> using namespace std; string makeCentered(int len) { string output; for (int i = 0; i < 27; i++) { output.push_back( . ); } for (int i = 0; i < len; i++) { output[13 + i] = X ; output[13 - i] = X ; } return output; } string blank() { string...
#include <bits/stdc++.h> using namespace std; const long double PI = atan(1.0) * 4.0; const long long int MOD = 1e9 + 7; const long long int INF = 1e5; const long double EPS = 0.0000001; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL); int a[1005], k; a[0] = -1; a[1] = 0; fo...
/* * 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...
/* * 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...
/** * 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...
`default_nettype none // ============================================================================ module serializer # ( parameter WIDTH = 4, // Serialization rate parameter MODE = "SDR" // "SDR" or "DDR" ) ( // Clock & reset input wire CLK, input wire RST, // Data input input wire[WIDTH-1:0] I, output wir...
#include <bits/stdc++.h> using namespace std; template <class T> T inline sqr(T x) { return x * x; } template <class T> inline void relaxMin(T &a, T b) { a = min(a, b); } template <class T> inline void relaxMax(T &a, T b) { a = max(a, b); } template <class T> inline T sign(T x) { ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:39:44 04/06/2010 // Design Name: // Module Name: path // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Re...
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; if (n <= 30) cout << NO n ; else { cout << YES n ; long long d = n - 30; long long a = 6, b = 10, c = 14; if (d == 6 || d == 10 || d == 14) cout << 6 10 15 << d - 1 << endl;...
/** * 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 + 10; map<pair<int, int>, int> weight; vector<int> edges[MAXN]; bool visited[MAXN]; long long int maximum; void dfs(int v, long long int sum) { visited[v] = true; maximum = max(maximum, sum); for (int i : edges[v]) { if (...
#include <bits/stdc++.h> using namespace std; vector<int> split(string s) { vector<int> xs; stringstream ss(s); string item; while (getline(ss, item, , )) { xs.push_back(stoi(item)); } return xs; } int main() { string s; getline(cin, s); vector<int> xxs = split(s); ...
/** * 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...
/* First construct a D-Flipflop and then reuse this in the asynchronous counter In fact this is a reuse of the dflipflop code already done in an earlier exercise NOTE the difference is that the reset signal is also part of the sensitivity list Just the name of the module is changed so that there is no conflict */ modu...
#include <bits/stdc++.h> using namespace std; int n, m, l, r, deg[100005], num; int main() { scanf( %d%d , &n, &m); for (int i = 1; i < n; i++) { scanf( %d%d , &l, &r); deg[l]++; deg[r]++; } for (int i = 1; i <= n; i++) if (deg[i] == 1) num++; printf( %.7f n , (double)2...
#include <bits/stdc++.h> using namespace std; auto main() -> int { int N, X, Y; cin >> N; vector<int> C(N); for (int i = 0; i < N; i++) cin >> C[i]; cin >> X >> Y; int l = 0; int ret = 0; for (int i = 0; i < N; i++) { if (l < X) { if (l + C[i] <= Y) l += C[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 law...
module datapath (input clk, reset, input memtoreg, pcsrc, input alusrc, regdst, input regwrite, jump, input [2:0] alucontrol, output zero, output [31:0] pc, input [31:0] instr, output [31:0] aluout, writedata, input [31:0] readdata); wire [4:0] writereg; wire [31:0] pcnext, pcnextbr, pcplus4, pcbranch; wire [31:0] sig...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. * ...
/* ---------------------------------------------------------------------------------- Copyright (c) 2013-2014 Embedded and Network Computing Lab. Open SSD Project Hanyang University All rights reserved. ---------------------------------------------------------------------------------- Redistribution and use ...
#include <iostream> #include <algorithm> #include <vector> #include <cmath> using namespace std; int main() { int t = 0; cin>>t; for(int i = 0; i < t; i++) { int n = 0; cin>>n; int v[100] = {0}; for(int j = 0; j < n; j++) cin>>v[j];...
#include <bits/stdc++.h> using namespace std; template <typename T> void join(vector<T>& arr, string sep) { bool first = true; for (auto t : arr) { if (first) { first = false; cout << t; } else { cout << sep << t; } } cout << n ; } struct Euler { ...
#include <bits/stdc++.h> using ll = long long; using namespace std; const long double PI = acos(-1); const long long M = 998244353; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); inline long long mod(long long n, long long m = M) { long long ret = n % m; if (ret < 0) ret += m; ...
/* 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,...
//----------------------------------------------------------------------------- // Title : PCI Express BFM Message Logging Include File // Project : PCI Express MegaCore function //----------------------------------------------------------------------------- // File : altpcietb_b...
#include <bits/stdc++.h> using namespace std; int main() { map<int, int> container_1; map<int, int> container_2; int n; cin >> n; for (int i = 0; i < n; ++i) { int a, b; cin >> a >> b; container_1[a] = b; container_2[a] = 0; } int k; cin >> k; for (int i =...
#include <bits/stdc++.h> using namespace std; int const N = 1e5 + 20, INF = 1e9 + 20; int n, h[N], pmx[N], pmn[N], ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 0; i < n; i++) cin >> h[i]; for (int i = 0; i < n; i++) pmx[i] = i ? max(h[i], pmx[i - 1]) : h[...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m; cin >> n >> m; long long int a[n + 1][m + 1], i, j, p = 0; for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { cin >> a[i][j]; } } for (i = ...
// DESCRIPTION: Verilator: Test symbol table scope map and general public // signal reflection // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2015 by Todd Strader. module t ( input wire CLK ); foo #(.WIDTH (1)) foo1 (.*); foo #(.WIDTH (7)) foo7 (.*); foo #...
#include <bits/stdc++.h> using namespace std; const int N = 25, mod = 1e9 + 7; int a[N][N], used[N][N], cur, first, n, m, k; long long ans; int count(int x) { int ans = 0; for (; x; x -= x & -x) ans++; return ans; } void dfs(int x, int y) { if (x == n) { int p = count(cur & ~first), ...
// (C) 2001-2015 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...
//----------------------------------------------------------------------------- // // (c) Copyright 2009-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; const int maxn = 100100; int n; long long a[maxn]; map<long long, long long> mp; long long mul(long long x, long long n) { long long ret = 1; while (n) { if (n & 1) ret *= x; x *= x; n >>= 1; } return ret; } int main() { ...
/*------------------------------------------------------------------------------ * 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...
`timescale 100ns/100ps module dummy; parameter [1:0] ipval = 2; endmodule `timescale 1us/1ns module top; parameter [1:0] ipval = 2; parameter spval = "Help"; parameter rpval = 1.0; event evt; reg [1:0] rgval; reg rgarr [2:0]; wire [1:0] wval; wire warr [2:0]; integer ival; real rval; real rarr...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2018 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 // /...
#include <bits/stdc++.h> struct vertex { long long x, y; int adj[4], k; } vv[30]; void dfs(int p, int v, long long x, long long y, long long a, int d) { int i; vv[v].x = x; vv[v].y = y; d = (d + 2) % 4; for (i = 0; i < vv[v].k; i++) if (vv[v].adj[i] != p) { long long 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...
// megafunction wizard: %RAM: 3-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: alt3pram // ============================================================ // File Name: regfile.v // Megafunction Name(s): // alt3pram // ============================================================...
//-------------------------------------------------------------------------------- // rle_enc.vhd // // Copyright (C) 2007 Jonas Diemer // // 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 Foundati...
#include <bits/stdc++.h> int main() { char jak[1000005], tak[1000005]; gets(jak); gets(tak); int k, r, i, t, flag = 0, count = 0, fount = 0, f, x, y, j, p = 0; k = strlen(jak); r = strlen(tak); for (i = 0; i < k; i++) { t = jak[i] - 48; if (t != 0 && flag == 0) { flag =...