text
stringlengths
59
71.4k
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// module read_cycle_tb; reg RESET; reg CLK14M; wire CLK; reg AS20; reg DS20; reg RW20; reg [31:0] A; reg [31:0] D_OUT; reg [1:0] SIZ; wire [1:0] DSACK; wire RA...
module decoder (cx,d); output [6:0] d; input [10:0] cx; reg [6:0] d; reg [6:0] s; reg [10:0] cx1; parameter s0 = 7'b1000; parameter s1 = 7'b0100; parameter s2 = 7'b0010; parameter s3 = 7'b0001; parameter s4 = 7'b0111; parameter s5 = 7'b0101; parameter s6 = 7'b0010; parameter s7 = 7'b1001; parameter s8...
//Legal Notice: (C)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 do...
#include <bits/stdc++.h> using namespace std; bool BeauYear(int y) { int a = y % 10; int b = (y / 10) % 10; int c = (y / 100) % 10; int d = (y / 1000) % 10; if (a != b && a != c && a != d && b != c && b != d && c != d) return true; return false; } int main() { ios_base::sync_with_std...
/** * 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...
//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 associate...
`timescale 1 ns / 1 ps // Simple counter for BRAM addressing // // Write enable is set to 1 for one cycle // after a rising edge is detected on the trigger module address_counter # ( parameter integer COUNT_WIDTH = 13 ) ( input wire clken, // Clock enable input wire trig, // Trigger input wire clk, outpu...
//alt_oct_power CBX_AUTO_BLACKBOX="ALL" CBX_SINGLE_OUTPUT_FILE="ON" device_family="Stratix IV" parallelterminationcontrol rdn rup seriesterminationcontrol //VERSION_BEGIN 11.0SP1 cbx_alt_oct_power 2011:07:03:21:10:32:SJ cbx_cycloneii 2011:07:03:21:10:33:SJ cbx_lpm_add_sub 2011:07:03:21:10:33:SJ cbx_lpm_compare 2011:07:...
#include <bits/stdc++.h> using namespace std; const int maxn = 1.1e5; queue<int> Q[2]; vector<int> E[maxn]; int n, m, cnt, in[maxn], f[maxn]; signed main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) scanf( %d , f + i); for (int i = 1, x, y; i <= m; ++i) scanf( %d%d , &x, &y), ++i...
#include <bits/stdc++.h> using namespace std; long long int p, pre, k, cnt; vector<long long int> ans; int main() { scanf( %lld %lld , &p, &k); if (p < k) { printf( 1 n%lld n , p); return 0; } pre = p; while (1) { cnt = (k - pre); if (cnt <= 0) { cnt = cnt / k...
#include <bits/stdc++.h> using namespace std; int n; long long a[100005]; int main() { { cin >> n; for (int i = 0; i < n; i++) scanf( %lld , &a[i]); sort(a, a + n); long long ans = LLONG_MAX; for (int c = 1;; c++) { long long now = 1; long long tot = 0; ...
#include <bits/stdc++.h> using namespace std; int solve(); int main() { solve(); } int solve() { string s; vector<int> cnt(26); cin >> s; int ncnt = 0; for (int i = 0; i < s.size(); ++i) ++cnt[s[i] - a ]; for (int i = 0; i < 26; ++i) ncnt += (cnt[i] & 1); while (ncnt > 1) { fo...
#include <bits/stdc++.h> using namespace std; long long pw(long long base, long long e) { return e ? pw(base * base, e / 2) * (e % 2 ? base : 1) : 1; } long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long to_int(string s) { long long ret = 0; for (int i = 0; i <= s.s...
#include <bits/stdc++.h> using namespace std; const double PI = 3.141592653589793238463; void printVec(vector<int> v1) { for (int i = 0; i < v1.size(); i++) cout << v1[i] << ; cout << endl; } int main() { ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); priority_queue<lon...
#include <bits/stdc++.h> using namespace std; int n; vector<int> x; int ax[3]; int main() { ax[0] = ax[1] = ax[2] = 0; cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; int cc = 0; for (int i = 0; i < s.size(); ++i) cc += s[i] - 0 ; x.push_back(cc % 3); ...
module node_noc(clk, rst, data_in, data_in_ready, fifo_in_ready, data_out, data_out_ready); parameter IDLE = 4'b0000; parameter IDLE1 = 4'b1111; parameter KEYWORD = 4'b0001; parameter TEXTFILE = 4'b0010; parameter TEXTFILE_1 = 4'b0011; parameter PAIR_NUM = 10; input clk; input rst; input [31...
#include <bits/stdc++.h> using namespace std; const long long dx[4] = {-1, 0, 1, 0}; const long long dy[4] = {0, -1, 0, 1}; const long long dxx[] = {1, 1, 0, -1, -1, -1, 0, 1}; const long long dyy[] = {0, 1, 1, 1, 0, -1, -1, -1}; void err(istream_iterator<string> it) {} template <typename T, typename... A...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 23:22:46 05/08/2015 // Design Name: branch // Module Name: /media/BELGELER/Workspaces/Xilinx/processor/test_branch.v // Project Name: processor // Target Device: /...
`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 must be 1 10 or 100 * -base is the time base for each unit, ranging from seconds * to femtoseconds, and must be:...
////////////////////////////////////////////////////////////////////// //// //// //// dbg_crc32_d1.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 la...
#include <bits/stdc++.h> using namespace std; struct node { long long t, d, g, h, s, ds, dq, dis, sum; } A[100100]; int p[100100], nxt[2 * 100100], C[2 * 100100], V[2 * 100100], f[100100], g[100100][19], n, q, i, ed; int gi() { int s = 0; char c = getchar(); while (c < 0 || c > 9 ) c ...
/* * TODO: add input and out put buffers that drive I/O signal */ /* * Comperator module: * compare 3 inputs and forward to output samllest element and it's index * this module is combinatorical. * * INPUTS: * d0,d1,d2: are the data inputs * great_n_small: * operation to be performed. '1' - greater index...
#include <bits/stdc++.h> using namespace std; const double pi = 3.1415926535897; int main() { string pass; string str[10]; cin >> pass; for (int i = 0; i < 10; i++) { cin >> str[i]; } for (int i = 0; i < 80; i += 10) { string tmp = pass.substr(i, 10); for (int io = 0; io ...
#include <bits/stdc++.h> using namespace std; long long int c, t, n, a[1000005], b[1000005], used[100005]; int main() { cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; used[i] = 0; } for (int i = 1; i <= n; i++) cin >> b[i]; if (n...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if ((a >= 0 && b < 0) || (a < 0 && b >= 0)) { cout << -1 ; return 0; } if (a == 0 && b == 0) { cout << -1 ; return 0; } if (a < 0 && b < 0) { cout << -1 ; return 0; ...
#include <bits/stdc++.h> using namespace std; char change(char curranswer) { if (curranswer == z ) curranswer = A ; else if (curranswer == Z ) curranswer = 0 ; else if (curranswer == 9 ) ; else curranswer++; return curranswer; } int main() { long long i, j, t...
#include <bits/stdc++.h> using namespace std; set<int> s; int main() { int x; cin >> x; s.insert(x); for (;;) { x++; while (x % 10 == 0) x /= 10; int sz = s.size(); s.insert(x); if (sz == s.size()) { printf( %d , s.size()); return 0; } } } ...
#include <bits/stdc++.h> char ans[100]; int n; int main() { scanf( %s%d , ans, &n); for (int i = 0; i < strlen(ans); i++) { if (ans[i] < a ) ans[i] += a - A ; if (ans[i] < 97 + n) ans[i] += A - a ; } printf( %s n , ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; char S[maxn][10]; int ju(char a[], char b[]) { int n = strlen(a), m = strlen(b); int x = 0, y = 0; for (int i = 0; i < n; i++) x = x * 10 + a[i] - 0 ; for (int j = 0; j < m; j++) y = y * 10 + (b[j] == ? ? 9 : b[j] - 0 ); ...
#include <bits/stdc++.h> using namespace std; bool checkbit(int mask, int bit) { return mask & (1 << bit); } int setbit(int mask, int bit) { return mask | (1 << bit); } int clearbit(int mask, int bit) { return mask & ~(1 << bit); } int togglebit(int mask, int bit) { return mask ^ (1 << bit); } int main() { ...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); vector<int> a(n); for (auto &i : a) scanf( %d , &i); map<int, int> dp; int ans = 0; int last = 0; for (int i = 0; i < n; i++) { int x = a[i]; dp[x] = dp[x - 1] + 1; if (ans < dp[x]) {...
`timescale 1ns / 1ps /* -- Module Name: DES Sbox 3 -- Description: Sbox 3 del algoritmo DES -- Dependencies: -- none -- Parameters: -- none -- Original Author: Héctor Cabrera -- Current Author: -- Notas: -- History: -- Creacion 05 de Junio 2015 */ module des_sbox3 ...
#include <bits/stdc++.h> const long long INF = 2e18; const double EPS = 1e-9; using namespace std; void WEZaa() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } int main() { WEZaa(); unsigned long long n, k; cin >> n >> k; vector<unsigned long long> a(n), b(n...
#include <bits/stdc++.h> using namespace std; struct FenwickTree { vector<int> tree; FenwickTree(int n = 0) { tree.resize(n); } void update(int i, int delta) { for (; i < (int)tree.size(); i |= i + 1) tree[i] += delta; } int sum(int ind) { int sum = 0; while (ind >= 0) { ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; template <typename T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf( %d , &x); } void _R(long long &x) { scanf( % PRId64, &x); } void _R(double &x) { scanf( %lf , &x); } void _R(char &x) { scanf( %c , &x); } void _R(char *x) { scanf( %s , x); }...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); } const int MAXN = 100010; int fst[MAXN], sec[MAXN]; int ans[MAXN]; int N, K; int cmp(const int &a, const int &b) { return a > b; } int main() { while (scanf( %d%d , &N, &K) != EOF) { f...
#include <bits/stdc++.h> using namespace std; char a[100][1000] = {0}; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long int t; cin >> t; while (t--) { long long int n, m, x, y; cin >> n >> m >> x >> y; for (long long int i = 1; i <= n; i++) { for (...
#include <bits/stdc++.h> using namespace std; int max_height(long long n) { return (long long)(sqrt(24 * n + 1) - 1) / 6; } int main() { int t; cin >> t; while (t--) { long long n; cin >> n; int pyramids = 0; while (1) { long long height = max_height(n); if (!he...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 2e5 + 5; int n, k, d, ansL = 1, ansR = 1, top1, top2, flag, pos; int a[MAXN], st1[MAXN], st2[MAXN]; map<int, int> lst; namespace SegmentTree { struct Tree { int l, r; int w, tag; } tree[MAXN << 2]; voi...
#include <bits/stdc++.h> using namespace std; const int N = 50005; const unsigned long long MOD = 1e8 + 7; const unsigned long long MAX = 1e15; int X[N], Y[N], T[N], K[N]; int n; double P[N], dp[N], ans = 0; bool cmp(int a, int b) { return T[a] < T[b]; } double dist(int i, int j) { double ans = sq...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n < 6) cout << -1 << endl; else { for (int i = 2; i <= 4; i++) cout << 1 << << i << endl; for (int i = 5; i <= n; i++) { cout << 2 << << i << endl; } } for (int i = 1; i < ...
(* Copyright © 1998-2006 * Henk Barendregt * Luís Cruz-Filipe * Herman Geuvers * Mariusz Giero * Rik van Ginneken * Dimitri Hendriks * Sébastien Hinderer * Bart Kirkels * Pierre Letouzey * Iris Loeb * Lionel Mamane * Milad Niqui * Russell O’Connor * Randy Pollack * Nickolay V. Shmyrev * Bas Spitters * ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, inf = 0x3f3f3f3f; void cmin(int& x, int y) { if (x > y) { x = y; } } int n, a[N]; long long answer; vector<int> adj[N]; void dfs(int u, int p, int d, int s) { if (d & 1) { answer += a[u] - s; s = a[u]; ...
#include <bits/stdc++.h> using namespace std; int main() { int n = 0, m = 1, i = 0, j = 0, k = 0, x = 0; int area[51][51] = {0}; cin >> n; for (i = 0; i < n; i++) for (x = 0; x < n; x++) cin >> area[i][x]; for (i = 0; i < n; i++) for (x = 0; x < n; x++) if (area[i][x] != 1) {...
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int a[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { int flag = 1; for (int j = i - 1; j >= 1 && j >= i - x; j--) { if (a[i] > a[j]) { ...
#include <bits/stdc++.h> using namespace std; const int N = 101; int a[N]; int n; int main() { int i, t; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); t = a[0]; a[0] = a[n - 1]; a[n - 1] = t; for (i = 0; i < n; i++) cout << a[i] << ; cout << endl; re...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<int, int> mp; map<int, int> np; for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; int p = y - x; int q = y + x; mp[p]++; np[q]++; } map<int, int>::iterator it; in...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, l, r, l1 = 0, r1 = 1e9, l2 = 0, r2 = 1e9; cin >> n; for (i = 0; i < n; i++) { cin >> l >> r; l1 = max(l1, l); r1 = min(r1, r); } cin >> n; for (i = 0; i < n; i++) { cin >> l >> r; l2 = max(l2, ...
#include <bits/stdc++.h> using namespace std; int n, ar[1010]; bool b[1010]; int main() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> ar[i]; } for (int i = 1; i <= n; ++i) { int yk = i; while (1) { if (b[yk]) break; b[yk] = 1; yk = ar[yk]; } ...
#include <bits/stdc++.h> using namespace std; unordered_map<int, int> mapa; vector<int> tab; int main() { ios_base::sync_with_stdio(false); int n, k, a; cin >> n >> k; int aktIlosc = n; for (int i = 0; i < n; i++) { cin >> a; if (mapa[a] == 0) tab.push_back(a); mapa[a]++; ...
/* * 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; struct point { int x, y; }; int F[500][500]; int x, y; void Init() { F[0 + 200][0 + 200] = 0; F[1 + 200][0 + 200] = 0; F[1 + 200][1 + 200] = 1; F[-1 + 200][1 + 200] = 2; F[-1 + 200][-1 + 200] = 3; for (int i = 2; i <= 110; i++) ...
#include <bits/stdc++.h> using namespace std; long long n, cnt; long long arr[100000], h[100000]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (long long i = 0; i <= n - 1; i++) { cin >> arr[i]; h[i] = arr[i]; } sort(h, h + n); for (long long i = 0...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000 * 1000 * 1000 + 7; inline long long mod(long long n) { if (n < 0) { return (n % MOD + MOD) % MOD; } else { return n % MOD; } } long long fp(long long a, long long p) { long long ans = 1, cur = a; for (long...
#include <bits/stdc++.h> using namespace std; inline bool check_diags(int x0, int y0, int x, int y) { return abs(x0 - x) == abs(y0 - y); } inline bool check_lines(int x0, int y0, int x, int y) { return x - x0 == 0 || y - y0 == 0; } vector<int> a, b, c, d; int n, x, s, m, k; void read() { 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...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.3 (lin64) Build Wed Oct 4 19:58:07 MDT 2017 // Date : Tue Oct 17 19:49:26 2017 // Host : TacitMonolith running 64-bit Ubuntu 16.04.3...
// This is a component of pluto_step, a hardware step waveform generator // Copyright 2007 Jeff Epler <> // // 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 ...
//----------------------------------------------------------------------------- // // (c) Copyright 2012-2012 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 ...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; int n; pair<long long, long long> a[maxn + 1]; pair<long long, long long> b; priority_queue<long long, vector<long long>, greater<long long> > q; bool cmp(pair<long long, long long> a, pair<long long, long long> b) { return a > b;...
#include <bits/stdc++.h> long long a[100001]; int main() { int n; scanf( %d , &n); int i, j, k; int m = n / 2; for (i = 1; i < n; i += 2) { scanf( %I64d , &a[i]); } long long cur = 100000000000001LL; for (i = n - 1; i >= 1; i -= 2) { bool ok = false; for (k = 2 - a[...
`ifdef __ICARUS__ `define SUPPORT_CONST_OUT_OF_RANGE_IN_IVTEST `endif module top; reg pass; parameter [7:0] in = 8'b10100101; reg [3:0] out; initial begin pass = 1'b1; `ifdef SUPPORT_CONST_OUT_OF_RANGE_IN_IVTEST out = in[7:'dx]; `else out = 4'bxxxx; `endif if (out !== 4'bxxxx) begin $...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[5] = {0}; for (int i = 0; i < n; ++i) { int tmp; cin >> tmp; arr[tmp]++; } int ret = arr[4]; ret += min(arr[1], arr[3]); ret += arr[2] / 2; if (arr[3] > arr[1]) { ret += ar...
/* * 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 Header Begin ========================================== // // OpenSPARC T1 Processor File: sctag_scbuf_rptr2.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...
#include <bits/stdc++.h> using namespace std; int nextt[200007], c[200007], vis[200007]; long long ans, n; template <class T> void read(T &x) { int f = 0; x = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) { f |= (ch == - ); ch = getchar(); } while (ch >= 0 && ch <...
#include <bits/stdc++.h> using namespace std; long long n, m, k, i, j, a[1000000], b[1000000], x, res = 1; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { cin >> x; b[x] = i; } while (b[a[res]] > b[a[res - 1]]) { res++; ...
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { int n, k, x, sum; scanf( %d %d , &n, &k); for (int i = 0; i < (n); i++) scanf( %d , &a[i]); int ng = 0, ps = 0, nm = -(1 << 28), pm = (1 << 28); for (int i = 0; i < (n); i++) { if (a[i] < 0) ng++; els...
/*------------------------------------------------------------------------ Purpose Clocks generation. ------------------------------------------------------------------------*/ module tenv_clockgen #(parameter clocks_number=2) ( input[(clocks_number-1):0] init, ...
/* The test bench for an 8 bit shift-register FIFO. * * Case I: * Tests the FIFO by writing eight 1s and reading them back. * * Created by David Tran * Version 0.1.0.0 * Last Modified:04-24-2014 */ `include "shift_fifo.v" module shift_fifo_tb ( readMode, // Specifies if we want to read to the FIFO wr...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long n; cin >> n; n = 4 * n; for (long long i = 0; i < (n / 4); i++) { cout << n - (2 * i) << ; } c...
module system ( processing_system7_0_MIO, processing_system7_0_PS_SRSTB, processing_system7_0_PS_CLK, processing_system7_0_PS_PORB, processing_system7_0_DDR_Clk, processing_system7_0_DDR_Clk_n, processing_system7_0_DDR_CKE, processing_system7_0_DDR_CS_n, processing_system7_0_DDR_RA...
#include <bits/stdc++.h> using namespace std; const long long MAX = 10e5; vector<long long> graph[MAX]; queue<long long> q; bool visit[MAX]; long long a[MAX]; long long s[MAX]; long long parent[MAX]; int main() { memset(visit, false, sizeof(visit)); long long nodes; cin >> nodes; 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 law...
`define CYCLE_TIME 50 module TestBench; reg Clk; reg Reset; reg Start; integer i, outfile, outfile2, counter; reg flag; reg [26:0] address; reg [23:0] tag; reg [4:0] index; wire [256-1:0] mem_cpu_data; wire mem_cpu_ack; wire [256-1:0] cpu_mem_data; wire [32-1:0] cpu_mem_addr; wire ...
#include <bits/stdc++.h> using namespace std; const int D = 1e6 + 3; const int MAXN = 110; int F[MAXN]; struct Mt { int v[MAXN][MAXN]; int N, M; Mt() { for (int i = 0; i < MAXN; i++) { for (int j = 0; j < MAXN; j++) { v[i][j] = 0; } } } void I() { ...
#include <bits/stdc++.h> using namespace std; int N, Y[50001]; set<int> pos[50001]; set<int> used; priority_queue<int> q; int next(int x) { int temp = x; while (x != 0) { if (used.count(x) == 0) return x; x /= 2; } return temp; } int main() { cin >> N; for (int i = 0;...
#include <bits/stdc++.h> using namespace std; long long n, m, k, x, y, z, a[5005], b[50005], ans, val; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n; for (long long i = 0; i < n; i++) cin >> a[i]; cin >> m; for (long long i = 0; i < m; i++) cin >> b[i]; s...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2005,2006 Matt Ettus // // 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 Li...
/** * 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() { string s; cin >> s; s = * + s; int add = 0; int n = (s.length()) - 1; for (int i = 1; i + i <= n; i++) { if (s[i] != s[s.size() - i]) { add++; } } if (add <= 1 && (n & 1) || add == 1) cout << YES ...
/* * 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> int main() { char x[205]; scanf( %s , x); for (int i = 0; i < strlen(x); i++) { if (x[i] == . ) { x[i] = 0 ; printf( %c , x[i]); } if (x[i] == - && x[i + 1] == . ) { x[i] = 1 ; printf( %c , x[i]); i = i + 1; } ...
#include <bits/stdc++.h> using namespace std; int t, memo[402][402][402], idx, n, m; string x, y; void read(string &s) { char c[404]; scanf( %s , c); s = c; } int dp(int i, int j, int k) { if (i == n) { if (k == m) return j; else return -10; } int &ret = m...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; long long a[N], pre[N]; int n; long long check(int p, int len) { return pre[p] - pre[p - len - 1] + pre[n] - pre[n - len]; } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); sort(a + 1, a +...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vd = vector<double>; using vs = vector<string>; using vpii = vector<pair<int, int>>; using vpll = vec...
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; cin >> n; getchar(); string s; cin >> s; int ans = 1000000; string cnt = ; for (int i = 0; i < n; ++i) { cnt += s[i]; string s1 = cnt; string s2 = s.substr(i + 1, i + 1);...
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; for (int k = 0; k < t; k++) { int n, total = 0; cin >> n; while (n / 10 > 0) { total = total + (n - (n % 10)); n = ((n - (n % 10)) / 10) + n % 10; } cout << total + (n % 10...
#include <bits/stdc++.h> int NEXT_FREE_ID = 0; std::unordered_map<std::string, int> stringId; namespace persistentid { int NEXT_FREE_INDEX = 1; int s[10000000], L[10000000], R[10000000]; int root[100005]; int n = 1 << 30; int upd(int p, int v, int id, int l = 0, int r = n) { int ID = NEXT_FREE_INDEX...
#include <bits/stdc++.h> using namespace std; int N; vector<int> fen, v; void _update(int i) { while (i <= N) { fen[i]++; i += i & -i; } } int _sum(int i) { int ret = 0; while (i > 0) { ret += fen[i]; i -= i & -i; } return ret; } int _bin(int i) { int ...
// // 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> int cnt; int n, m, k; char s[1111][1111]; int c[1111][1111], vis[1111][1111]; int b[1111]; int tot; void dfs(int p, int q) { c[p][q] = cnt; vis[p][q] = 1; if (s[p - 1][q] == . && !vis[p - 1][q]) dfs(p - 1, q); if (s[p - 1][q] == * ) tot++; if (s[p + 1][q] ==...
#include <bits/stdc++.h> using namespace std; class Data { public: int l, r, num; Data() {} Data(int a, int b, int c) { l = a; r = b; num = c; } bool operator<(const Data& a) const { return l < a.r; } }; vector<Data> a; int main() { int L, b, f, n, q, k; cin >>...
#include <bits/stdc++.h> using namespace std; int p[50001], n, l, r; queue<int> ver[50001]; void go(int pre, int v) { int t; p[v] = pre; if (v != l) { while (!ver[v].empty()) { t = ver[v].front(); ver[v].pop(); if (t != pre) go(v, t); } } } int main() { ...