text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int nxt() { int res; scanf( %d , &res); return res; } inline void solve() { int n = nxt(); int k = nxt(); int d = nxt(); vector<vector<int> > ans; ans.push_back(vector<int>(d, 0)); while (int(ans.size()) < n) { vector<int> q...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2014 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; // Aggregate outputs into a single...
`define RegBankP2_NOP 4'h0 `define RegBankP2_LD0 4'h1 `define RegBankP2_LD1 4'h2 `define RegBankP2_State_Reset 2'h0 `define RegBankP2_State_Ready 2'h1 `define RegBankP2_State_Error 2'h2 module RegBankP2(clock,reset,inst,inst_en,out_0,out_1); input wire clock; input wire reset; input wire [11:0...
#include <bits/stdc++.h> const long long N = 1e6 + 10; const long long mod = 1e9 + 7; const long long inf = 0x3f3f3f3f; const double eps = 1e-8; const double pi = acos(-1); using namespace std; namespace geo { long long sgn(double x) { if (fabs(x) < eps) return 0; if (x < 0) return -1; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 26.06.2017 22:42:05 // Design Name: // Module Name: flags_monitor // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> int n, cnt; char ch[100005], tmp; int main() { scanf( %d , &n); scanf( %s , ch + 1); for (int i = 1; i <= n; i++) if (ch[i] != tmp) { if (tmp != 0) { if ((tmp == o || tmp == e ) && cnt == 2) printf( %c%c , tmp, tmp); else { ...
/** * 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 task_func_test01(clk, a, b, c, x, y, z, w); input clk; input [7:0] a, b, c; output reg [7:0] x, y, z, w; function [7:0] sum_shift; input [3:0] s1, s2, s3; sum_shift = s1 + (s2 << 2) + (s3 << 4); endfunction task reset_w; w = 0; endtask task add_to; output [7:0] out; input [7:0] in; out = out + in; endtask ...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<long long int> v[2]; const long long int N = 3e5 + 5; long long int x[N]; char ch[N]; signed main() { ios ::sync_with_stdio(0), cin.tie(0), cou...
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, a[N], ans[N], cnt, x, y; bool Ok = 0; int main() { cin >> n; for (int i = 0; i <= n; i++) { cin >> a[i]; if (i) Ok |= (a[i] > 1 && a[i - 1] > 1); } if (!Ok) { cout << perfect ; } else { cout...
#include <bits/stdc++.h> using namespace std; template <typename T> T abs(T a) { return a < 0 ? -a : a; } template <typename T> T sqr(T a) { return a * a; } const int INF = (int)1e9; const long double EPS = 1e-9; const long double PI = 3.1415926535897932384626433832795; const int N = 1000;...
#include <bits/stdc++.h> using namespace std; int res[100005], sz; bool prime[100005], used[100005]; int main() { int n; cin >> n; for (int p = 2; p <= n / 2; ++p) { if (prime[p]) continue; for (int j = p; j <= n; j += p) prime[j] = 1; if (p == 2) continue; int len = 0; ...
/* Copyright (c) 2016-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...
#include <bits/stdc++.h> #pragma GCC optimize( O3 , unroll-all-loops ) #pragma GCC target( sse4.2 ) using namespace std; ifstream in; ofstream out; const long long kk = 1000; const long long ml = kk * kk; const long long mod = ml * kk + 7; const long long inf = ml * ml * ml + 7; mt19937 rng(chrono:...
#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> using namespace std; vector<pair<long long int, long long int> > points, hull; bool comp(pair<long long int, long long int> a, pair<long long int, long long int> b) { if (a.first != b.first) return a.first < b.first; return a.second < b.second; } int cross(pair<lon...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string nonz; int ans = 0; string s = ; bool zr = false; for (int i = 0; i < n; i++) { string a; cin >> a; if (a == 0 ) zr = true; string x = a; bool beauty = true; int zero ...
//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995-2010 Xilinx, Inc. All rights reserved. //////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor: Xilinx // \ \ \/ Version : ...
#include <bits/stdc++.h> int main() { int k, d, i, n, x; scanf( %d%d , &k, &d); n = k; x = d; if ((k > 1) && (d == 0)) { printf( No solution ); } else { for (i = 1; ((i < n) && (x > 0)); i++) { printf( 1 ); x--; } while (i < n) { printf( 0 ); ...
#include <bits/stdc++.h> char buf[1 << 21], *p1 = buf, *p2 = buf; inline long long read() { long long ret = 0, ff = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) ff = -ff; ch = getchar(); } while (isdigit(ch)) { ret = (ret << 3) + (ret << 1) + ch - 0 ; ch...
////////////////////////////////////////////////////////////////////// //// //// //// orpsoc-defines //// //// //// //// Top level ORPSoC defines fi...
/** * 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; map<pair<int, int>, int> id; vector<int> a[100005]; int main() { int i, j, k, n; cin >> n; cout << n - 1 << endl; int idd = 1; for (k = (1); k <= (n - 1); k++) { cin >> i >> j; a[i].push_back(j); a[j].push_back(i); id[make...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const long long INF = 1LL << 62; const long long MINF = -(1LL << 62); template <typename T> T getint() { T val = 0; char c; bool neg = false; while ((c = getchar()) && !(c >= 0 && c <= 9 )) { neg |= c == - ; ...
#include <bits/stdc++.h> using namespace std; void JIZZ(string output = ) { cout << output; exit(0); } const long double PI = 3.14159265358979323846264338327950288; const long double eps = 1e-10; const long long mod = 1e9 + 7; void solve() { string s, t; cin >> s >> t; for (int st = ...
// // usb 3.0 endpoint abstract // // Copyright (c) 2014 Marshall H. // All rights reserved. // This code is released under the terms of the simplified BSD license. // See LICENSE.TXT for details. // module usb3_ep ( input wire slow_clk, input wire local_clk, input wire rd_clk, input wire wr_clk, input wire...
//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...
module sing( input [11:0] PTX, input [11:0] PTY, input [11:0] P1X, input [11:0] P1Y, input [11:0] P2X, input [11:0] P2Y, output sin ); wire signed [11:0] Sub1; wire signed [11:0] Sub2; wire signed [11:0] Sub3; wire signed [11:0] Sub4; wire signed [22:0] Sub5; w...
#include <bits/stdc++.h> using namespace std; int n; int a[200009], b[200009]; bool k[200009]; int mx; int main() { scanf( %d , &n); for (int j = 1; j <= n; j++) scanf( %d , &a[j]); for (int j = 1; j <= n; j++) scanf( %d , &b[j]); for (int j = 1; j <= n; j++) k[a[j]] = 1; if (!k[1]) { ...
#include <bits/stdc++.h> using namespace std; int main() { string s, l, r; cin >> s; long long a, b, n; cin >> a >> b; n = s.size(); long long ar[n]; long long br[n]; ar[n - 1] = -1; br[0] = -1; ar[0] = (s[0] - 0 ) % a; br[n - 1] = (s[n - 1] - 0 ) % b; for (int i = ...
#include <bits/stdc++.h> using namespace std; int main() { int data[100]; int n, x, y; cin >> n >> x >> y; int c = 0; for (int i = 0; i < n; i++) { cin >> data[i]; if (data[i] <= x) c++; } if (x > y) { cout << n; } else { if (c % 2 == 0) { cout << c / ...
#include <bits/stdc++.h> using namespace std; struct point { double x, y; }; double dist(point P, point Q) { double dx = P.x - Q.x, dy = P.y - Q.y; return sqrt(dx * dx + dy * dy); } vector<point> crossing(point O1, double r1, point O2, double r2) { double d = dist(O1, O2); double t = (d ...
/** * 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(false); cin.tie(0); cout.tie(0); int q; cin >> q; while (q--) { long long pos; cin >> pos; if (pos == 1) { cout << 1 << endl; continue; } long long total = 0; ...
// (c) Copyright 1995-2017 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 not a license and does not grant ...
/* * 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 2014 - 2017 (c) Analog Devices, Inc. All rights reserved. // // In this HDL repository, there are many different and unique modules, consisting // of...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2016 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> using namespace std; using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); double startTime; double gct() { return ((double)clock() - startTime) / CLOCKS_PER_S...
// This file has been automatically generated by goFB and should not be edited by hand // Compiler written by Hammond Pearce and available at github.com/kiwih/goFB // Verilog support is EXPERIMENTAL ONLY // This file represents the Basic Function Block for InjectorMotorController //defines for state names used intern...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; vector<pair<int, int> > adj[N]; int ans[N]; int off[N]; int lvl[N], anc[N][25]; int n, a, b, k; void dfs(int u = 0, int par = 0, int l = 0) { lvl[u] = l; anc[u][0] = par; for (auto nxt : adj[u]) if (nxt.first != par) ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; template <typename T, typename U> ostream &operator<<(ostream &os, pair<T, U> p) { os << ( << p.first << , << p.second << ) ; return os; } template <typename T, typename U> istream &operator>>(istream &is, pair<T, U>...
/* Copyright (c) 2015-2016 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...
//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...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; int n, k, m; int a[1000000]; int main() { ios_base::sync_with_stdio(0); cin >> n >> k; int d = 0; if (n % 2 == 1) { d = (n / 2 + 1) * (n / 2 + 1); d += (n / 2) * (n / 2); } else { d = (n / 2) * (n /...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 20:28:25 03/19/2013 // Design Name: // Module Name: NERP_demo_top // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k, n, c = 0, p = 0, al, bl, l = 0; string s; cin >> s; for (i = 0; i < s.length(); i++) { l++; c += (s[i] - 0 ); if (c % 3 == 0 || (s[i] - 0 ) % 3 == 0 || l >= 3) { p++; c = 0; ...
#include <bits/stdc++.h> using namespace std; template <typename TH> void _dbg(const char* sdbg, TH h) { cerr << sdbg << = << h << n ; } template <typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) { while (*sdbg != , ) cerr << *sdbg++; cerr << = << h << , ; _dbg...
#include <bits/stdc++.h> using namespace std; int n, m, a, b; int tmp[33][33]; int source[33][33]; int target[33][33]; pair<int, int> prv[33][33]; bool block[33][33]; vector<pair<int, int> > R; int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; void save() { for (i...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0); string s; long long p = 0, q = 0; cin >> s; for (int i = s.size() - 1; i > -1; i--) { if (s[i] == a ) { p += q; p = p % 1000000007...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); long long ans = 0; vector<pair<int, int> > v; vector<int> all; for (int i = 1; i <= n; ++i) { int a, b, c, d; scanf( %d%d%d%d , &a, &b, &c, &d); if (a + b < c + d) { if (a > d) v.push...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; const double PI = 2.0 * acos(0.0); const int MAXN = 33; int n, m; string s; bool d1[26]; bool d2[700]; int encode(char x, char y) { return (x - a ) * 26 + (y - a ); } int main() { memset(d1, false, sizeof(...
#include <bits/stdc++.h> using namespace std; void solve() { int x, y, n; cin >> x >> y >> n; int max = (n / x) * x; if (max + y > n) { max = max - x + y; } else { max += y; } cout << max << n ; } int main() { int t; cin >> t; while (t--) solve(); return...
#include <bits/stdc++.h> using namespace std; int n; long long qp(long long x, long long y) { long long r = 1; for (; y; y >>= 1, x = x * x % 1000000007ll) if (y & 1) r = r * x % 1000000007ll; return r; } long long c[1000010]; int main() { scanf( %d , &n); for (int i = 1; i <= n; 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> const int maxx = 1000001; int x[maxx], y[maxx]; unsigned long long hash[maxx], vl[maxx], count = 0, check = 1, mul = 1; bool compare(unsigned long long a, unsigned long long b) { return a > b; } unsigned long long sum1ton(unsigned long long n) { return n * (n - 1) / 2; } int main() ...
// tests using array elements as indices/selects in an array lval select `timescale 1ns/100ps module tb; reg [7:0] a[7:0]; real r[7:0]; wire [2:0] idx[7:0]; genvar g; for (g = 0; g < 8; g=g+1) assign idx[g] = g; reg pass; integer i; initial begin pass = 1'b1; // zero everything out for (i = 0; i < 8; i ...
module mult4( a0,a1,a2,a3, b0,b1,b2,b3, z0,z1,z2,z3,z4,z5,z6,z7); input a0,a1,a2,a3,b0,b1,b2,b3; output z0,z1,z2,z3,z4,z5,z6,z7; wire x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17; assign z0 = a0&b0; //HA assign z1 = (a1&b0)^(a0&b1); assign x1 = (a1&b0)&(a0&b1); //FA assign x2 = (a1&b2)^(a0&b2)^x1; ass...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int main() { int m, n; int out; cin >> m >> n; if (m >= n && m >= 2) { out = (m / 2) * n; if (m % 2 && n / 2) { out += (n / 2); } } else if (n > m && n >= 2) { out = (n / 2) * m; if (n % 2 && m / 2) { out...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n; string str; cin >> n >> a >> b >> str; if (str[b - 1] == str[a - 1]) cout << 0 n ; else cout << 1 n ; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX = 3e5 + 5; pair<long double, int> x[MAX]; int main() { ios::sync_with_stdio(false); int n, id, k; cin >> n; for (int i = 0; i < (int)(n); i++) { cin >> x[i].first; x[i].second = i + 1; } cin >> k; sort(x, x + n);...
#include <bits/stdc++.h> using namespace std; const int N = 60 + 7; const int INF = (int)1e9; int n; int m; int q; int dp[N][N][N]; int one[N][N][N]; int main() { ios::sync_with_stdio(0); cin.tie(0); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) for (int k = 0; k < ...
module single_register(datain, dataout, clk, clr, WE); input [31:0] datain; output [31:0] dataout; input clk, clr, WE; reg [31:0] register; always @(posedge clk or posedge clr) begin if(clr) register = 0; else if(WE == 1) register = datain; end assign dataout = register; end...
#include <bits/stdc++.h> using namespace std; const int MX = 300002; long long N; int ans[MX], arr[MX], was[MX]; int take; void f(int L, int R, int vL, int vR) { if (L > R) return; if (vL == vR) { for (int i = L; i <= R; i++) { ans[i] = vL; } return; } int mid = L +...
#include <bits/stdc++.h> using namespace std; int main() { int tt; cin >> tt; while (tt--) { long long n; cin >> n; string s = to_string(n); int c = 0; for (int i = 0; i < s.size(); i++) { if (s[i] != 0 ) c++; } cout << c; cout << n ; for ...
#include <bits/stdc++.h> using namespace std; const int tam = 100010; const int MOD = 1000000007; const int MOD1 = 998244353; const double EPS = 1e-9; const double PI = acos(-1); int ar[3000000]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < 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...
// // Copyright (c) 2015 Jan Adelsbach <>. // 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 3 of the License, or // (at your optio...
/* * 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 N = 3005; const int inf = 5e8; vector<int> to[N], from[N]; int d[N][N], b[N][N]; vector<pair<int, int>> go[N], back[N]; bool done[N]; int n; void bfs(vector<int>* edge, int dist[N][N], vector<pair<int, int>>* ret) { for (int i = 0; i < N; i++...
#include <queue> #include <vector> #include <stdio.h> #include <stdlib.h> #define DEBUG printf( Passing [%s] in Line %d n , __FUNCTION__ , __LINE__) ; const int MAX_N = (1 << 11) + 10 , MAX_M = 10 + 5 , MAX_E = (1 << 22) + 10 , INF = 0x3f3f3f3f ; struct Link { int num , cap , cost ; Link *ne...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: scdata_efuse_hdr.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 ...
//----------------------------------------------------- // Proyecto 1 : DISEÑO DE UN CONTROLADOR DE SD HOST // Archivo : DATA.v // Descripcion : Control de datos del SD Host // La función de este bloque es servir de interface entre los registros // la interfaz de DMA, y la capa física donde se pasan las tramas ...
#include <bits/stdc++.h> using namespace std; int ABS(int a) { if (a < 0) return (-a); return a; } vector<int> v[50005]; int main() { int n, r1, r2, i; scanf( %d , &n); scanf( %d , &r1); scanf( %d , &r2); for (i = (1); i < (n + 1); ++i) { if (r1 == i) continue; int x; ...
#include <bits/stdc++.h> using namespace std; int main() { string n; cin >> n; int ans = 0; while (n.size() > 1) { int k = 0; for (int i = 0; i < n.size(); i++) { k += n[i] - 48; } ans++; stringstream ss; ss << k; string str = ss.str(); n = str...
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; int n, m, a[1005][1005]; vector<int> row[1005]; vector<int> col[1005]; int ans[1005][1005]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { scanf( %d , &a[i][j]); ...
// (C) 2001-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 simulation // files), and any associated doc...
// Module m_paper implements all features of the 2-bit paper processor. module m_paper; reg r_low = 1'b0; // logic low register reg r_high = 1'b1; // logic high register reg r_clock = 1'b0; // clock pulse register reg r_reset = 1'b1; // reset value register wire w_low, w_high,...
#include <bits/stdc++.h> using namespace std; int n; int a[100005]; int tmp[100005]; int sl = 0; int dp[100005]; int zs = 0; int sz[1200005]; int dd[100005]; int cl[100005]; vector<int> g[100005]; int sol() { zs = 0; for (int i = 1; i <= sl; ++i) { int u = tmp[i]; for (auto &...
/** * insn_out.v - Microcoded Accumulator CPU * Copyright (C) 2015 Orlando Arias, David Mascenik * * 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...
/* * 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) 2008 Xilinx, Inc. All rights reserved. // // XILINX CONFIDENTIAL PROPERTY // This document contains proprietary information which is // protected by copyright. All rights are reserved. This notice ...
`include "../defined.vh" module Lite_MIPS # ( parameter W = 32, parameter L = 6 ) ( clk, rst, g_init, e_init, o ); localparam N = 2**L; input clk; input rst; input [N*W-1:0] g_init; input [N*W-1:0] e_init; output [N*W-1:0] o; wire [N*W-1:0] inst_mem_in_wire; wire ...
#include <bits/stdc++.h> using namespace std; int main() { int n, cou = 0; cin >> n; string s; cin >> s; int res = n + 1; for (int i = 0; i < n; i++) { if (s[i] == H ) cou++; } for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < cou; j++) { if (s...
module top; integer res, id, job, inform, status, code, value; reg [30:0] short_job, short_inform, short_stat; initial begin id = 1; $q_initialize(); $q_initialize(1); $q_initialize(id); $q_initialize("A name"); $q_initialize(id, 1); $q_initialize(id, 2); $q_initialize(id, "A type...
#include <bits/stdc++.h> using namespace std; const int N = 5100; char Map[N][N]; int dp[N][N]; int main() { int i, j; int line, row; scanf( %d%d , &line, &row); for (i = 0; i < line; i++) scanf( %s , Map[i]); for (i = 0; i < line; i++) { for (j = row - 1; j >= 0; j--) { if (...
`timescale 1ns / 1ps // // Behavioral RAM. // module memory ( input wire [15:0] addr, // address bus input wire we, // write enable input wire clk, // write clock input wire bytew, // byte write input wire [15:0] d_in, // write data bus output wire [15:0] d_out // read data bus ); // 64 k...
/* * Copyright (c) 2015-2017 The Ultiparc Project. 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 list...
#include <bits/stdc++.h> using namespace std; int a, b, c, d; int gcd(int first, int second) { if (!second) return first; return gcd(second, first % second); } pair<int, int> sol, curr; int main() { cin >> a >> b >> c >> d; int dd = gcd(a, b); a /= dd; b /= dd; dd = gcd(c, d); ...
#include <bits/stdc++.h> using namespace std; long long func(long long arr[], long long n) { long long ans = 0; for (long long i = 2; i < n; i++) { if (arr[i] > arr[i - 1] && arr[i] > arr[i + 1]) { ans++; } else if (arr[i] < arr[i - 1] && arr[i] < arr[i + 1]) { ans++; } ...
// (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...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n), b(m); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; sort(a.begin(), a.end()); ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; constexpr int INF = 1001001001; constexpr int mod = 1000000007; template <class T> inline bool chmax(T& x, T y) { if (x < y) { x = y; return true; } return false; } template <class T> ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const int MAXN = 2005; int n, m; char maze[MAXN][MAXN]; void Dfs(int x, int y) { if (x >= n - 1 || y >= m - 1 || x < 0 || y < 0) return; int xx, yy, s = 0; for (int i = 0; i < 2; ++i) for (...
#include <bits/stdc++.h> using namespace std; string mapp[105]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> mapp[i]; int sx = 0x3f3f3f3f, sy = 0x3f3f3f3f, ex = 0, ey = 0, cnt = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (mapp[i]...
`timescale 1 ns / 1 ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11/18/2016 01:33:37 PM // Design Name: // Module Name: axi_combiner // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revis...
// This is a 6 to 1 mux that inputs from the 6 monitors and outputs to the 4 cpus // Author: Kekai Hu. Mar 1, 2013 module mux_61( input [2:0] sel, input out_ack_reset_0, input packet_drop_signal_0, input out_ack_reset_1, input packet_drop_signal_1, input out_ack_reset_2, inp...
`timescale 1ns / 1ns ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2015/11/01 18:08:48 // Design Name: // Module Name: sim_spi // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revis...
#include <bits/stdc++.h> using namespace std; int N, K; long long B; long long A[100005], Ac[100005]; int main() { cin >> N >> K >> B; map<long long, int> ct; for (int i = 0; i < N; i++) { cin >> A[i]; ct[A[i]]++; } ct[A[N - 1]]--; for (int i = 0; i < N - 1; i++) Ac[i] = A[...