text
stringlengths
59
71.4k
/** * 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; template <class T> T Max(const T &a, const T &b) { return a > b ? a : b; } const int SN = 100000 + 10; long long w[SN], f[SN][2], down[SN], g[SN], h[SN], head[SN]; long long u, v, n, num; bool vis[SN]; struct Edge { int from, to, next; } E[SN << ...
#include <bits/stdc++.h> using namespace std; string s; int i; int main() { cin >> s; i = s.find( 0 ); if (i > -1) s.erase(i, 1); else s.erase(0, 1); cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int h, cen; long long n, num; while (scanf( %d%I64d , &h, &n) != EOF) { num = (long long)pow(2.0, h) - 1 + n; int flag; long long ans = 0; if (num % 2 == 0) flag = 0; else flag = 1; cen = h - 1...
#include <bits/stdc++.h> using namespace std; vector<long long int> v; vector<long long int> v1; vector<long long int> v2; const long long int inf = 100000000000005; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i = 1; i < n; ...
#include <bits/stdc++.h> using namespace std; int const maxn = 1e5 + 5; int n, m, k, p[105], second[105], mx[105]; int ans; int main() { scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; ++i) scanf( %d , &p[i]); for (int i = 1; i <= n; ++i) { scanf( %d , &second[i]); if (mx[second[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 RotaryLed(clock0,clock180,reset,rotary,leds,vga_hsync,vga_vsync,vga_r,vga_g,vga_b); input wire clock0; input wire clock180; input wire reset; input wire [1:0] rotary; output wire [7:0] leds; output wire vga_hsync; output wire vga_vsync; output wire ...
#include <bits/stdc++.h> using namespace std; const int inf = 2e9; const long double eps = 0.000001; const long long mod = 1e9 + 7; const long double PI = 3.14159265359; template <class T> struct MyVector : vector<T> { MyVector() : vector<T>() {} MyVector(int n) : vector<T>(n) {} T &operator[]...
// megafunction wizard: %In-System Sources and Probes% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsource_probe // ============================================================ // File Name: JTAG_Probe.v // Megafunction Name(s): // altsource_probe // // Simulation Library Files(s): // altera_mf // ==...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 08:57:44 07/13/2015 // Design Name: // Module Name: SPI // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Rev...
#include <bits/stdc++.h> using namespace std; const int N = 1100000; const int M = 21; vector<int> adj[N]; int par[N][M]; int vis[N]; void dfs(int u, int p) { par[u][0] = p; for (int v : adj[u]) { if (v == p) continue; dfs(v, u); } } int main() { ios_base::sync_with_stdio(0...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); } struct key { string name; int t, p, g; }; int main() { int n, s, mt = 0, mg = 0, mp = 0; string x; cin >> n; vector<key> vec(n); for (int i = 0; i < n; i++) { cin >> s...
`timescale 1 ns / 1 ps module axis_variable # ( parameter integer AXIS_TDATA_WIDTH = 32 ) ( // System signals input wire aclk, input wire aresetn, input wire [AXIS_TDATA_WIDTH-1:0] cfg_data, // Master side input wire m_axis_tread...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long Fib[100]; long long Path[100]; pair<long long, long long> get(long long N, long long X, bool f) { assert(Fib[N] >= X); if (N <= 0) { return {0, 0}; } if (N == 1) { if (X == 1) { return...
#include <bits/stdc++.h> using namespace std; using namespace std; long long a[200005]; struct poi { long long val; int pos; } tp; bool operator<(const poi &a, const poi &b) { return (a.val > b.val) || (a.val == b.val and a.pos > b.pos); } priority_queue<poi> q; int main() { int n; ...
#include <bits/stdc++.h> using namespace std; int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 1}; long long int sizes[100001]; long long int arr[100001]; bool ok = true; long long int A[100001]; pair<long long int, long long int> B[100001]; long long int root(long long int i) { while (i != arr[i])...
/* Top level that just instantiates a UART in loopback mode in an icestick. * Assumtions: 12M clock. 115200 bps. 8N1 format. * Note: Needs retesting on hardware after code reorganization. */ /* MIT License Copyright (c) 2016 Baard Nossum Permission is hereby granted, free of charge, to any person obt...
module VGAController( input iClk, input inRst, input [7:0] iR, input [7:0] iG, input [7:0] iB, output [7:0] oR, output [7:0] oG, output [7:0] oB, output oHSync, output ...
#include <bits/stdc++.h> using namespace std; int f[100005], s[100005]; int main() { int n, k, inp; scanf( %d %d , &n, &k); for (int i = 1; i < k + 1; i++) { scanf( %d , &inp); s[inp] = i; if (!f[inp]) f[inp] = i; } int ans = 0; for (int i = 1; i < n + 1; i++) { if ...
#include <bits/stdc++.h> using namespace std; int main() { int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; if (r1 == r2 || c1 == c2) cout << 1; else cout << 2; cout << ; if ((r1 + c1) % 2 != (r2 + c2) % 2) cout << 0; else { if (r1 + c1 == r2 + c2 || r1 - c1 ==...
#include <bits/stdc++.h> using namespace std; int main() { int t; while (cin >> t) { string a; cin >> a; int s = 0; for (int i = 0; i < t - 1;) { if (a.at(i) == a.at(i + 1)) { if (a.at(i) == a ) a.at(i) = b ; else a.at(i) = a ; ...
#include <bits/stdc++.h> using namespace std; const int Inf = (int)1e9 + 7; const long long LongInf = (long long)1e18 + 7; namespace { const int N = 1007; const int MOD = (int)1e9 + 7; int k, pa, pb; long long dp[N][N]; long long pw(long long x, int m) { if (m == 0) return 1; long long y = pw(...
#include <bits/stdc++.h> char s[200010]; int tree[26][200010 << 2]; bool vis[200010]; inline void PushUp(int t, int rt) { tree[t][rt] = tree[t][rt << 1] + tree[t][rt << 1 | 1]; } void Update(int t, int x, int L, int R, int rt) { if (L == R) tree[t][rt] = 1; else { int mid = (L + R) >...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 06/17/2017 08:53:01 PM // Design Name: // Module Name: tb // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revisio...
#include <bits/stdc++.h> using namespace std; long long a[222222], b[222222], c[222222], d[222222]; set<long long> st; set<long long>::iterator it; map<long long, long long> sp2; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, m, k, x, s, i; cin >> n ...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) swap(a, b); if (b == 0) return a; return gcd(b, a % b); } int main() { int n, m; cin >> n >> m; int a0, b0, x; for (int i = 0; i < n + 1; i++) { cin >> x; if (!i) a0 = x; } for (int i...
// (C) 1992-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 simulati...
#include <bits/stdc++.h> using namespace std; int a[105][105][105]; int ans[105][105]; int main() { int n, m, h, x; cin >> n >> m >> h; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) for (int k = 1; k <= h; k++) a[i][j][k] = 1; for (int i = 1; i <= m; i++) { cin >>...
/** * 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; vector<pair<double, double> > vec; double x[10], y[10]; int cross(pair<double, double> a, pair<double, double> b, pair<double, double> c) { double re = (a.first - c.first) * (b.second - c.second); re -= (a.second - c.second) * (b.first - c.first)...
module tb_fpga(); parameter wire_width = 7; parameter lb_cfg_size = 18; parameter fpga_width = 5; parameter fpga_height = 5; // Test ports reg A, B; reg carryin; wire out; wire carryout; // Configuration ports reg [fpga_height*fpga_width*wire_width*12-1:0] brbselect; reg [(fpga_height-1)*(fpga_width-1)*(wi...
#include <bits/stdc++.h> int main() { long a, b, c; scanf( %ld%ld%ld , &a, &b, &c); if (b == a) { printf( YES n ); } else if (c > 0) { if (b < a) { printf( NO n ); } else if (((b - a) % c) == 0) { printf( YES n ); } else { printf( NO n ); } } e...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
////////////////////////////////////////////////////////////////////////////////// // Company: LKB // Engineer: Leonhard Neuhaus // // Create Date: 27.11.2014 14:15:43 // Design Name: // Module Name: red_pitaya_iq_fgen_block // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies...
#include <bits/stdc++.h> using namespace std; inline const int read() { int r = 0, k = 1; char c = getchar(); for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) k = -1; for (; c >= 0 && c <= 9 ; c = getchar()) r = r * 10 + c - 0 ; return k * r; } long long n; int k, a[110]; ...
#include <bits/stdc++.h> using namespace std; const int MAXM = 101000; pair<int, int> a[MAXM]; vector<pair<int, int> > b[MAXM << 1]; vector<int> c[MAXM << 1], d[MAXM << 1]; int main() { int n, m, i, j, k, x, y; int f, l, r, top; while (scanf( %d%d , &n, &m) != EOF) { for (i = 0; i < m; i++...
#include <bits/stdc++.h> using namespace std; void solve(); void YN(bool b) { if (b) { cout << YES << n ; ; } else { cout << NO << n ; ; } }; void yn(bool b) { if (b) { cout << Yes << n ; ; } else { cout...
#include <bits/stdc++.h> using namespace std; long long inf = 4e18, mod = 1e9 + 7; vector<pair<pair<long long, long long>, pair<long long, long long>>> v; int segt[4 * 6000000 + 5], lazy[4 * 6000000 + 5]; void push(int v, int l, int r) { segt[v] += lazy[v]; if (l != r) { lazy[2 * v] += lazy[v]; ...
/* * 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 MAX = 300010; int n; int maxx; int node[2 * MAX][30]; int cau[MAX]; int site; int other; void in() { scanf( %d , &n); int a, b; char c; for (int i = 1; i < n; i++) { scanf( %d %d %c , &a, &b, &c), node[a][c - a ] = b; }...
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T p, T e, T M) { long long ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:37:34 05/31/2016 // Design Name: // Module Name: Contador_ID // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: /...
//THINK ALOUD !! #include <bits/stdc++.h> #define debug(x) cout << -> [ << #x << = << x << ] n #define debug2(x, y) cout << -> [ << #x << = << x << , << #y << = << y << ] n #define debug3(x, y, z) cout << -> [ << #x << = << x << , << #y << = << y << , << #z << ...
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : -x; } int n; int m; int l[100], v[100][100], t[100][100], q[200]; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { scanf( %d , &l[i]); for (int j = 0; j < l[i]; j++) ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const long long inf = 9e18; struct NODE { long long v, id; bool operator<(const NODE& other) const { return v > other.v || (v == other.v && id > other.id); } } node[N]; long long a[N], b[N]; long long n; long long f(...
// a simple font_module // a simple font_module // text is generated from position (translated to ANSI) // IMPORTANT // this code can be a little confusing // since test_on is generated but not outputted // this is because that the top module of this module do not need to distinguish between different screens module f...
/** * 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() { int n, m; cin >> n >> m; int arr[100]; for (int counter = 0; counter < n; counter++) { cin >> arr[counter]; } sort(arr, arr + n); int sum = 0; for (int counter = n - 1; counter >= 0; counter--) { sum += arr[counte...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int s = 0; for (int i = 0; i < 5; i++) { int x; cin >> x; s += x; } if (s % 5 || !s) cout << -1 ; else cout << s / 5; }
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T x) { return x * x; } template <class T> T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a % b) : a); } template <class T> T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); } template <class T> inline T bigmod(T p, T...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double eps = 1e-6; const int mod = 1000000007; inline string getstr(string &s, int l, int r) { string ret = ; for (int i = l; i <= r; i++) ret.push_back(s[i]); return ret; } int modpow(int x, int y, int md = mod)...
/** * 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 = 2e5 + 5; int tim; int t[maxn]; int sum[maxn], sum2[maxn]; int in[maxn], ou[maxn], dfn[maxn]; vector<int> G[maxn]; void dfs(int rt, int fa) { in[rt] = ++tim; dfn[tim] = rt; for (int i = 0; i < G[rt].size(); i++) { int to = G...
// megafunction wizard: %ALTPLL% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altpll // ============================================================ // File Name: clk_pll.v // Megafunction Name(s): // altpll // // Simulation Library Files(s): // altera_mf // =================================...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int n, m, k, par[maxn], ans[maxn]; bool arr[maxn]; pair<int, pair<int, int>> e[maxn]; int get_path(int v) { return par[v] < 0 ? v : (par[v] = get_path(par[v])); } void merge(int v, int u) { if ((v = get_path(v)) == (u = get_path(...
// Copyright (c) 2000 Stephen Williams () // // This source code is free software; you can redistribute it // and/or modify it in source code form 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) // ...
/* This block handles the autoincrement needed for bursting and detects read responses */ `include "elink_regmap.v" module erx_protocol (/*AUTOARG*/ // Outputs erx_test_access, erx_test_data, erx_rdwr_access, erx_rr_access, erx_packet, // Inputs clk, test_mode, rx_packet, rx_burst, rx_access ); ...
//------------------------------------------------------------------------------ // YF32 -- A small SOC implementation based on mlite (32-bit RISC CPU) // @Taiwan //------------------------------------------------------------------------------ // // ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03/10/2016 11:52:43 AM // Design Name: // Module Name: Oper_Start_In // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // ...
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const int BASE = 27; const int N = 200000 + 2; const int LOGN = 20; const long long oo = 1e18; const double EPS = 1e-9; int n, q, a[N], mn[N], mx[N], freq[N], dsu[N], bst[N], sum[N]; int find(int i) { return dsu[i] == i ? i : dsu...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int nax = 1e5 + 10; vector<int> tree(4 * nax); long long i, j, x, y, k; bool sortbysec(const pair<long long, long long> &a, const pair<long long, long long> &b) { return (a.second < b.second); } int main() ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:28:42 11/06/2013 // Design Name: // Module Name: FrequencyDivider // Project Name: // Target Devices: // Tool versions: // Description: // /...
//############################################################################# //# Function: Phase Locked Loop # //############################################################################# //# Author: Andreas Olofsson # ...
////////////////////////////////////////////////////////////////////////////////// // // Author : Praveen Kumar Pendyala // Create Date : 05/27/13 // Modify Date : 16/01/14 // Module Name : pdl_puf // Project Name : PDL // Target Devices : Xilinx Vertix 5, XUPV5 110T // Tool v...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\velocityControlHdl\velocityControlHdl_Maintain_Range_block.v // Created: 2014-08-25 21:11:09 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // ----------------------------------------------...
// Copyright (C) 2012 // Ashwin A. Mendon // // This file is part of SATA2 core. // // 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...
#include <bits/stdc++.h> using namespace std; const int maxn = 1200005; const int OO = 0x3f3f3f3; int vis[maxn]; vector<int> p; int N = 1200000; void find_prime() { p.clear(); memset(vis, 0, sizeof(vis)); for (int i = 2; i <= N; i++) if (!vis[i]) for (int j = i * 2; j <= N; j += ...
#include <bits/stdc++.h> using namespace std; int dp[222][105]; int dp2[105]; char cc[555]; char c[111]; char a[111]; int alen, clen; int main() { int b, d; scanf( %d %d n , &b, &d); gets(a); gets(c); alen = strlen(a); clen = strlen(c); for (int i = 0; i < clen; i++) { ...
#include <bits/stdc++.h> using namespace std; long long int arr[500005], sum[500005]; bool vis[100005]; map<long long int, long long int> hola; map<pair<long long int, long long int>, long long int> con; vector<pair<long long int, long long int>> conn; int main() { long long int n, maxi = INT_MIN; ...
/* a lpc decoder * lpc signals: * lpc_ad: 4 data lines * lpc_frame: frame to start a new transaction. active low * lpc_reset: reset line. active low * output signals: * out_cyctype_dir: type and direction. same as in LPC Spec 1.1 * out_addr: 16-bit address * out_data: data read or written (1byte) ...
#include <bits/stdc++.h> using namespace std; char s1[200005], s2[200005]; int len; bool judge(int p, char *s1, char *s2) { for (int i = 0; i < p; i++) { if (s1[i] != s2[i]) return 0; } return 1; } int check(int p, char *s1, char *s2) { if (p == 1) { if (s1[0] != s2[0]) return 0;...
#include <bits/stdc++.h> using namespace std; int n, k; long long a[10010]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); sort(a + 1, a + 1 + n); long long sum = 0; for (int i = 1; i <= k; i++) sum += a[i]; printf( %lld n , sum); return 0; }...
`timescale 1ns / 1ps //----------------------------------------------------------------------------- // Title : JTAG VPI virtual interface // Project : KPU //----------------------------------------------------------------------------- // File : v_jtag_vpi.v // Author : acorallo <> // Created : 03.06.2017 //----...
//Legal Notice: (C)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 do...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; const ll MOD = 1e9 + 7, N = 1e5 + 10; const ll LG = log2(N) + 1; struct LCA { vector<vector<ll>> G, parent; vector<ll> tin, tout, depth; ll timer; ll n; ll LG; LCA(vector<vector<ll>> G, ll R...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string myNumber; cin >> myNumber; int temp; int fhalf = 0, shalf = 0; for (int i = 0; i < n / 2; ++i) { temp = myNumber[i] - 0 ; if (temp != 4 && temp != 7) { cout << NO ; goto exit;...
#include <bits/stdc++.h> using namespace std; int main() { int n = 4; int a[4]; for (int i = 0; i < 4; i++) { cin >> a[i]; } sort(a, a + n); for (int i = 0; i < 3; i++) { cout << a[3] - 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 la...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.2 (win64) Build Thu Jun 15 18:39:09 MDT 2017 // Date : Tue Sep 19 00:30:32 2017 // Host : DarkCube running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; const int d = 5; const int MAX = 1 << d; const int TOTAL = 374; inline int bit(unsigned int mask, int k) { return (mask >> k) & 1; } int __builtin_fnz(unsigned int x) { return 31 - __builtin_clz(x); } void printm(unsigned int mask, int k = d) { for (int i ...
#include <bits/stdc++.h> using namespace std; int toNumber(string s) { int Number; if (!(istringstream(s) >> Number)) Number = 0; return Number; } string toString(int number) { ostringstream ostr; ostr << number; return ostr.str(); } int main() { int n, m, k; while (cin >> n ...
#include <bits/stdc++.h> using namespace std; int A, B, q; long long l, t, m; bool check(long long len) { long long ind_left = l; long long ind_righ = ind_left + len - 1; long long num_left = A + (ind_left - 1) * B; long long num_righ = A + (ind_righ - 1) * B; long long need_time; if (le...
// megafunction wizard: %FIFO%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: adc_data_fifo.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // =========================...
#include <bits/stdc++.h> using namespace std; int main() { vector<int> child; int n, k; scanf( %d %d , &n, &k); int *A = new int[k]; for (int i = 0; i < k; ++i) { scanf( %d , &A[i]); } for (int i = 0; i < n; ++i) { child.push_back(i + 1); } int count = 0; for (int...
//---------------------------------------------------------------------// // Name: addrgen.v // Author: Chris Wynnyk // Date: 2/3/2008 // Purpose: Generates addresses. //---------------------------------------------------------------------// module addrgen( clk, nrst, start, readout, n, wradd...
#include <bits/stdc++.h> using namespace std; vector<int> v; long long int arr[100001], operation[100001][3], kitnibaar1[100002], kitnibaar[100002], update1[100002], update[100002]; int main() { int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= n; i++) { cin >> arr[i]; } for ...
// 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*/ // Outputs passed, // Inputs clk, fastclk, reset_l ); input clk /*verilator sc_clock*/; input fastclk /*verilator sc...
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; vector<char> a(str.begin(), str.end()); cin >> str; vector<char> b(str.begin(), str.end()); int res = 0; for (int i = 0; i < a.size(); i++) { if (a[i] >= a ) a[i] += - a + A ; if (b[i] >= a...
#include <bits/stdc++.h> using namespace std; long long k, d, t, cnt = 0; bool f(double T) { long long interval = ((long long)ceil(k / (d * 1.0))) * d; long long no_of_interval = T / interval; double t_on = no_of_interval * k, t_off = (interval - k) * no_of_interval; double rem = T - no_of_interva...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 23:51:00 02/21/2015 // Design Name: mfmDecode // Module Name: C:/Users/ChrisP/Documents/RL02Controller/RL02Controller/mfmDecode_tb.v // Project Name: RL02Co...
// ---------------------------------------------------------------------- // Copyright (c) 2016, 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 (C) 2009 Onno Kortmann <> ** ** 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. ** ** This program ...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: result_fifo.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ===============================...
/* * Copyright 2017 Google 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
#include <bits/stdc++.h> using namespace std; const long long N = 5e5 + 5; vector<long long> g[N]; map<long long, long long> cnt; long long n, c, a[N], pref[N]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> c; for (long long i = 1; i <= n; i++) {...
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int32_t main() { c_p_c(); long long t; cin >> t; while (t--) { long long n, r; cin ...
`default_nettype none module async ( input wire clk, input wire reset, input wire [3:0] async_data, output reg async_ack, output reg [1:0] sync_data, output reg sync_en ); reg [3:0] async_data_d1, async_data_d2; wire async_req_d0, async_sp_d0...
#include <bits/stdc++.h> using namespace std; int c[5555], ans[5555]; int main() { int n; cin >> n; int a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { memset(c, 0, sizeof(c)); int bc = 0, bt = -1; for (int j = i; j <= n; j++) { int ...
#include <bits/stdc++.h> long long MOD = 1e9 + 7; using namespace std; int main() { long long n, t; cin >> n >> t; long long a[200010], x[200010], b[200010]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { cin >> x[i]; x[i]--; if ((i > 0 && x[i] < x[i -...