text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int n, l[300], c[300]; cin >> n; for (int i = 0; i < n; i++) cin >> l[i]; for (int i = 0; i < n; i++) cin >> c[i]; unordered_map<int, int> um; for (int i = 0; i < n; i++) ...
#include <bits/stdc++.h> using namespace std; map<string, int> hsh; int check(string str, int l, int r) { int pos = 0, cur = 0; for (int i = r; i >= l; i--) { if (str[i] == ( ) cur++; else if (str[i] == ) ) cur--; else if (cur == 0 && pos == 0 && (str[i] == * || str[i...
#include <bits/stdc++.h> #pragma optimize( -O3 ) using namespace std; const long long mod = 998244353; int n, m, u, v; pair<vector<int>, int> adj[1000006]; int alr[1000006]; long long ans = 0, cr = 0; bool check(int i, int j) { if ((int)adj[i].first.size() != (int)adj[j].first.size()) return false; ...
#if !defined(ONLINE_JUDGE) #include prettyprint.hpp #include debug.h #else #include <bits/stdc++.h> using namespace std; #define deb(...) 1729 #define dbg(...) 29 #define cer(x) 13 #endif const bool testcase = 1; typedef long long int ll; const ll mod1 = 10000000...
#include <bits/stdc++.h> using namespace std; int min(int a, int b) { if (a > b) return b; else return a; } int main() { int tc; cin >> tc; while (tc--) { long long int n; cin >> n; vector<int> a(n + 1, 0); vector<int> ans(n + 1, 0); for (int i = 1; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100007; long long i, j, k, n, m, t, x, y, ans; long long pw2[32]; long long a[MAXN]; void calPowerTwo() { long long i, j, k; pw2[0] = 1; for (i = 1; i < 32; i++) { pw2[i] = pw2[i - 1] * 2; } } int main() { calPowerT...
#include <bits/stdc++.h> using namespace std; const long long M = 1e9, I = 1e18; const int mxn = 1e5; int t, n; string s, pr, ans; bool fl; void solve() { fl = 0; ans = ; cin >> n; cin >> pr; ans = pr; for (int i = 1; i < n - 2; i++) { cin >> s; if (pr[1] != s[0]) { ...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; const int MOD = 1e9 + 7; vector<int> g[N + N]; int mat[N][N], p[N + N], sub[N + N], vis[N + N]; int ans[N + N], instack[N + N], go = true, ct = 0; vector<pair<int, int>> extime; void putNumbers(int node) { vis[node] = 1; instac...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, c; cin >> n >> c; vector<long long> a(n); multiset<long long> p; for (long long i = 0; i < n; i++) { cin >> a[i]; } for (long long i ...
#include <bits/stdc++.h> int main() { int n; scanf( %i , &n); printf( %li , (long int)n / 2 * 3); return 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; double ans = 1; int main() { int n, m, k; scanf( %d%d%d , &n, &m, &k); if (k >= m) printf( 1 n ); else if (n + k < m) printf( 0 n ); else { for (int i = 1; i <= k + 1; i++) ans = ans * (m - i + 1) / (n + i); ans = 1.0 - ans;...
#include <bits/stdc++.h> using namespace std; int main() { string s; int i, j, k, p, len, n; cin >> n >> k >> s; int arr[30] = {0}; char x = a ; for (i = 0; i < 26; i++) { x = a + i; p = 0; for (j = 0; j < n; j++) { if (s[j] == x) p++; else ...
#include <bits/stdc++.h> using namespace std; struct operacion { string name; int x; operacion() {} operacion(string name, int x) : name(name), x(x) {} }; int n; priority_queue<int, vector<int>, greater<int> > q; vector<operacion> v; int main() { ios::sync_with_stdio(false); cin >>...
/*============================================================================ This Verilog source file is part of the Berkeley HardFloat IEEE Floating-Point Arithmetic Package, Release 1, by John R. Hauser. Copyright 2019 The Regents of the University of California. All rights reserved. Redistribution an...
#include <bits/stdc++.h> const int maxn = 1005; int p[maxn], d[maxn], l[maxn][2], nl, ti; int main() { int n, h, r, c; scanf( %d%d%d , &n, &h, &r); for (int i = 0; i != n; ++i) scanf( %d%d , p + i, d + i); c = h; while (true) { c += r; if (c > h) c = h; if (c <= 0) break; ...
/* * NAME * * regr - register of data that can be held or cleared * * DESCRIPTION * * The regr (register) module can be used to store data in the current * cylcle so it will be output on the next cycle. Signals are also * provided to hold the data or clear it. The hold and clear signals * are both synchrono...
#include <bits/stdc++.h> using namespace std; char st1[100010], st2[100010]; int a1[100010], a2[100010], b1[100010], b2[100010]; int n; int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || 9 < ch) { if (ch == - ) f = -1; ch = getchar(); } while ( 0 <= ch &...
/** * 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...
// DESCRIPTION: Verilator: Verilog Test module // // Copyright 2011 by Wilson Snyder. This program is free software; you can // redistribute it and/or modify it under the terms of either the GNU // Lesser General Public License Version 3 or the Perl Artistic License // Version 2.0. module t (/*AUTOARG*/ // Inputs ...
#include <bits/stdc++.h> using namespace std; int main() { int n, i; long long sum = 0, z = 0, s = 0, m = 0, mm = 0; cin >> n; vector<long long> a(n); for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < (n - 1); i++) { if (i % 2 == 0) sum = sum + abs(a[i + 1] - a[i]); el...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7, P = 1e7 + 19; const int N = 200005; int nt = 1, k, n, Q, x, y, tot, op; long long pm(long long x, long long p) { long long res = 1; while (p) { if (p & 1) res = res * x % M; p >>= 1; x = x * x % M; } r...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; stack<pair<int, int> > S; S.push(make_pair(0, -1)); vector<pair<int, int> > ans; for (int i = 0; i <= n; i++) { int a; if (i < n) cin >> a; else a = 0; while (S.top().first > a...
#include <bits/stdc++.h> long n, m, x, y, i, a[1000], z; double aa, bb, sum; int main() { scanf( %ld%ld , &n, &m); for (i = 1; i <= n; i++) scanf( %ld , &a[i]); sum = 0; for (i = 1; i <= m; i++) { scanf( %ld%ld%ld , &x, &y, &z); aa = a[x] + a[y]; bb = z; if (aa / bb > sum) ...
#include <bits/stdc++.h> using namespace std; int main() { long long int x, y; double f, s; cin >> x >> y; f = y * (log10(x)); s = x * (log10(y)); if (abs(f - s) < pow(10, -8)) cout << = ; else if (f < s) cout << < ; else if (f > s) cout << > ; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, x1, y1, x2, y2, j, k, sum = 0; int a[101][101]; memset(a, 0, sizeof(a)); scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d%d%d%d , &x1, &y1, &x2, &y2); for (k = x1; k <= x2; k++) for (j = y1; j <= y2; j++...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1000000000,1000000000 ) using namespace std; const long long inf = 1e18 + 7; const long long mod = 1e9 + 7; const double eps = 1e-9; const double PI = 2 * acos(0.0); const double E = 2.71828; int f[1 << 24], sum[1 << 24], n, k, a[24], b[2]; int ...
#include <bits/stdc++.h> using namespace std; int n, tx, ty, ans, fa[2055]; bool vis[2055]; int find(const int i) { return fa[i] == i ? i : fa[i] = find(fa[i]); } void merge(const int i, const int j) { fa[i] = j; } int main() { scanf( %d , &n); for (int i = 1; i <= 2010; ++i) { fa[i] = i; ...
#include <bits/stdc++.h> using namespace std; int freq[200005]; int arr[1005]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> arr[i]; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) freq[arr[i] + 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 la...
/////////////////////////////////////////////////////////////////////////////// // // Silicon Spectrum Corporation - All Rights Reserved // Copyright (C) 2009 - All rights reserved // // This File is copyright Silicon Spectrum Corporation and is licensed for // use by UASC hereafter the "licensee", as defined...
// 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_clk (/*AUTOARG*/ // Outputs passed, // Inputs fastclk, clk, reset_l ); input fastclk; input clk; input reset_l; output pass...
/* * Copyright (c) 2002 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) * ...
#include <bits/stdc++.h> using namespace std; long long dp[1000000 + 9] = {0}; long long a1[1000000 + 9] = {0}; long long a2[1000000 + 9] = {0}; long long a3[1000000 + 9] = {0}; long long a4[1000000 + 9] = {0}; long long a5[1000000 + 9] = {0}; long long a6[1000000 + 9] = {0}; long long a7[1000000 + 9]...
/* * NAME * ---- * * SPI_slave.v - SPI slave * * DESCRIPTION * ----------- * * This module controls the SPI to bus communication. * * Refer to the documentation (doc/) for a more detailed * description of the timing singals used here. * Look for the section titled "Timing diagram of SPI" * * The follow...
#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; ...
module vesa_tpg( clock, reset, dout_ready, dout_valid, dout_data, dout_sop, dout_eop, bpp // 3'b000 = 18bpp, 3'b001 = 24bpp ); parameter MAX_BPC = 8; input clock; input reset; input dout_ready; output dout_valid; output [MAX_BPC*3-1:0] dout_data; output dout_sop; output dout_eop; wire [1:0] dout_em...
/** * 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 N = 1e6 + 1, logN = 21 + 1, mod = 1e9 + 7; int fl(int n) { int ans = 0; while (n /= 2) ++ans; return ans; } int ord2(int n) { int ans = 0; while (n % 2 == 0) { n >>= 1; ++ans; } return ans; } long long binpow(l...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, root; vector<int> adj[N]; bool ok; int dfs(int v, int p = -1) { int ret = 0; int cnt = 2; if (v == root) cnt++; for (int u : adj[v]) { if (u == p) continue; int res = dfs(u, v); if (res) ret = 2; ...
#include <bits/stdc++.h> using namespace std; bool dp[1005][1005]; vector<int> v; int b[1005], A[1005]; int Find(int A[], int x) { int root = x, tmp; while (A[root] >= 0) root = A[root]; while (x != root) { tmp = x; x = A[x]; A[tmp] = root; } return root; } void Union...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Tue Oct 17 02:50:46 2017 // Host : Juice-Laptop running 64-bit major relea...
/** * 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; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; int n, m, p, nm; vector<char> g; vector<bool> vis; vector<int> s, cnt; vector<queue<int>> ex; queue<int> q; bool isEmpty(int v) { if (v < 0) return false; int i = v / m, ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: dbginit_inst.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 and/...
/* * 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 Bit_OP_16bit(F, A, BS, S); input[15:0] A; input[3:0] BS; input S; output reg[15:0] F; always @(A) begin case (BS[3:0]) 4'b0000: begin F = {A[15:1],S}; //Bit 0 end 4'b0001: begin F = {A[15:2],S,A[0]}; //Bit 1 end 4'b0010: begin F = {A[15:3],S,A[1:0]}; //Bit 2 end 4'b0011: begin F = {A[1...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/*------------------------------------------------------------------------------ * 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; using ll = long long; double p; bool in_memo[200 + 1][230 + 1][2][1 << 8]; double memo[200 + 1][230 + 1][2][1 << 8]; double E(int k, int lead_count, bool lead_parity, int mask) { double& ans = memo[k][lead_count][lead_parity][mask]; if (not in_memo[k][le...
//Legal Notice: (C)2017 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; pair<int, int> T[4 * 200005]; void update(int n, int b, int e, int p, int v) { if (b == p && e == p) { T[n] = make_pair(v, p); } else { int m = (b + e) / 2; if (p <= m) update(2 * n, b, m, p, v); else update(2 * n + 1, m...
////////////////////////////////////////////////////////////////////////////////// // // This file is part of the N64 RGB/YPbPr DAC project. // // Copyright (C) 2015-2021 by Peter Bartmann <> // // N64 RGB/YPbPr DAC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Wojtek Gumua // // Create Date: 15:47:33 06/07/2015 // Design Name: // Module Name: processor // Project Name: // Target Devices: // Tool versions: // Description: // // Depend...
///////////////////////////////////////////////////////////////////// //// //// //// Non-restoring unsigned divider //// //// //// //// Author: Richard Herveille ...
/** * 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 k[5] = {3, 4, 5, 4, 3}; int st[5] = {0, 0, 0, 1, 2}; int dx[] = {0, -1, -1, 0, 1, 1}; int dy[] = {-1, -1, 0, 1, 1, 0}; int x[32], y[32]; int id[32][32]; char a[32][32]; char f[1 << 20]; int prep() { memset(id, 0xff, sizeof(id)); int n = 0; ...
#include <bits/stdc++.h> using namespace std; long n, m; vector<long> clauses[100000 + 1]; vector<long> variables[100000 + 1]; long long ans[2] = {0}; bool check_clauses[100000 + 1] = {false}; long long dp_path[100000 + 1][2][2]; long long dp_cycle[100000 + 1][2][2][2]; void path_component(long start_...
module uart_tx #(parameter CLOCK_FREQ = 12_000_000, BAUD_RATE = 115_200) ( input clock, input [7:0] read_data, input read_clock_enable, input reset, /* active low */ output reg ready, /* ready to read new data */ output reg tx, output reg uart_clock); reg [9:0] data; localparam CLOCKS_PER_BIT = CLOCK_FREQ ...
module dummy; parameter [TSTBITS-1:0] // synopsys enum tstate_info TIDLE = 3'b000, TCN1 = 3'b001, TCN2 = TCN1+1, // must be numbered consecutively TCN3 = TCN2+1, TCN4 = TCN3+1, TCN5 = TCN4+1, IOCLR = TCN5+1, TUNU1 = 3'b111; // state and output logic always @ (`ifdef SIMFSM i...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// module write_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 R...
#include <bits/stdc++.h> const int maxn = int(1e5) + 7, mod = int(1e9) + 7; bool not_prime[maxn]; std::map<int, int> cnt[maxn]; std::vector<int> factor[maxn]; long long qpow(long long p, long long q) { long long ret = 1; while (q) { if (q & 1) ret = ret * p % mod; p = p * p % mod; q ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, w; cin >> w >> n; if (w <= 3) { cout << YES << endl; return 0; } while (n > 0) { if (n % w > 1 && n % w...
/** * 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...
// (C) 1992-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 simulati...
#include <bits/stdc++.h> using namespace std; vector<int> ans; void solve(long long n) { long long step = 0; while (n != 1) { if (n % 2 == 0) { if (n % 6 != 0) { ans.push_back(-1); return; } n /= 6; if (n == 0) { ans.push_back(-1); ...
/*****************************************************************************/ // // Module : cae_clock.vpp // Revision : $Revision: 1.4 $ // Last Modified On: $Date: 2011/09/29 17:44:03 $ // Last Modified By: $Author: mruff $ // //--------------------------------------------------------------------------...
/* * 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; string s[1100]; int vis[1100]; int num[100]; int main() { ios::sync_with_stdio(false); int n, len, k; cin >> n >> len >> k; string st; cin >> st; for (int i = 0; i < st.size(); i++) { num[st[i] - a ]++; } int l = 0, r = 25; ...
#include <bits/stdc++.h> using namespace std; int N; vector<string> a; vector<int> big; vector<int> mark; string s; string t; int main() { cin >> N; string s1; for (int i = 0; i < N; i++) { cin >> s1; a.push_back(s1); } cin >> s; cin >> t; for (int i = 0; i < s.si...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int columns[n + 1]; memset(columns, 0, sizeof(columns)); for (int i = 0; i < m; i++) { int tmp; cin >> tmp; columns[tmp]++; } int ans = 1001; for (int i = 1; i <= n; i++) { ans...
/* * Bug report: * * From: Hendrik <> * Subject: gEDA: Pass array element into module in iverilog 0.5 * To: * Date: Mon, 10 Sep 2001 11:53:04 +0800 */ module top; reg [6:0] x[2:0]; speak i0 (x[0], x[1], x[2]); initial begin #10 x[0] = 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; const int maxn = 200005; int a[maxn]; long long s[maxn], ss[maxn]; pair<int, long long> que[maxn]; int tot; pair<int, long long> operator-(pair<int, long long> b, pair<int, long long> a) { pair<int, long long> c; c.first = b.first - a.first; c.seco...
#include <bits/stdc++.h> using namespace std; const bool OJ = true; const long long inf = 1LL << 60; template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { for (long long i = 0; i < (((long long)((v).size()))); i++) os << v[i] << ; return os; } template <class T> istream& o...
/*------------------------------------------------------------------------- This confidential and proprietary software may be only used as authorized by a licensing agreement from amfpga. (C) COPYRIGHT 2013.www.amfpga.com ALL RIGHTS RESERVED Filename : sdram_ov7670_vga.v Author : Amfpga Data : 2013-02-1 Vers...
#include <bits/stdc++.h> using namespace std; long long mod = 1000000000 + 7; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; cin >> n; n -= 10; if (n >= 1 && n <= 11 && n != 10) { cout << 4; } else if (n == 10) { cout << 15; } else { cout <...
module Transmision (input rw, //rw=1 para transmitir input clk, input reset, //reset=0 para transmitir input wire [7:0] din, output busy, output reg done, output clk_blu, outp...
#include <bits/stdc++.h> using namespace std; template <typename T> void print1d(vector<T> &a) { for (long long int i = 0; i < a.size(); i++) { cout << a[i] << ; } cout << endl; } vector<long long int> divisor(long long int n) { vector<long long int> a; for (long long int i = 1; i...
///////////////////////////////////////////////////////////// // Created by: Synopsys DC Ultra(TM) in wire load mode // Version : L-2016.03-SP3 // Date : Sun Nov 20 02:53:52 2016 ///////////////////////////////////////////////////////////// module GeAr_N20_R5_P5_with_recovery ( clk, in1, in2, res, if_error_del...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2006 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); // verilator lint_off MULTIDRIVEN wire [31:0] outb...
/* This file is part of Fusion-Core-ISA. Fusion-Core-ISA 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. Fusi...
#include <bits/stdc++.h> using namespace std; int main() { int a[101] = {}, b = 0, c, d, x, y, i, max = -1, f = 0; cin >> x >> y; for (i = 1; i <= x; i++) { cin >> c; a[c]++; } for (i = 1; i <= 100; i++) { if (a[i] > max) max = a[i]; if (a[i] != 0) f++; } if (max ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, net, i, flag, d; string str; cin >> n; net = 0; flag = 0; for (i = 0; i < n; i++) { cin >> d; cin >> str; if ((net == 0) && (str != South )) flag = 1; if ((net == 20000) && (str != North )) ...
#include <bits/stdc++.h> const int N = 300010; const int MOD = 1e9 + 7; struct xxx { int id; char c; } s[N]; std::string a, b, c; int gap, n; int sa[N], lcp[N], rank[N], tmp[N], bucket[N], cnt[N][3], ans[N], dp[19][N], fw[N]; void update(int i, int v) { while (i < N) { fw[i] = (f...
module sha1_compression( input [159:0] hash_state_in, input [ 31:0] w, input [ 6:0] round, output [159:0] hash_state_out ); reg [31:0] k; reg [31:0] f; wire [31:0] temp; wire [31:0] a = hash_state_in[159:128]; wire [31:0] b = hash_state_in[127:96 ]; wire [31:0] c = hash_state_in[...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int i = 1, j = n, count = 0, k = 1; while (k <= (n - 1)) { count = count + ((i + j) % (n + 1)); if (k % 2 == 1) { i++; } else { j--; } k++; } cout << count; }
#include <bits/stdc++.h> using namespace std; const int iinf = 1e9 + 10; const long long inf = 1ll << 60; const long long mod = 1e9 + 7; void GG() { cout << 0 n ; exit(0); } long long mpow(long long a, long long n, long long mo = mod) { long long re = 1; while (n > 0) { if (n & 1) r...
#include <bits/stdc++.h> using namespace std; void test_case() { int n; long long k; cin >> n >> k; int l, r[2] = {-1, -1}; long long curr[2] = {k, k}, ans[2] = {0, 0}, monsters; for (int i = 0; i < n; i++) { int old_r[2] = {r[0], r[1]}, tmp_r; long long old_curr[2] = {curr[0], c...
#include <bits/stdc++.h> using namespace std; char s[10][10]; int main() { int bl = 0, wh = 0; for (int i = 0; i < 8; i++) scanf( %s , s[i]); for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) { if (s[i][j] == Q ) wh += 9; else if (s[i][j] == R ) wh += ...
#include <bits/stdc++.h> using namespace std; double dp[1 << 20][20], p[20][20]; bool mark[1 << 20][20]; int n; double mem(int mask, int winner) { if (!mask) return (winner == 1); if (mark[mask][winner]) return dp[mask][winner]; mark[mask][winner] = true; double &ret = dp[mask][winner]; fo...
/** * 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 N = 41, K = 11; bitset<40> a[N]; vector<int> steps[K]; int n, k; bool ok = true; void go(int pos, bitset<40> is_one, bitset<40> is_question) { if (pos == k) { if (is_question != 0) { ok = false; return; } int one...
#include <bits/stdc++.h> namespace competitive_programming { inline namespace utility {} namespace debugging {} namespace io {} } // namespace competitive_programming namespace competitive_programming::utility { class timer { private: std::chrono::time_point<std::chrono::steady_clock> begin, end; ...
#include <bits/stdc++.h> using namespace std; int main() { int flag = 0, i, k; string str, s; cin >> str; if (str.at(0) == - ) { flag = 1; str.erase(0, 1); } if (flag == 1) cout << ( ; cout << $ ; if ((int)str.find( . ) != -1) s = str.substr(0, str.find( . )); ...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; void solve() { int n, t; while (cin >> n >> t) { int x, y; vector<pair<int, int> > a; vector<pair<int, int> > v; for (int i = 0; i < n; i++) { cin >> x >> y; a.push_back(make_pair(x, y)); } for (int i = 0; i < ...
// DEFINES `define BITS 8 // Bit width of the operands `define B2TS 16 // Bit width of the operands module bm_base_multiply(clock, reset_n, a_in, b_in, c_in, d_in, e_in, f_in, out0, out2, out3, out4, out1); // SIGNAL DECLARATIONS input clock; input reset_n; input [`BITS...
#include <bits/stdc++.h> using namespace std; const int MAXN = 60; long long h, n; int step[MAXN]; inline long long calc(long long high) { return (1ll << (high + 1)) - 1; } void solve() { long long tmp = (1ll << h) - 1 + n; int cnt = 0; while (tmp != 1) { if (tmp % 2 == 1) step[cnt...