text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; struct state { int i, j, dp, cp; }; int di[] = {0, 1, 0, -1}; int dj[] = {1, 0, -1, 0}; state n[50][50][4][2]; state current; char b[50][51]; int r, c; int moves; void read() { cin >> r >> moves; for (int i = 0; i < r; i++) { cin >> b...
module lc3_pipeline_cpu( input clk, input reset, input INT, output [15:0] pc, output [15:0] PSR, output EXC, output [5:0] state, output [5:0] stall, output [15:0] memA, inout [15:0] memD, output rc, output wc, output [5:0] state_next, output [15:0] aluout, outp...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 5e3 + 10; vector<double> vd; int flag = 0; vector<int> check(double x, int sz) { vector<int> v; int cur = 0; double tot = x; while (v.size() < sz) { int o = tot / 10; cur += o; v.push...
#include <bits/stdc++.h> using namespace std; char grid[10][10]; bool colW[10], colB[10]; int main() { int Case = 1; int l, p, q; char dump[2]; while (gets(grid[1])) { for (int i = 2; i <= 8; i++) { gets(grid[i]); } memset(colB, false, sizeof(colB)); memset(colW, ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:10:34 02/25/2014 // Design Name: // Module Name: Decode_Int // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: //...
#include <bits/stdc++.h> using namespace std; ifstream inp( inp.txt ); ofstream out( out.txt ); const int N = 1e5 + 5; const long long B = 73; int builtin_popcount(int &mask) { int kol = 0; for (int bit = 0; bit < 20; bit++) kol += int(bool(mask & (1 << bit))); return kol; } signed main() { ...
// (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 la...
#include <bits/stdc++.h> const long long int mrx = 1e6 + 5, M = 1e9 + 7, dm = 1e3 + 5; const long double pi = 3.1415926535897932384626433832795028841971693993751; long long int mx = -1e18, mn = 1e18; using namespace std; long long int q, n[mrx]; int main() { ios_base::sync_with_stdio(NULL); cin.tie(...
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265389793238462643383279502884197169; const long long MOD = 1e9 + 7; const int MAXN = 1e6 + 5; const int oo = 1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t, p; cin >> t; while ...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 10; int to[maxn << 1], nex[maxn << 1], head[maxn << 1], e, cnt; int u[maxn << 1], v[maxn << 1]; int dep[maxn << 1], siz[maxn << 1], son[maxn << 1], top[maxn << 1], fa[maxn << 1], id[maxn << 1]; int sum[maxn << 2]; int n; vo...
// 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 : Wed May 31 20:17:20 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, M = 1 << 20 | 10; const int mod = 1e9 + 7; long long n, m, sum; int a[M]; int main() { scanf( %lld%lld , &n, &m); for (int i = 1; i <= n; i++) a[i] = i, sum += i; if (sum > m) return puts( -1 ), 0; for (int i = 1, j = n; i...
#include <bits/stdc++.h> using namespace std; const int N = 1111111; int a[N]; int n, k; vector<int> prime, p; void Getprime() { for (int i = 2; i <= 1000; i++) { bool bo = 1; for (int j = 2; j * j <= i; j++) { if (i % j == 0) { bo = 0; break; } } ...
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, p, k; cin >> a >> b >> c; if (c != 0) { p = b - a; k = p / c; if (p % c == 0) { if (k >= 0) cout << YES << endl; else cout << NO << endl; } else cout ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: ITCR // Engineer: Yermy Benvaides // // Create Date: 20:33:46 02/29/2016 // Design Name: // Module Name: Traductor // Project Name: // Target Devices: // Tool versions: // Description: // //...
#include <bits/stdc++.h> using namespace std; template <class T> bool remin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <class T> bool remax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } int nxt(...
#include <bits/stdc++.h> using namespace std; string s[3]; int permutation[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}}; string accepted_strings[6]; string process(string str) { string result = ; for (int i = 0; i < (int)str.length(); i++) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 400010, inf = 1 << 30; int N, M, father[maxn], nxt[maxn], toit[maxn], len[maxn], side[maxn], id[maxn], seq[maxn], D[maxn], cnt; int DFN, dfn[maxn], top[maxn], size[maxn], con[maxn], ans[maxn], tree[maxn << 2], cover[maxn << 2]; bool ex...
/** * 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 NMAX = 1e6 + 5; const int MOD = 998244353; long long lgput(long long b, long long p) { long long r = 1; while (p) { if (p & 1) { r = 1LL * r * b % MOD; } p >>= 1; b = b * b % MOD; } return r; } long long ...
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } bo...
// ============================================================== // 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...
#include <bits/stdc++.h> using namespace std; int n, q; int arr[1000010], lazy[1000010 << 2]; string str; struct data { int n4, n7, n47, n74; data() { n4 = n7 = n47 = n74 = 0; } } tree[1000010 << 2]; void build(int node, int l, int r) { if (l == r) { tree[node].n4 = (arr[l] == 4); ...
#include <bits/stdc++.h> using namespace std; int main() { vector<long long> v; int n; cin >> n; v.resize(n); for (int i = 0; i < n; i++) { cin >> v[i]; } sort(v.rbegin(), v.rend()); long long ans = v[0]; for (int i = 1; i < n; i++) { if (v[i] >= v[i - 1]) v[i] = max(...
// (c) Copyright 2012-2013 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 g...
#include <bits/stdc++.h> using namespace std; vector<long long> g[(long long)3e5], a((long long)3e5); long long i, n, x, y, r; void b(long long p, long long q, long long m) { a[p]++, r += m; for (auto j : g[p]) if (j != q) b(j, p, m ^ 1), a[p] += a[j]; } int main() { for (cin >> n, i = 1; ...
#include <bits/stdc++.h> using namespace std; void actionFun() { long long n; cin >> n; long long c = 2; for (int i = 0; i < n; i++) { cout << c << ; ++c; } cout << endl; return; } int main() { int t; cin >> t; while (t--) { actionFun(); } }
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; const ld EPS = 1E-9; struct pt { ld x, y; }; struct seg { pt p, q; int id; ld get_y(ld x) const { if (abs(p...
// Gris InterConnect slave // This module acts as a Wishbone master and receives operations from // the GIC Master which acts as a Wishbone slave. module gic_slave #( parameter idle = 4'b1111 ) ( output [31:0] wbm_adr_o, output wbm_stb_o, output wbm_cyc_o, output [3:0] ...
#include <bits/stdc++.h> using namespace std; int main() { double r, x, y, z, t; cin >> r >> x >> y >> z >> t; double d = (x - z) * (x - z) + (y - t) * (y - t); d = sqrt(d); double i; for (i = 0; i < 10000000; i++) { if ((i * r) >= d / 2) break; } cout << i << endl; }
#include <bits/stdc++.h> using namespace std; int n, k; int query(int x, int y) { cout << 1 << x << << y << endl; string ans; cin >> ans; if (ans == TAK ) return 1; return 0; } int find(int l, int r) { if (l > r) return -1; int L = l; int R = r; while (L < R) { ...
#include <bits/stdc++.h> using namespace std; pair<int, int> x[1024], y[1024]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> x[i].first >> x[i].second; y[i].fi...
#include <bits/stdc++.h> using namespace std; struct Rect { int x1, y1, x2, y2; long long area() { return (long long)(x2 - x1) * (y2 - y1); } }; long long intersect(const Rect&, const Rect&); Rect intersectingRect(const Rect&, const Rect&); int main() { Rect white, black1, black2, b1Inside, b2In...
// Verilog netlist generated by Workcraft 3 module VME (d, lds, dtack, dsr, dsw, ldtack); input dsr, dsw, ldtack; output d, lds, dtack; wire U1_ON, IN_BUBBLE3_ON, IN_BUBBLE5_ON, U7_ON, IN_BUBBLE10_ON, OUT_BUBBLE1_ON, U14_ON, IN_BUBBLE16_ON, IN_BUBBLE18_ON, U20_ON, IN_BUBBLE23_ON, IN_BUBBLE25_ON, IN_BUBBLE28...
#include <bits/stdc++.h> using namespace std; int f[10000050], pre[10000050], used[10000050], edge[105]; vector<int> vec; int main() { int n, m, i, j, x, y, maxi, size, news; scanf( %d%d , &n, &m); for (i = 1; i <= m; i++) { scanf( %d%d , &x, &y); edge[x] |= 1 << y; edge[y] |= 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2017 by Matt Myers. // SPDX-License-Identifier: CC0-1.0 `define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (g...
#include <bits/stdc++.h> using namespace std; int main() { int m, n; cin >> m >> n; vector<int> sg(n, +1); for (int i = 1, x; i <= n; ++i) { cout << i << n ; fflush(stdout); cin >> x; if (x < 0) sg[i - 1] = -1; if (x == 0) return 0; } int l = n + 1, r = m, pt ...
module xyz (/*AUTOARG*/ // Outputs signal_f, signal_c, // Inputs signal_b ); /*AUTOINPUT*/ // Beginning of automatic inputs (from unused autoinst inputs) input [2:0] signal_b; // To u_abc of abc.v // End of automatics /*AUTOOUTPUT*/ /...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAXN = 1e5 + 10; bool bd[MAXN]; int n; int a[MAXN]; vector<pair<int, int>> sol; pair<int, int> coord(pair<int, int> p) { return {(n - 1 - p.second), p.first}; } int main(void) { scanf( %d , &n); for (int i = 0; i ...
#include <bits/stdc++.h> using namespace std; const int N = 2000 * 2000 + 1; int n, m, mark[N], mx, rep; string s; vector<int> adj[N]; bool circle(int v) { mark[v] = 1; for (int i = 0; i < adj[v].size(); i++) { int u = adj[v][i]; if (mark[u] == 1 || (!mark[u] && circle(u))) return true; ...
#include <bits/stdc++.h> using namespace std; using namespace placeholders; template <class T> void mini(T &l, T r) { l = min(l, r); } template <class T> void maxi(T &l, T r) { l = max(l, r); } template <class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << = << h << n ; } ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n, m; cin >> n >> m; vector<vector<int>> adj(n); for (int i = 0, u, v; i < m; ++i) { cin >> u >> v; --u, --v; adj[u].push_back(v); adj[v].push_back(u); } set<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> const int INF = 1e6; using namespace std; const int maxn = 1e5 + 5; const int N = 1e6; const int big = 1e9; long long int get(long long int a, long long int b, long long int x, long long int y) { x--; y--; long long int temp = (y * (y - 1) - x * (x - ...
#include <bits/stdc++.h> using namespace std; map<string, int> A; string s; int main() { A[ void ] = 100; A[ errtype ] = 0; int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> s; if (s[4] == d ) { string a, b; cin >> a >> b; int l = a.length(); ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, min = 1000; scanf( %d %d , &n, &m); vector<int> v(m); for (int i = 0; i < m; i++) scanf( %d , &v[i]); sort(v.begin(), v.end()); for (int i = 0; n + i - 1 < m; i++) { if (min > v[n + i - 1] - v[i]) min = v[n + i - 1] -...
#include <bits/stdc++.h> using namespace std; int dp, p[201000], tt[201000], pre[201000], l[201000], vis[201000]; int n, m, i, j, a[1010][1010], g[201000], now[201000], s, t, dis[201000], z[201000], ans; void link(int x, int y, int z) { dp++; pre[dp] = p[x]; p[x] = dp; tt[dp] = y; g[dp...
#include <bits/stdc++.h> using namespace std; int x[5], y[5]; int matr[5005][5005]; inline void err() { for (int i = 0; i <= 5000; ++i) for (int j = 0; j <= 5000; ++j) matr[i][j] = -1; } inline void fil(int i, int j, int ii, int jj, int val) { for (int a = i; a <= ii; ++a) for (int b = j...
////////////////////////////////////////////////////////////////////////////// // // Xilinx, Inc. 2007 www.xilinx.com // // XAPP xxx // ////////////////////////////////////////////////////////////////////////////// // // File name : chnlbond.v // // Description : Channel Bonding Logic // ...
#include <bits/stdc++.h> using namespace std; int main() { int x, i, p = 0, k = 0; cin >> x; char n[x + 1]; cin >> n; for (i = 0; i < x; i++) { if (n[i] == L ) p++; else k++; } cout << p + k + 1 << endl; }
/** \file "channel-ledr-expect-fail.v" Chain a source and sink in prsim to verilog. $Id: $ */ `timescale 1ns/1ps `include "standard.v" module timeunit; initial $timeformat(-9,1," ns",9); endmodule module TOP; reg l0, l1; wire r0, r1; DELAY #(0.01) d0(l0, r0); DELAY #(0.01) d1(l1, r1); // prsim stuff i...
/////////////////////////////////////////////////////////////////////////////// // 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; int main() { int t, n, ind; cin >> t; while (t--) { cin >> n; ind = -1; int a[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; if (a[i] % 2 == 0) ind = i; } if (ind != -1) cout << 1 n << ind + 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; ifstream Cin( input.txt ); ofstream Cout( output.txt ); pair<bool, long long> Try(long long A, long long B, long long N) { long long err = 0, C; while (A > 0 && B > 0 && N > 0) { if (A == 1 && B != 1) { C = B - 1; A = B = 1; } els...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; int arr[N], grr[100006] = {0}, fre[100005] = {0}, x, ma = 0, ans = 0; for (int i = 0; i < N; i++) { bool ok = false; cin >> x; grr[fre[x]]--; fre[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...
#include <bits/stdc++.h> using namespace std; long long int n, m; long long int arr[200005]; map<long long int, long long int> x; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> n >> m; for (int i = 0; i < n; ++i) cin >> arr[i]; long long int l = 0, sum = 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...
// // Copyright 2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is dis...
#include <bits/stdc++.h> using namespace std; const int m = 31623; int nim[] = { 0, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12, }; bool isLarge[m]; int n; int main(void) { cin >> n; memset(isLarge, true, sizeof(isLarge)); for (int i =...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11.07.2017 23:51:28 // Design Name: // Module Name: t_id // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; set<int> s; for (int i = 0; i < n; i++) { int x; cin >> x; s.insert(x); } set<int>::iterator it = s.begin(); int c = 0; while (it != s.end()) { if (*it == 0) c++; it++; } ...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 1; const long long int mod2 = 1e9 + 9; const long long int maxn = 1e6 + 1; const int root = 1e7 + 5; const long long inf = 1e18 + 18; double pie4 = 3.1415926535; long long int visit[maxn], a[maxn]; void die() { cout << ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int a, b, c, d, i, j, n, m, k, ans; int cs[100001], mas[100001], dp[100001]; inline int sum(int a, int b) { if (!a) return cs[b]; else return cs[b] - cs[a - 1]; } int main() { scanf( %d , &n); ...
`include "../define.v" `include "memory.v" module rom_tb; reg rst; reg ce; reg[`MemDataWidth-1:0] data; reg[`MemAddrWidth-1:0] addr; reg we; reg[`ByteSlctWidth-1:0] byte_slct; wire[`MemDataWidth-1:0] data_o; memory #(.MemoryDataNum(32)) test_momory( .rst(rst), .ce(ce), .data_i(data)...
#include <bits/stdc++.h> using namespace std; int n; vector<vector<int>> adj; vector<long long> d; vector<bool> visited; bitset<5000> sol; void dfs(int m) { bitset<5000> tmp; d[m] = 1; tmp[0] = 1; for (auto l : adj[m]) { if (!visited[l]) { visited[l] = 1; dfs(l); ...
#include <bits/stdc++.h> using namespace std; int main() { int num; cin >> num; if (num <= 9) { cout << num << endl; } else if (10 < num && num <= 189) { num = num - 9; int tmp = num / 2; tmp = 9 + tmp + num % 2; if (num % 2) cout << tmp / 10 << endl; else...
Require Import HJ.Vars. Set Arguments Implicit. (** A count-down rsem with dynamic registration works exactly like a reverse semaphore, it includes has three operations: - an operation to register a task that increments the reverse semaphore; - an operation to signal, or deregister, a task that decrements the...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int SIZE = 1e6 + 10; int a[SIZE], b[SIZE], c[SIZE], cnt[SIZE]; bool used[SIZE]; vector<int> r[SIZE]; set<int> H; void print_array(vector<int>& arr) { for (int i = 0; i < (((int)(arr).size())); ++i) { if (i) printf( ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); ; int n; bool allSame = true; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (i > 0 and a[i] != a[i - 1]) allSame = false; } sort(a, a + n); if (n == 1) { ...
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n >> k; priority_queue<pair<int, int> > p; set<int> s; for (int i = 1; i <= n; i++) { int in; cin >> in; p.push({in, i}); s.insert(i + k); } long long ans = 0; vector<int> v(n); ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: dram_clk_edgelogic.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 i...
#include <bits/stdc++.h> using namespace std; int main() { int rj = 1000000000; int n, m, a, b; scanf( %d %d %d %d , &n, &m, &a, &b); for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) { if (i + j * m < n) continue; rj = min(rj, a * i + b * j); } printf( %d n ,...
#include <bits/stdc++.h> using namespace std; long long mod = (1000000007LL); inline long long mult(long long a, long long b) { return (a * b) % mod; } inline long long poww(long long a, long long b) { long long res = 1; while (b > 0) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; ...
// // Copyright (C) 2015-2016 Markus Hiienkari <> // // This file is part of Open Source Scan Converter project. // // 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 Li...
//`timescale 1 ms /1 us `include "mux81c.v" module chap4p32c_tb (S); // module declaration output [0:3] S; reg [0:3] S; //S[0]=A, S[1]=B, S[2]=C, S[3]=D wire [0:7] I; wire Y; integer fp; // program body assign I[0]=~S[3]; assign I[1]=~S[3]; assign I[2]=S[3]; assign I[3]=S[3]; assign I[4]=...
#include <bits/stdc++.h> using namespace std; const int N = 50 + 5; int n, a[N][N], tot; int main() { cin >> n; int i = 0, j = n / 2, x, y; for (int k = 1; k <= n * n; k++) { if (a[i][j]) { i = (x + 1) % n; j = y; } a[i][j] = k; x = i; y = j; i = (...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int n, m, q; int a[1110][810]; char s[1100]; int ni[5] = {0, 1, 3, 2, 4}; long long pow_mod(long long a, long long e) { long long res = 1; for (; e; a = a * a % mod, e >>= 1) if (e & 1) res = res * a % mod; retu...
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000000000000; int main() { int n, m; cin >> n >> m; vector<int> x(n); for (int i = 0; i < n; i++) { cin >> x[i]; } vector<int> p(m), c(m); for (int i = 0; i < m; i++) { cin >> p[i] >> c[i]; } so...
#include <bits/stdc++.h> using namespace std; int tr[400], ar[400]; vector<pair<int, int> > vv; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> ar[i]; for (int i = 0; i < n; i++) cin >> tr[i]; for (int i = 0; i < n; i++) { if (tr[i] == ar[i]) continue; int j; ...
#include <bits/stdc++.h> constexpr int N = 1.5e5, M = 1 << 18; int n, q; int parent[N], dep[N]; char ch[N]; int down[N], h[N], deg[N]; int mx[N][26], edge[N][26], sum[N]; int e[N][2]; int bad; void add(int u, int c, int v) { u = down[u]; edge[u][c] += v; for (u = parent[u]; u != -1; u = pa...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:01:29 04/03/2016 // Design Name: Register // Module Name: C:/Users/Ranolazine/Desktop/lab5_better_io/test_for_reg.v // Project Name: lab5 // Target Devi...
// EE 471 Lab 4, Beck Pang, Spring 2015 // four 4-word block directly mapped cache with write back method // Instruction cache, only need to read instruction // but the cache is a general cache module dCache ( input clk, // Clock input rst_n, // Asynchronous reset active low input WrEn, input [31:0] dataIn, ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2017. // SPDX-License-Identifier: CC0-1.0 interface if1; integer var1; endinterface interface if2; if1 i1 (); integer var2; endinterface module mod1 ( input clk, in...
#include <bits/stdc++.h> using namespace std; int main(void) { int n, i, j = -100, k, *a, cnt = 0, cnt1 = 0; cin >> n; a = new int[n]; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n - 2; i++) { if (a[i] == 1 && a[i + 1] == 0 && a[i + 2] == 1) { if (i - j > 2) ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); long long n, m, k, t; cin >> n >> m >> k >> t; pair<int, int> mp[k + 1]; long long x, y, a, b; for (int i = 0; i < k; i++) { cin >> mp[i].first >> mp[i].second; } sort(mp, mp + k); for ...
#include <bits/stdc++.h> using namespace std; const int N = 5000010; vector<long long> v[N]; int a[N]; long long com2(long long n) { return n * (n - 1) / 2; } int main() { long long n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); if (a[i] >= m) { print...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `ifdef OVL_ASSERT_ON parameter REQ_ACK_START = 2'b00; parameter REQ_ACK_WAIT = 2'b01; parameter REQ_ACK_ERR = 2'b10; parameter REQ_ACK_DEASSERT = 2'b11; reg [1:0] r_state; re...
#include <bits/stdc++.h> using namespace std; int main() { int n, x = 0; cin >> n; while (n > 0) { if (n >= 100) { x += n / 100; n %= 100; } else if (n >= 20 && n < 100) { x += n / 20; n %= 20; } else if (n >= 10 && n < 50) { x += n / 10; ...
/** * 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 fa[2005], fb[2005]; long long mina[2005], minb[2005]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; vector<long long> a(n), b(m); for (int i = 0; i < n; i++) { cin >> a[i];...
#include <bits/stdc++.h> using namespace std; int a[101][4]; int main() { int n; cin >> n; int min = 0, ind = 0; for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3]; min = 100000; ind = 0; for (int i = 0; i < n; i++) { bool ust = false; for (int j = ...
// $Id: c_err_rpt.v 5188 2012-08-30 00:31:31Z dub $ /* Copyright (c) 2007-2012, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of...
#include <bits/stdc++.h> using namespace std; const int OO = 0x3f3f3f3f, N = 1e2 + 5, mod = 1e9 + 7; int ans, lst = OO, gt[26]; string s1, s2; vector<int> idx[26]; int main() { cin >> s1 >> s2; for (int i = 0; i < s1.size(); ++i) idx[s1[i] - a ].push_back(i); for (int i = 0; i < s2.size(); ++i)...
#include <bits/stdc++.h> int main() { int n, p, q, p1[150], q1[150], pq[300], i, j, k, l, m; scanf( %d , &n); scanf( %d , &p); for (i = 0; i < p; i++) { scanf( %d , &p1[i]); } scanf( %d , &q); for (j = 0; j < q; j++) { scanf( %d , &q1[j]); } if ((p == 0) && (q == 0)) { ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer _mode; initial _mode = 0; // verilator lint_off LITENDIAN reg [7:0] mem_narrow...
// ghrd_10as066n2_ocm_0.v // Generated using ACDS version 17.1 240 `timescale 1 ps / 1 ps module ghrd_10as066n2_ocm_0 ( input wire clk, // clk1.clk input wire reset, // reset1.reset input wire reset_req, // .reset_req input wire [17:0] address, // s1.addres...