text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { x = 0; char c = getchar(), f = 0; for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) f = 1; for (; c >= 0 && c <= 9 ; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); if (f) x = -...
#include <bits/stdc++.h> using namespace std; int main() { long long in, temp = 0, t = 0; int casos; cin >> casos; for (int i = 0; i < casos; i++) { cin >> in; temp = in * (in + 1) / 2; for (long long i = 0;; i++) { if ((1 << i) > in) { break; } else { ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int tmp = 0; tmp < t; tmp++) { unsigned long long int n, k; cin >> n >> k; if (k >= n) { cout << 1 << n ; continue; } bool fl = false; for (int i = 2; i * i <= n; i++) {...
`timescale 1ns / 1ps module ControlUnit( input [5:0] op, input clk, input rst, input zero, input sign, output wire [2:0] state, output ExtSel, // PC output [1:0] PCSrc, output PCWre, // ALU output ALUSrcA, output ALUSrcB, output reg [2:0] ALUOp, // Instr...
#include <bits/stdc++.h> using namespace std; int n, s, x1, x2, v1, v2, w, d, ans; int main() { cin >> s >> x1 >> x2 >> v1 >> v2 >> w >> d; ans = abs(x1 - x2) * v2; if (d == 1) { if (w < x2) { if (x1 < x2) { if (x1 >= w) ans = min(ans, (x2 - w) * v1); else...
`timescale 1ns / 1ps `default_nettype none ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 04:47:33 03/21/2011 // Design Name: // Module Name: memorias // Project Name: // Target Device_ns: // Tool versions: // Description: /...
#include <bits/stdc++.h> using namespace std; template <class T> void checkmax(T &t, T x) { if (x > t) t = x; } template <class T> void checkmin(T &t, T x) { if (x < t) t = x; } template <class T> void _checkmax(T &t, T x) { if (t == -1 || x > t) t = x; } template <class T> void _che...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 12:23:35 04/24/2015 // Design Name: ADD // Module Name: /media/BELGELER/Workspaces/Xilinx/processor/test_add.v // Project Name: processor // Target Device: // Tool...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11:57:36 02/22/2015 // Design Name: decodeFSM // Module Name: C:/Users/ChrisP/Documents/RL02Controller/RL02Controller/decodeFSM_tb.v // Project Name: RL02Co...
// MBT 5-1-2017 // // fast version of the gateway reset sequence // // this version assumes that all channels work // and is just for gatelevel simulation. // `include "bsg_defines.v" module bsg_source_sync_channel_control_master_master #(parameter `BSG_INV_PARAM( link_channels_p ) , parameter `BSG_INV_PARAM(...
module ARM_CU_ALU_TestBench3; parameter sim_time = 750*2; // Num of Cycles * 2 reg MFC , Reset , Clk , MEMSTORE,MEMLOAD; reg [31:0] MEMDAT; wire MFA,READ_WRITE,WORD_BYTE; wire [7:0] MEMADD; //module ARM_CU_ALU( input MFC , Reset , Clk , MEMSTORE,MEMLOAD,MEMDAT, output MEMADD, MFA,READ_WRITE,WORD_BYTE); ARM_CU_ALU C...
/* Legal Notice: (C)2009 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...
module testbench; parameter NO_OF_MSGS=128, MSG_WIDTH=4, B=3, PATTERN_WIDTH=74, SIGN_DEPTH=128, SHIFT_WIDTH=$clog2(PATTERN_WIDTH-B+1),DATA_WIDTH=MSG_WIDTH*NO_OF_MSGS, NOS_SHIFTER=2*NO_OF_MSGS, POINTER_WIDTH=$clog2(NOS_SHIFTER), NOS_KEY=4, NOS_CMPS=SIGN_DEPTH/NOS_KEY,NOS_STGS=$clog2(SIGN_DEPTH/NOS_K...
# include <bits/stdc++.h> # define sz(x) (int)x.size() # define f first # define s second using namespace std; using ll = long long; void solve() { int n, a, b; cin >> n >> a >> b; int x, y; cin >> x >> y; int c = n - max(a, b) + abs(a - b) / 2; int d = min(a, b) + abs(a - b) /...
#include <bits/stdc++.h> int main() { int tcase; for (scanf( %d , &tcase); tcase--;) { long long l, r; scanf( %lld%lld , &l, &r); if (l == r) { printf( %lld n , r); continue; } int p = 63 - __builtin_clzll(l ^ r); long long temp = 0; for (int i = 63; i...
#include <bits/stdc++.h> int main() { char str[5010]; memset(str, 0, sizeof(str)); scanf( %s , str); int n; n = strlen(str); int res = 0; for (int i = 0; i < n; i++) { int l = 0, sum = 0; for (int j = i; j < n; j++) { if (str[j] == ( ) l++; else if (s...
#include <bits/stdc++.h> using namespace std; const long long inf = 1e12; const int maxn = 2e5 + 30; int n; long long dp[maxn][2], val[maxn], h[maxn], ans; vector<int> G[maxn]; void Min(long long &x, long long y) { if (x > y) x = y; } void dfs(int u, int fa) { for (auto v : G[u]) { if (v...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2011 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> const long long int MOD = 1e9 + 7; const long long int INF = 1011111111; const long long int LLINF = 1000111000111000111LL; const long double EPS = 1e-10; const long double PI = 3.14159265358979323; using namespace std; long long int power(int x, int n) { if (n == 0) ret...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ `timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time unit...
// bsg_mesosync_link is the designed IO in bsg group that devides // the core's clock to a slower clock for IO based on the configuration // it receives. For each input data line it can choose between the clock // edge and which cycle in the divided clock to take the sameple, based on // the bit_cfg_i configuration. ...
#include <bits/stdc++.h> using namespace std; int n, k; int fr[200002]; int arr[200002]; bool check(int cati) { int qq = 0; for (int i = 1; i <= 200000; ++i) qq += fr[i] / cati; if (qq >= k) return 1; return 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin...
//wb_tx1_ddr3.v /* Distributed under the MIT license. Copyright (c) 2015 Dave McCoy () 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 ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 21:11:59 11/11/2015 // Design Name: // Module Name: LEDWorm // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 13:05:56 10/30/2014 // Design Name: // Module Name: RegistroLoad // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << ? << 1 << << 3 << endl; int ac; cin >> ac; cout << ? << 1 << << 2 << endl; int ab; cin >> ab; cout << ? << 2 << << 3 << endl; int bc; cin >> bc; int amc = ab - bc;...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n; cin >> n; int a[n]; for (int j = 1; j <= n; j++) { a[j] = pow(2, j); } int f = 0, s = 0; for (int j = 1; j <= n; j++) { if (j < n / 2...
#include <bits/stdc++.h> using namespace std; int n, k, mod = 1000000007; char t[2042]; long long dp[2042][2042], suff[2042][2042]; int solve() { dp[n][0] = 1; for (int cInd = n - 1; cInd >= 0; cInd--) { dp[cInd][0] = 1; for (int kLeft = 0; kLeft <= k; kLeft++) { bool f = 0; ...
// Copyright (c) 2015 CERN // Maciej Suminski <> // // 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) // any late...
#include <bits/stdc++.h> using namespace std; const int N = 1e6; const long long int inf = 1e18; vector<long long int> v, arr; void pf() {} long long int sqrtfun(long long int num) { long long int lo = 0, hi = (long long int)2e9, mid; if (num == 1) return num; while (lo + 1 < hi) { mid = l...
#include <bits/stdc++.h> using namespace std; int n, x, y; char a[100005]; int main(void) { scanf( %d%d%d , &n, &x, &y); for (int i = 1; i <= n; i++) { cin >> a[i]; } if (a[x] == a[y]) puts( 0 ); else puts( 1 ); }
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 8; int a[N], fa[N][20]; vector<int> E[N]; long long res; void dfs(int x, int f) { fa[x][0] = f; long long temp = a[f]; for (int i = 1; i < 20; i++) { fa[x][i] = fa[fa[x][i - 1]][i - 1]; temp = min(temp, (i + 1ll) * a[f...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; long long POW(long long a, long long b, long long MMM = MOD) { long long ret = 1; for (; b; b >>= 1, a = (a * a) % MMM) if (b & 1) ret = (ret * a) % MMM; return ret; } long long gcd(long long a, long long b) { re...
#include <bits/stdc++.h> using namespace std; int main() { int n, i = 2, c = 0, v = 1; cin >> n; int x = 5; while (n - x > 0) { n = n - x; x = x * 2; v = v * 2; } while (n - v >= 1) { n = n - v; c++; } if (c + 1 == 1) { cout << Sheldon ; } ...
#include <bits/stdc++.h> using namespace std; mt19937 rnd(time(0)); const double eps = 1e-10; const long long inf = 0x3f3f3f3f3f3f3f3fLL; const long long N = 2e5 + 5; const long long MOD = 1e9 + 7; long long pw(long long b, long long p) { long long res = 1; while (p > 0) { if (p & 1) res = r...
/* * 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 "../src/include/FIFO2MM_adv.v" `include "../src/s2mm_adv.v" `include "s2mm_test_fifo_generator_0_0.v" `include "s2mm_test.v" `timescale 1ns / 1ps /// 2. first line output : if f0 valid /// 3. sof for reset module test(); parameter integer C_PIXEL_WIDTH = 8; parameter integer C_IMG_WBITS = 12; parameter inte...
#include <bits/stdc++.h> using namespace std; bool one(string s); bool two(string s); void c(string s); void c2(string s); int main() { string str; int i; cin >> str; if (one(str)) { c(str); } else if (two(str)) { c2(str); } else { cout << str << endl; } ret...
/****************************************************************************** This Source Code Form is subject to the terms of the Open Hardware Description License, v. 1.0. If a copy of the OHDL was not distributed with this file, You can obtain one at http://juliusbaxter.net/ohdl/ohdl.txt Description: Simple ...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2013 Altera Corporation, San Jose, California, USA. * ...
// 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 09:40:17 2017 // Host : DarkCube running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; map<int, int> times; const int INF = 0x3fffffff; struct Node { int l, r; int v; Node() { l = -1, r = -1; } Node(int _l, int _r) { l = _l, r = _r; } } node[120000]; int fa[120000]; int n, v, ls, rs, root; int ans; int Findroot(int t) { i...
#include <bits/stdc++.h> using namespace std; vector<int> isbandyk(int a, vector<int> prad) { vector<int> rez; vector<int> ats(prad.size(), -1); int pas = 0; for (int i = 0; i < prad.size(); i++) { if (prad[i] <= a - 1) { rez.push_back(prad[i]); pas = i; ats[i] = 1; ...
`timescale 1ns / 1ps // Modified by: Adam Michael, CM1884 // Mohammad Almisbaa, CM2060 // Date: November 5, 2015 // Summary: This is just a square wave generator. //File: CRTClockTemplate.v //Generate 25MHz VGA clock from a SystemClock //SystemClockFreq and CRTClockFreq are input parameters in MHz //ECE333 F...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int n; cin >> n; if (n % 2 == 0) return cout << NO , 0; long long int arr[2 * n + 1]; long long int a = 1, b = n + 1; for (long long int...
#include <bits/stdc++.h> using namespace std; int N, M, A, B; int main() { scanf( %d%d%d%d , &N, &M, &A, &B); int rA = (A - 1) / M + 1, cA = A - (rA - 1) * M; int rB = (B - 1) / M + 1, cB = B - (rB - 1) * M; if (B == N) cB = M; if (rA == rB) { puts( 1 ); exit(0); } if (rA +...
////////////////////////////////////////////////////////////////// // // // Memory Access - Instantiates the memory access stage // // sub-modules of the Amber 25 Core // // ...
#include <bits/stdc++.h> using namespace std; int n, a[300000 + 10], ans = 2e9; vector<int> lj[300000 + 10]; multiset<int> s; int main() { int i; scanf( %d , &n); for (i = 1; i <= n; ++i) scanf( %d , &a[i]), s.insert(a[i]); for (i = 1; i < n; ++i) { int u, v; scanf( %d%d , &u, &v);...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, t; cin >> t; while (t--) { cin >> n; if (n % 2 == 0) cout << n / 2 << n ; else cout << (n / 2) + 1 << n ; } }
#include <bits/stdc++.h> using namespace std; int main() { string a = , b = ; int n, m; cin >> n >> m; for (int i = 0; i < 2220; i++) { if (i % 2 == 0) { a += 5 ; b += 4 ; } else { a += 4 ; b += 5 ; } } a += 5 ; b += 5 ; cou...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tests; cin >> tests; for (int test = 0; test < tests; ++test) { int n; cin >> n; vector<...
#include <bits/stdc++.h> using namespace std; int c1, c2, c3, c4, n, m; int rs1, rs2, rs3, rs4, rs; int a, b; int main() { ios_base::sync_with_stdio(0); ; cin.tie(0); ; cin >> c1 >> c2 >> c3 >> c4; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a; rs1 += min(a * c...
#include <bits/stdc++.h> using namespace std; static inline void WRITE(int a) { printf( %d n , a); } static inline void WRITE2(int a, int b) { printf( %d %d n , a, b); } const int S9 = 1000000007, S6 = 1000007, S5 = 100007, S4 = 10007, S3 = 1007, S2 = 107; const double E2 = 0.01, E4 = 0.0001, E6 =...
// 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 : Fri Sep 22 22:04:40 2017 // Host : DarkCube running 64-bit major release ...
#include <bits/stdc++.h> const int inf = (1ll << 30) - 1; const int maxn = (int)1e5 + 10; using namespace std; int dp[150][(1 << 16) + 100]; int c[111]; int r[111]; int b[111]; char temp[111]; int cntR[(1 << 16) + 10]; int cntB[(1 << 16) + 10]; int n; void solve() { memset(dp, -1, sizeof dp)...
#include <bits/stdc++.h> using namespace std; const long double radian = 180 / acos(-1); int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long x, mini = LLONG_MAX, p; cin >> x; x %= 360; if (x < 0) x = 360 + x; for (int i = 0; i < 4; i++) { if (min...
// file: Clock48MHZ_exdes.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 dis...
#include <bits/stdc++.h> using namespace std; const int INF = (1 << 30) - 1; const long double EPS = 1e-9; const long double PI = fabs(atan2(0.0, -1.0)); const int MAXV = 80010; int n; vector<int> g[MAXV]; void load() { scanf( %d , &n); for (int i = 0, u, v; i < n - 1; i++) { scanf( %d%d ,...
#include <bits/stdc++.h> using namespace std; double eps = 1e-7; int n, m, A, B, a[6010]; int cmp(double x) { if (x > eps) return 1; if (x < -eps) return -1; return 0; } struct line { double k, b; line(double _k, double _b) { k = _k, b = _b; } line(double __x) { k = 2, b = -2 * __x; ...
#include <bits/stdc++.h> using namespace std; int main() { pair<int, int> u, v; int n, ans = 0; long long a, b, c, p, q; scanf( %d%d%d%d , &u.first, &u.second, &v.first, &v.second); scanf( %d , &n); while (n--) { scanf( %lld%lld%lld , &a, &b, &c); p = a * u.first + b * u.second +...
#include <bits/stdc++.h> using namespace std; string a; int main() { int t; cin >> t; while (t--) { int n; cin >> n; cin >> a; for (int i = 0; i < a.length(); i += 2) cout << a[i]; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; void task(); int main() { srand(time(0)); ios_base::sync_with_stdio(0); task(); return 0; } vector<int> prefix_function(string s) { int n = s.length(); vector<int> p(n, 0); for (int i = 1; i < n; ++i) { int j = p[i - 1]; whi...
/* * 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() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, h; cin >> n >> m >> h; vector<int> ms(m), ns(n); vector<vector<int> > ok(n, vector<int>(m)); for (int i = 0; i < m; i++) { cin >> ms[i]; } for...
/** * 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 long long maxn = 1e6 + 00; const long long inf = 1e9 + 800; long long a[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, r, sum = 0; ; cin >> n >> r; for (long long i = 0; i < (1 << n); i++) ...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; int n, k; while (t--) { char a[3] = { a , b , c }; cin >> n >> k; int temp = k; ...
/* * 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) 2017 Andrew Zonenberg and contributors * * ...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); int l[n]; for (int i = 0; i < n; ++i) { l[i] = n; } for (int i = 0; i < n; ++i) { for (int j = 1; j <= min(n - i - 1, i); ++j) { if (s[i - j] == s[i] && s[i] == s[i + j]) ...
// This pass performs an optimisation that decomposes wide arithmetic // comparisons into LUT-size chunks (as guided by the `LUT_WIDTH // macro) connected to a single lookahead-carry-unit $lcu cell, // which is typically mapped to dedicated (and fast) FPGA // carry-chains. (* techmap_celltype = "$lt $le $gt $ge...
/* **************************************************************************** This Source Code Form is subject to the terms of the Open Hardware Description License, v. 1.0. If a copy of the OHDL was not distributed with this file, You can obtain one at http://juliusbaxter.net/ohdl/ohdl.txt Description: mo...
#include <bits/stdc++.h> using namespace std; int a, b, h, n, i; long long x, ans; pair<pair<int, int>, int> p[100005]; map<long long, long long> f; void update(int index, long long value) { while (index < 1e9) { f[index] = max(f[index], value); index += (-index & index); } } long lo...
#include <bits/stdc++.h> using namespace std; int n; struct SegTree { int L, R, P, DELTA; struct node { int d; bool zero; } v[212345 * 4]; inline void set_zero(int x) { v[x].zero = 1; v[x].d = 0; } inline void fix(int x, int d) { v[x].zero = 0; v[x].d +=...
#include <bits/stdc++.h> #pragma GCC optimize( inline ) int rd() { register int k = 0; char c = getchar(); while (c > 9 || c < 0 ) c = getchar(); while (c >= 0 && c <= 9 ) k = k * 10 + c - 48, c = getchar(); return k; } const int N = 100001; struct Q { int o, t, l, r; } q[N]; ...
Require Import AutoSep. (** * The simplest function *) Definition diverger := bmodule "diverger" {{ bfunction "diverger"() [SPEC reserving 0 PRE[_] [| True |] POST[_] [| False |] ] Diverge end }}. (* Eval compute in compile diverger. *) Theorem divergerOk : moduleOk diverger. vcgen; sep_auto. Qed....
#include <bits/stdc++.h> using namespace std; bool b[150000] = {0}; bool dfs(int n, vector<set<int>>& v) { b[n] = 1; for (auto itr = v[n].begin(); itr != v[n].end(); itr++) { if (!b[*itr]) if (v[n] != v[*itr]) return 0; if (!b[*itr]) dfs(*itr, v); } return 1; } int main() {...
/** * 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; void past_code(); void file() {} long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } long long todic(string z) { long long sum = 0; long long j = 1; for (long long i = 0; i < z.length(); i++) { sum +=...
#include <bits/stdc++.h> using namespace std; long long in() { int32_t x; scanf( %d , &x); return x; } const long long maxn = 1e5 + 10; const long long mod = 1e9 + 7; const long long inf = 1e9 + 10; vector<long long> g[maxn]; long long deg[maxn]; long long a[maxn]; bool mark[maxn]; lon...
#include <bits/stdc++.h> using namespace std; const long long N = 200005; long long n, m, u, v, k; long long flag; long long a[N]; long long x, y, z; long long aa, bb, cc, dd; long long ans[100005]; long long sum; void init() {} long long gcd(long long x, long long y) { if (!y) return x; r...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); long k; scanf( %ld , &k); int d; scanf( %d , &d); long arr[n]; for (int i = 0; i < n; i++) { ci...
#include <bits/stdc++.h> using namespace std; void incr(long long &st, long long &en, long long &k, long long val) { en++; if (val <= k) { k++; } } void decr(long long &st, long long &en, long long &k, long long val) { long long sz = en - st + 1; if (val < k) { k -= val; sz...
#include <bits/stdc++.h> using namespace std; int32_t main() { long long int n; cin >> n; long long int ar[n + 1]; for (long long int i = 0; i < n; i++) cin >> ar[i]; sort(ar, ar + n, greater<long long int>()); vector<long long int> v, ans; for (long long int i = 0; i < n; i++) { v...
#include <bits/stdc++.h> using namespace std; char str[210], in[10]; int cnt[10], r[10]; int main() { scanf( %s %s , in, str); int l = strlen(in); for (int i = 0; i < l; i++) { if (in[i] == 9 ) cnt[6]++; else if (in[i] == 5 ) cnt[2]++; else cnt[in[i] - 0 ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:55:04 12/14/2010 // Design Name: // Module Name: msu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: // R...
/** * 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 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...
`timescale 1ns / 1ps module virtual_master( /* - This is just done for simultion purposes, the module implements a task that sends data over the I2C bus */ output reg SDA, output reg SCL, output reg dbg=0 ); reg [7:0] dataSent = 8'bz0zzz0zz, addressSent=8'bzzz0000z; //DATA BB, ADD E1 integer i=0; t...
#include <bits/stdc++.h> using namespace std; const int MAXN = 3000; vector<int> E[MAXN]; long long dp[MAXN][MAXN]; int P[MAXN][MAXN]; int T[MAXN][MAXN]; int n; bool cmp(int a, int b) { return dp[a] > dp[b]; } void dfs(int x, int p, int r) { P[r][x] = p; int d = 1; for (int i = 0; i < E[x]...
`timescale 1ns / 1ps `define BUS_REQUESTED 1'b1 `define BUS_NOT_REQUESTED 1'b0 `define BUS_GRANTED 1'b1 `define BUS_NOT_GRANTED 1'b0 module arbiter( grant1, grant2, request_p1, request_p2, enable, reset, clk ); // outputs from the module output reg grant1; output reg grant2; // inputs to the module inpu...
/* wb_intercon_tb. Part of wb_intercon * * ISC License * * Copyright (C) 2019 Olof Kindgren <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies...
#include <bits/stdc++.h> using namespace std; int main() { int N = 0, p = 0, q = 0; int k = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> p >> q; if (q - p >= 2) k++; } cout << k; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f; int main() { int n, a, x, b, y; cin >> n >> a >> x >> b >> y; while (a != x && b != y) { a++; if (a > n) a = 1; b--; if (b < 1) b = n; if (a == b) { printf( Y...
#include <bits/stdc++.h> using namespace std; int suspect[100000]; int justify[100000]; bool killer[100000]; pair<int, int> a[100000]; int main() { int n, m; scanf( %d%d , &n, &m); int cnt = 0; for (int i = 0; i < n; i++) { killer[i] = false; char x; int k; scanf( %d ...
#include <bits/stdc++.h> using namespace std; int a[1000100], g[1000100]; int main() { for (int i = 1; i < 20; i++) { int msk = (1 << i) - 1; for (int j = (1 << i - 1); j < (1 << i); j++) { g[j] = (1 << i - 1) | g[j ^ msk]; } } int n, x; scanf( %d , &n); for (int i = ...
module testbench(); localparam width_p = 8; logic [width_p-1:0] li; logic [`BSG_SAFE_CLOG2(width_p)-1:0] addr_lo; logic v_lo; bsg_priority_encode #( .width_p(8) ,.lo_to_hi_p(1) ) pe ( .i(li) ,.addr_o(addr_lo) ,.v_o(v_lo) ); initial begin li = 8'b0; #(10); assert(v_lo =...
// // 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...
/** * 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 Solution() { int n; cin >> n; string s; cin >> s; int cnt = 0; for (int i = 0; i < n; ++i) cnt += (s[i] == H ); s += s; int ans = 0x7fffffff; for (int i = 0; i < n; ++i) { int dif = 0; for (int j = 0; j < cnt; ++j) ...