text
stringlengths
59
71.4k
//-------------------------------------------------------------------------------- // prescaler.vhd // // Copyright (C) 2006 Michael Poppitz // // 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...
`define CLOG2(x) \ (x <= 2) ? 1 : \ (x <= 4) ? 2 : \ (x <= 8) ? 3 : \ (x <= 16) ? 4 : \ (x <= 32) ? 5 : \ (x <= 64) ? 6 : \ (x <= 128) ? 7 : \ (x <= 256) ? 8 : \ -1 module sync_fifo #( parameter DEPTH = 3, ...
#include <bits/stdc++.h> using namespace std; int main() { vector<int> ans, a; int n, temp; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &temp); a.push_back(temp); } for (int i = 0; i < a.size(); i++) { if (a[i] == 1) { ans.push_back(1); } else {...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, W, i, j, k; cin >> n >> m >> W; long long w[n], b[n]; for (i = 0; i < n; i++) cin >> w[i]; for (i = 0; i < n; i++) cin >> b[i]; vector<long long> G[n]; for (i = 0; i < m; i++) { cin >> j >> k; j--; ...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module spi #( parameter BASEADDR = 16'h0000, p...
#include <bits/stdc++.h> using namespace std; long long int n, k; long long int i; long long int sum = 0; long long int cheng = 1; long long int ans[200010]; struct xxx { long long int num; long long int id; bool operator<(const struct xxx &node) const { return num > node.num; } } xxx[200010...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.4 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2011 Xilinx Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // // ____ ___ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Versi...
#include <bits/stdc++.h> using namespace std; const int N = 500005; int n, m, h[N], mn[N], par[N], t, num, op, uo, ra; vector<int> adj[N]; set<int> answer, qtr; bool finish, q[N], vis[N]; struct edge { int u, v; } ed[N]; void output() { if ((int)answer.size() == n) { cout << NO << n ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003 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 License...
//Legal Notice: (C)2013 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...
/* * 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...
// registerfile_io32.v // This file was auto-generated as a prototype implementation of a module // created in component editor. It ties off all outputs to ground and // ignores all inputs. It needs to be edited to make it do something // useful. // // This file will not be automatically regenerated. You should ch...
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k, m, n, x, y; cin >> n; if (n == 1) { x = 9; y = 8; } if (n == 2) { x = 6; y = 4; } if (n == 3) { x = 9; y = 6; } if ((n != 2) && (n != 1) && (n != 3)) { if (...
/** * 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> template <typename T> class IntegerIterator : public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> { public: explicit IntegerIterator(int value) : value(value) {} IntegerIterator& operator++() { ++value; return *this; } IntegerIterator...
/* * CameraOneFrame architecture * * Copyright (c) 2014, * Luca Maggiani <> * Scuola Superiore Sant'Anna (http://www.sssup.it) and * Consorzio Nazionale Interuniversitario per le Telecomunicazioni * (http://www.cnit.it). * * All rights reserved. * * Redistribution and use in source and binary forms, wi...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const double PI = acos(-1.0); long long f[555], n; string g[] = { < , ^ , > , v }; string s, t; int main() { cin >> s >> t; cin >> n; if (n % 2 == 0) { cout << undefined ; return 0; } for (int i = 0;...
#include <bits/stdc++.h> using namespace std; struct Trie { struct Node { char c; vector<pair<int, int> > n; Node* ch[26]; Node(char ch) { this->c = ch; for (int i = 0; i < 26; i++) this->ch[i] = NULL; } }; Node* root; vector<pair<int, int> > res; in...
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; const int maxn = 200000 + 10; inline void read(int &x) { int f = 1; x = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { ...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 1e9; const long long LINF = INF * (long long)INF + 100; const double EPS = 1e-7; const int MAX = 20 * 1000 + 47; const int MAS = 2 * 1e5 + 10; const int MOD = 998244353; int main() { ios_base::sync_with_std...
#include <bits/stdc++.h> using namespace std; template <typename _T> void read(_T &x) { _T f = 1; x = 0; char s = getchar(); while (s > 9 || s < 0 ) { if (s == - ) f = -1; s = getchar(); } while ( 0 <= s && s <= 9 ) { x = (x << 3) + (x << 1) + (s ^ 48); s = ge...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; const int N = 1e7 + 5; const int M = 25; int A[M], B[M], n, m, x, y, cnt; int dp[M * 4][M * 4]; void Min(int &x, int y) { x = min(x, y); } int main() { cin >> n >> m; for (int i = 0; i < n; ++i) cin >> A[i]; for (int i = 0; i < n; ++i) cin >> B[i];...
#include <bits/stdc++.h> using namespace std; string s, v; int ans, p, t; char c; char tr[1000]; int mypow(int k) { int c = 1; for (int i = 1; i <= k; i++) { c *= 2; } return c; } int main() { gets(tr); s = (string)tr; p = 0; for (int i = 0; i < s.length(); i++) { ...
////////////////////////////////////////////////////////////////////// //// //// //// Generic Single-Port Synchronous RAM //// //// //// //// This file is part of memory li...
#include <bits/stdc++.h> using namespace std; const float pi = acos(-1.0); const int maxn = 1e5 + 5; int c[maxn]; long long a[5][maxn], b[maxn]; vector<int> vec[maxn]; void dfs(int u, int fa) { for (auto p : vec[u]) { if (p != fa) { c[p] = 6 - c[u] - c[fa]; dfs(p, u); } ...
// handles transmission over UART module uart_tx ( input wire clk, input wire reset, input wire tx_start, input wire s_tick, input wire [7:0] din, output reg tx_done_tick, output wire tx ); parameter DBIT = 8; parameter SB_TICK = 16; localparam IDLE = 0; localparam ST...
#include <bits/stdc++.h> using namespace std; int k; int n; int planks[1005]; int g = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> k; for (int t = 0; t < k; t++) { cin >> n; for (int i = 0; i < n; i++) cin >> planks[i]; sort(planks, ...
#include <bits/stdc++.h> long long A[100000]; using namespace std; int main() { long long n, s = 0, m = -100000, a = 0, p; cin >> n; for (int i = 0; i < n; i++) { cin >> A[i]; if (A[i] % 2 == 0 && A[i] > 0) s += A[i]; } std::sort(A, A + n); for (int i = n - 1; i >= 0; i--) { ...
#include <bits/stdc++.h> template <typename _Tp> void read(_Tp &x) { char ch(getchar()); bool f(false); while (!isdigit(ch)) f |= ch == 45, ch = getchar(); x = ch & 15, ch = getchar(); while (isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar(); if (f) x = -x; } template <typename _Tp, ty...
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const long long INF = 1e18; const int maxn = 1e6 + 6; const int mod = 1e9 + 7; const double eps = 1e-9; inline bool read(long long &num) { char in; bool IsN = false; in = getchar(); if (in == EOF) return false; while...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j; cin >> n >> m; for (i = 1; i <= n; i++) { int c = i / 2; if (i % 2 != 0) { for (j = 0; j < m; j++) { cout << # ; } cout << endl; } else if (c % 2 == 0) { cout << # ; ...
// -- (c) Copyright 2009 - 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 disclaimer is not a...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, amazing = 0, maxx, minn, k; cin >> n; cin >> k; maxx = k; minn = k; for (int i = 1; i < n; i++) { cin >> k; if (k > maxx) { maxx = k; amazing++;...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const double PI = acos(-1.0); const long long int mod = 1e9 + 7; const int MAXN = 1e6 + 5; void cp() { int n, k; string s; cin >> n >> k >> s; vector<pair<int, int> > group; int l = 0, r = 0; while (l < n) { ...
#include <bits/stdc++.h> using namespace std; const int MAXN = (1e5 + 5) * 2; void Max(int &x, int y) { if (x < y) x = y; } int n, m; int a[MAXN]; int dp[MAXN]; bool chk1(int s, int x) { memset(dp, 0, sizeof(dp)); for (int i = s, iend = s + n - 1; i <= iend; ++i) { int d = a[i + 1] - a...
#include <bits/stdc++.h> using namespace std; const int maxn = 110000; int n, q; map<pair<int, int>, int> M; int u[maxn], v[maxn]; int s[maxn], e[maxn]; vector<int> V[maxn << 4]; struct DSU { int fa[maxn], col[maxn], sz[maxn]; stack<pair<pair<int *, int>, int>> stk; int findfa(int x, int &va...
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> a[100010]; int x; int now; void print() { cout << YES << endl; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cout << a[i][j] << ; cout << endl; } } int main() { cin >> n >> m; now = 1; ...
#include <bits/stdc++.h> using namespace std; int l[100000], r[100000], u[100000], d[100000]; int dp[2], dp2[2]; int main() { int i; int n, m, q; char c; scanf( %d %d %d , &n, &m, &q); for (i = 0; i < n; i++) scanf( %c , &c), l[i] = (c == B ); for (i = 0; i < n; i++) scanf( %c , &c), ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ...
/* * 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; template <class T> inline T sqr(const T& a) { return a * a; } const long double EPS = 1e-9; const long double PI = 2 * acos(0.0); const int N = 100000; int counts[N]; int xors[N]; vector<int> g[N]; queue<int> qq; vector<pair<int, int> > ans; in...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007, inf = 1000000000; const int N = 100010; inline int read() { char ch; while (!isdigit(ch = getchar())) ; int x = ch - 0 ; while (isdigit(ch = getchar())) x = (x << 1) + (x << 3) + ch - 0 ; return x; } ...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); if (n < 4) printf( NO n ); else if (n % 2) { printf( YES n ); printf( 1 + 5 = 6 n3 - 2 = 1 n4 * 6 = 24 n24 * 1 = 24 n ); for (int j = n; j > 6; j -= 2) { printf( %d - %d = 1 n , j, j - ...
/* * 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 law...
#include <bits/stdc++.h> using namespace std; int main(void) { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> ans1, ans2; string a, b; cin >> a >> b; a = a + 0 ; b = b + 0 ; for (int i = 0; i < n; i++) { if (a[i] != a[i + 1]) ans1.pu...
#include <bits/stdc++.h> using namespace std; int main() { int n, a = 0, b = 0; int t; for (int i = 0; i < 3; ++i) { cin >> t; a += t; } a = (a + 4) / 5; for (int i = 0; i < 3; ++i) { cin >> t; b += t; } b = (b + 9) / 10; cin >> n; if (a + b > n) ...
#include <bits/stdc++.h> using namespace std; void getmax(int &a, const int b) { if (b > a) a = b; } struct Segment { int l, r; Segment() {} Segment(const int _l, const int _r) : l(_l), r(_r) {} bool operator<(const Segment &s) const { return l != s.l ? l < s.l : r > s.r; } }; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 300010; long long p, q, b; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } bool ok() { long long m = gcd(p, q); q /= m; m = b; while (q != 1) { m = gcd(q, m); q /= m; if (m == 1) break; ...
#include <bits/stdc++.h> using namespace std; const int base = 13331; const int MOD = 1e9 + 7; const int MOD1 = 998244353; const int mod = 65536; const long long INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const int N = 1e6 + 10, M = 20000010; const int NN = 3e5 + 10; inline long lo...
#include <bits/stdc++.h> int main() { int a, b, c; scanf( %d%d%d , &a, &b, &c); if ((a + b) == c || (c + b) == a || (a + c) == b) { printf( 1 ); } else { if ((a + b) < c) { printf( %d , (c - b - a + 1)); } else if (b + c < a) { printf( %d , (a - b - c + 1)); } e...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:10000000 ) using namespace std; template <typename T> inline T abs(T a) { return ((a < 0) ? -a : a); } template <typename T> inline T sqr(T a) { return a * a; } const int INF = (int)1E9 + 7; const long double EPS = 1E-9; const long d...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int s1[n]; int s2[n]; for (int i = 0; i < n; i++) cin >> s1[i]; for (int i = 0; i < n; i++) cin >> s2[i]; for (int i = 0; i < n; i++) s1[i]--, s2[i]--; int arr[n]; for (int i = 0; i < n; i++) { arr[...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a == 0 && b == 0) { cout << NO ; return 0; } if (abs(a - b) <= 1) cout << YES ; else cout << NO ; }
#include <bits/stdc++.h> using namespace std; int main() { string s, p = ; cin >> s; int i, j = 0, f = 0, start, end; for (i = s.size() - 1; i >= 0 && f == 0; i--) { if (s[i] != 0 ) { end = i; f = 1; } } f = 0; for (i = 0; i < s.size() && f == 0; i++) { ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2004 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=1; reg [31:0] a, b, c, d, e, f, g; always @ (*) begin // Te...
/** * This is written by Zhiyang Ong * for EE577b Extra Credit Homework , Question 2 * * Behavioral model for the Hamming decoder */ module ham_15_11_decoder (c,q); // Output signals representing the 11-bit decoded vector output reg [10:0] q; // Input signals representing the 15-bit input input [14:0] c; ...
/* * Copyright (c) 2015 Steven Stallion * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of cond...
////////////////////////////////////////////////////////////////////// //// //// //// raminfr.v //// //// //// //// ...
#include <bits/stdc++.h> using namespace std; const int N = 5; int vis[N][N][N]; int l[N], r[N]; double get_frac(int x, int y) { return (1.0 * x) / (1.0 * y); } double dfs(vector<vector<vector<double>>> &dp, int b, int cur, int g, int e, int n) { if (cur == n) { if (g == 0) 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 la...
#include <bits/stdc++.h> using namespace std; long long n, W, B, X, dp[1001][10001], c[1001], cum[1001], cost[1001]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cin >> n >> W >> B >> X; for (int i = 0; i < n; i++) { cin >> c[i]; if (i == 0) cum[i] = c[i]; el...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; const int N2 = 2e6 + 5; long long cs[N2], csn[N2]; int main() { int n, x, y; scanf( %d%d%d , &n, &x, &y); int mx = 0; for (int i = 0, a; i < n; i++) { scanf( %d , &a); cs[a]++; mx = max(mx, a); } lo...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, d, e, f, g, h, i, j, k, l, n, v, t; cin >> n >> k; long long m[k]; for (i = 0; i < k; i++) cin >> m[i]; if (n % 2 == 0) { a = m[k - 1]; if (a & 1) cout << odd n ; else cout << even n...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { long long n, m; cin >> n >> m; long long tot = n * (n + 1) / 2, zr = n - m, gr = m + 1; long long k = zr / gr, ans = 0; if...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int MAX = 200005; long long modexp(long long x, long long n) { if (n == 0) return 1LL; if (n % 2 == 0) { long long y = modexp(x, n / 2) % mod; return (y * y) % mod; } return (x * modexp(x, n - 1) % mod...
#include <bits/stdc++.h> using namespace std; long long mod, n, m, a[200005], b[200005], kq, vt1, vt2, l, r, mid, mn[200005]; map<int, bool> mp; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; mod = 998244353; for (int i = 1; i <= n; ++i) { cin >>...
#include <bits/stdc++.h> long long i, j, r, c, fre[1000], ans; char na, name1[1000][1000]; using namespace std; int main() { scanf( %lld %lld %c , &r, &c, &na); for (i = 0; i < r; i++) { for (j = 0; j < c; j++) { scanf( %c , &name1[i][j]); } } for (i = 0; i < r; 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...
/*------------------------------------------------------------------------------ * This code was generated by Spiral Multiplier Block Generator, www.spiral.net * Copyright (c) 2006, Carnegie Mellon University * All rights reserved. * The code is distributed under a BSD style license * (see http://www.opensource.or...
#include <bits/stdc++.h> using namespace std; int getFldsFromLine(char *line, std::vector<char *> &res, const char *sep = t n v f r ); int main(int argc, char **argv) { FILE *infile = stdin; char *line; line = (char *)calloc(5000000, sizeof(char)); if (line == NULL) { ...
#include <bits/stdc++.h> using namespace std; long long arr[200005], sh[200005], sp[200005]; int main() { long long i, j, k, n, m, p, q, t, cnt = 0, mn; scanf( %lld , &n); scanf( %lld , &k); for (i = 0; i < n; i++) { scanf( %lld , &arr[i]); ; } sort(arr, arr + n); for (i = ...
// Copyright (c) 2000-2012 Bluespec, Inc. // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, pub...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. //------------------------------------------------------------------------------ // SHARED CODE //------------------------------------------------------------------------------ // No shared code for ...
/*------------------------------------------------------------------------------ * This code was generated by Spiral Multiplier Block Generator, www.spiral.net * Copyright (c) 2006, Carnegie Mellon University * All rights reserved. * The code is distributed under a BSD style license * (see http://www.opensource.or...
#include <bits/stdc++.h> using namespace std; int main() { int l, r; cin >> l >> r; for (int i = l; i < r + 1; i++) { vector<int> cnts(10); int x = i; while (x > 0) { cnts[x % 10]++; x /= 10; } bool good = true; for (int j = 0; j < 10; j++) { i...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e6 + 200, RANGE = 1e6 + 20; const long long INF = 0x3f3f3f3f3f3f3f3f; int n, m, p; long long pre_min[MAX_N], nodes[MAX_N << 2], tag[MAX_N << 2]; pair<int, int> ai[MAX_N], bi[MAX_N]; struct tup { int x, y, z; bool operator<(const tup ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5; int n; long long x, m, ans; long long f() { long long a, b, q; q = (x - 1) % 4; a = q == 0 ? x - 1 : q == 1 ? 1 : q == 2 ? x : 0; q = (x + m - 1) % 4; b = q == 0 ? x + m - 1 : q == 1 ? 1 : q == 2 ? x + m : 0; return a ^ b...
module check (input unsigned [103:0] a, c); wire [103:0] int_AB; assign int_AB = ~a; always @(a, int_AB, c) begin #1; if (int_AB !== c) begin $display("ERROR"); $finish; end end endmodule module stimulus (output reg unsigned [103:0] A); parameter S = 2000; int unsigned i; initial begin ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2016 by Andrew Bardsley. // bug1071 module t (/*AUTOARG*/ // Inputs clk ); input clk; reg [3:0] array_1 [2:0]; reg [3:0] array_2 [2:0]; reg [3:0] array_3 [3: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; int i, j, k, l, x, y, z, m, n, a, b, ans, p, q, r; int numbers[800000]; int gcd(int x, int y) { if (y == 0) return x; else return gcd(y, x % y); } int main() { scanf( %d %d %d , &a, &b, &n); ans = gcd(a, b); m = sqrt(ans); for...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n]; long long sum = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; } if (sum % 2 != 0) { sum++; } long long sum1 = 0; for (int i = 0; i < n; i++) { sum1...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, i; cin >> n >> m; i = n / 2 + (n & 1); i = (m >= i) ? 0 : n - 2 * m; cout << i << ; if (!m) { cout << n; return 0; } for (i = 1; ((i * (i - 1)) / 2) < m; i++) ; cout << n - i; retu...
/******************************************************************************* * Module: simul_axi_master_wdata * Date:2014-03-24 * Author: Andrey Filippov * Description: Simulation model for AXI write data channel * * Copyright (c) 2014 Elphel, Inc.. * simul_axi_master_wdata.v is free software; you can ...
#include <bits/stdc++.h> using ll = long long int; using namespace std; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; int negative = -1; int ans = 0; for (int i = 0; i < n; ++i) { if (s[i] == ) ) --cnt; else if (s[i] == ( ) ++cnt; ...
/******************************************************************************* * 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 N = 100008; int a[N]; int b[N]; int main() { int n = 0; int x = 0; scanf( %d %d , &n, &x); for (int i = 1; i <= n; ++i) { scanf( %d , a + i); } for (int i = 1; i <= n; ++i) { scanf( %d , b + i); } sort(a + 1, a...
// Library - static, Cell - th54w22, View - schematic // LAST TIME SAVED: May 23 18:03:43 2014 // NETLIST TIME: May 23 18:07:14 2014 `timescale 1ns / 1ns module th54w22 ( y, a, b, c, d ); output y; input a, b, c, d; specify specparam CDS_LIBNAME = "static"; specparam CDS_CELLNAME = "th54w22"; spec...
#include <bits/stdc++.h> using namespace std; void mul(unsigned long long int F[2][2], unsigned long long int M[2][2]) { unsigned long long int x = F[0][0] * M[0][0] % 1000000007 + F[0][1] * M[1][0] % 1000000007; unsigned long long int y = F[0][0] * M[0][1] % 1000000007 + F[0][1] * M[1][1] %...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 6; vector<pair<int, int> > G[maxn]; int out, m, d[maxn], ans[maxn][3], leaf[maxn][2]; void add_m(int u, int v, int d) { ans[++m][0] = u, ans[m][1] = v, ans[m][2] = d; } void add_link(int u, int l, int d) { if (u == out) { a...
#include <bits/stdc++.h> using namespace std; int main() { long long p, d; while (scanf( %I64d%I64d , &p, &d) != EOF) { long long ans = ++p; for (long long i = 10;; i *= 10) { if (p % i > d) break; ans = p - p % i; } printf( %I64d n , ans - 1); } return 0; }...
#include <bits/stdc++.h> using namespace std; long long dp[10010], leftx[10010], rightx[10010], l[5010], r[5010]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, x; cin >> n >> x; vector<int> ry; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; l[i] ...
// // Copyright (c) 1999 Steven Wilson () // // 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) // ...