text
stringlengths
59
71.4k
module adder( input wire a, input wire b, input wire ci, output reg s, output reg co ); always @ (*) {co, s} = a + b + ci; endmodule module mult( input wire [3:0] opA, input wire [3:0] opB, output wire [7:0] result ); wire a [11:0]; wire b [11:0]; wire c [11:0]; wire s [11:0]; assign resu...
/* * 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; set<pair<long long int, long long int> > s; pair<long long int, long long int> p; long long int d[300000], x, n, k, l = 0, di = 0; vector<long long int> v[300000]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> k; for ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2009 by Wilson Snyder. typedef struct packed { bit b9; byte b1; bit b0; } pack_t; module t (/*AUTOARG*/ // Inputs clk ); input clk; in...
#include <bits/stdc++.h> using namespace std; const long long maxn = 200010; const long long MOD = 1e9 + 7; const long long INF = 1e9; const long long LINF = 1e18; long long n, m, a[maxn], b[maxn]; map<long long, long long> M, N; string s, ss; set<long long> S; long long l, r, h; int32_t main() { ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; const int INFINITE = 0x3f3f3f3f; template <class T> inline void checkmin(T &a, T b) { if (b < a) a = b; } template <class T> inline void checkmax(T &a, T b) { if (b > a) a = b; } template ...
#include <bits/stdc++.h> using namespace std; int main() { int xp, nb; cin >> xp >> nb; cout << min(xp, min(nb, (xp + nb) / 3)); return 0; }
#include <bits/stdc++.h> using namespace std; vector<int> v[100005]; bool d[100005]; int s[100005]; void del(int i, int par) { if (v[i].size() <= 2) { d[i] = true; for (int j : v[i]) if (j != par) del(j, i); } } int main() { int n; cin >> n; int a, b; for (int i...
#include <bits/stdc++.h> int main() { int n, m; while (scanf( %d %d , &n, &m) != EOF) { if (n * m < 2) { printf( 0 n ); } else { printf( %d n , n * m / 2); } } }
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, int> ord; vector<pair<int, int> > edges; vector<int> adj[200000]; int n; int main() { cin >> n; cout << n - 1 << endl; for (int i = 1; i < n; i++) { int a, b; cin >> a >> b; edges.push_back(make_pair(a, b)); ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 6, MAX = 2e5 + 5, OO = 1000000009; long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } long long lcm(long long x, long long y) { return (x * y / gcd(x, y)); } long long fact(long long z) { return (z <= 1) ? 1 : z * fact(z...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long INF = 2e18; const int N = 1231234; int n, m; int a[N], b[N]; bool ok(long long x) { int i, j; for (i = 0, j = 0; i < m; ++i) { while (j < n && abs(b[i] - a[j]) <= x) j++; } return j == n; } ...
`timescale 1ns/10ps module pll_0002( // interface 'refclk' input wire refclk, // interface 'reset' input wire rst, // interface 'outclk0' output wire outclk_0, // interface 'locked' output wire locked ); altera_pll #( .fractional_vco_multiplier("false"), .reference_clock_frequency("50.0 MHz"), .ope...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; int main() { ios::sync_with_stdio(0); cin.tie(0); int q; cin >> q; for (int cas = 0; cas < q; ++cas) { ll a, b, m; cin >> a >> b >> m; if (a == b) { cout << 1 << << a ...
#include <bits/stdc++.h> long long a[10000]; using namespace std; int main() { long long n, i, j, c; cin >> n; for (i = 1; i < n + 1; i++) cin >> a[i]; for (i = 1; i < n + 1; i++) { for (j = i + 1; j < n + 1; j++) { if (a[i] > a[j]) { c = a[i]; a[i] = a[j]; ...
#include <bits/stdc++.h> using namespace std; template <typename T> T prod(const T &a, const T &b, const T &mod) { return ((a % mod) * (b % mod)) % mod; } template <typename T> T pow_(const T &a, const T &b) { if (!b) return 1; T p = pow_(a, b / 2); p *= p; return (b % 2) ? (p * a) : p; ...
#include <bits/stdc++.h> using namespace std; using int64 = long long; using pii = pair<int, int>; using vchar = vector<char>; using vvchar = vector<vchar>; using vint = vector<int>; using vint64 = vector<int64>; using vvint = vector<vint>; using vbool = vector<bool>; using vpii = vector<pii>; tem...
#include <bits/stdc++.h> using namespace std; const long long int MAX = 1000000007; const long long int MAXN = 100010; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; while (t--) { long long int n, k; cin >> n >> k; ...
#include <bits/stdc++.h> const long long _INF = 1e18; const int INF = 1e9; using namespace std; int T; void solved() { long long n = 0; cin >> n; if (n % 2 == 1) n++; if (n <= 6) cout << 15 << n ; else cout << n * 5 / 2 << n ; } int main() { setbuf(stdout, NULL); ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e7 + 5; const int maxm = 2e5 + 5; const int inf = 0x3f3f3f3f; const long long mod = 1e9 + 7; const double eps = 1e-9; const double pi = acos(-1); int m, n, w, k; void init() {} bool judge(int now) {} long long quickpow(long long a, lo...
// (C) 2001-2012 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 doc...
//Legal Notice: (C)2012 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...
#include <bits/stdc++.h> const int MAX_N = 500000; const int MAX_M = 500000; const int MOD = 998244353; int l[MAX_M], r[MAX_M], val[MAX_M]; int smen[1 + MAX_N + 1], left[1 + MAX_N], dp[1 + MAX_N], _sp[1 + 1 + MAX_N], *sp = _sp + 1; int solve(int n, int m, int bit) { int last = 0, p = 0; for (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> int main() { unsigned short n; unsigned short ac1; unsigned short i; unsigned short w; unsigned short ac2; unsigned short gw; if (scanf( %hu , &n) != 1) return -1; if (n < 1 || n > 100) return -1; ac1 = 0; for (i = 0; i < n; i++) { if (scanf( %hu ...
// generated by gen_VerilogEHR.py using VerilogEHR.mako // Copyright (c) 2019 Massachusetts Institute of Technology // 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...
#include <bits/stdc++.h> const int mod = 1000000007; using namespace std; pair<int, int> a[12345]; vector<int> ans[3]; map<pair<int, int>, bool> used; map<int, int> cnts; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { scanf( %d , &a[i].first); a[i].second = i + 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 n, m, a[200010], w[200010], f[3010][3010], g[3010][3010], inv[3010 * 2], sum[3]; const int mod = 998244353; int getInverse(int x, int y) { int ret = 1; while (y) { if (y & 1) ret = (long long)ret * x % mod; x = (long long)x * x % mod; ...
#include <bits/stdc++.h> using namespace std; struct rua { char s[100001]; int n, a[100001], b[100001], x, y; void _() { int cnt = 0; for (int i = 1; i <= n; i++) if (s[i] == A ) a[i] = ++cnt, b[i] = b[i - 1]; else a[i] = cnt = 0, b[i] = b[i - 1] + 1; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 110, MOD = 1e9 + 7; long long dp[MAXN][2]; int main() { ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr); int n, k, d; cin >> n >> k >> d; dp[0][0] = 1; for (int i = 1; i <= n; i++) { for (int j ...
#include <bits/stdc++.h> const int mod = 200003; const int gmod = 2; const int inf = 1039074182; const long long llinf = 1LL * inf * inf; template <typename T1, typename T2> inline void chmin(T1 &x, T2 b) { if (b < x) x = b; } template <typename T1, typename T2> inline void chmax(T1 &x, T2 b) { ...
// (C) 2001-2015 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated doc...
#include <bits/stdc++.h> using namespace std; int main() { long long n, arr[100000], arr1[100000]; cin >> n; string s = ; for (int x = 0; x < n; x++) cin >> arr[x], arr1[x] = arr[x]; sort(arr1, arr1 + n); for (int x = 0; x <= arr1[n - 1]; x++) { for (int y = 0; y < n - 1; y++) { ...
#include <bits/stdc++.h> using namespace std; signed long long int a[100000 + 5], b[100000 + 5]; int n, m; signed long long int func(signed long long int x) { signed long long int ans = 0; for (int i = 1; i <= n; ++i) { if (a[i] < x) ans += x - a[i]; } for (int i = 1; i <= m; ++i) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a[105], nr = 0, poz = 0; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { if (a[i] <= k) nr++; else { poz = i; break; } } if (poz || nr == 0) ...
//////////////////////////////////////////////////////////////////////////////// // // Filename: linetest.v // {{{ // Project: wbuart32, a full featured UART with simulator // // Purpose: To test that the txuart and rxuart modules work properly, by // buffering one line's worth of input, and then piping that line // ...
#include <bits/stdc++.h> using namespace std; int main() { int t, x; cin >> t; while (t--) { cin >> x; while (x > 0) { if (x % 3 == 0) x = x % 3; else if (x % 7 == 0) x = x % 7; else { x -= 7; x -= 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> using namespace std; int main() { int i, n, x, y, c; cin >> n >> x >> y; int a[n]; for (i = 0; i < n; i++) cin >> a[i]; if (x > y) cout << n << endl; else { c = 0; for (i = 0; i < n; i++) if (a[i] <= x) c++; if (c % 2 == 1) c =...
#include <bits/stdc++.h> using namespace std; int L, R; int main() { int n, m, i, j, u, v; cin >> n >> m; int ans = 100001; for (i = 0; i < m; i++) { scanf( %d%d , &L, &R); ans = min(ans, R - L + 1); } cout << ans << endl; for (i = 1; i <= n; i++) cout << i % ans << ; ...
/** * 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 HashMap { vector<pair<int, int> > g[1000007]; void ins(int x, int y) { int id = ((long long)x * 1000000007 + y) % 1000007; g[id].push_back(make_pair(x, y)); } bool get(int x, int y) { int id = ((long long)x * 1000000007 + y) % 10...
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, m, in[N], out[N], id[N], dep[N]; vector<int> v[N]; int idx; void dfs(int pos, int dd) { in[pos] = ++idx; id[idx] = pos; dep[idx] = dd; for (auto &i : v[pos]) dfs(i, dd + 1); out[pos] = ++idx; id[idx] = pos; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> yarr(51, 0); vector<int> xarr(51, 0); int q = 4 * n + 1; vector<pair<int, int>> trav; for (int i = 0; i < q; i++) { int x, y; cin >> x >> y; trav.push_back(make_pair(x, y)); xa...
#include <bits/stdc++.h> using namespace std; int main() { int x, a, b; cin >> a >> b >> x; if (a >= b) { cout << 0 ; if (x % 2 == 0) { for (int i = 1; i < x / 2; i++) cout << 10 ; for (int i = 0; i <= b - x / 2; i++) cout << 1 ; for (int i = 1; i <= a - x / 2; i++...
// usb_ft232.v `timescale 1 ns / 1 ps module usb_ft232 ( input clk, input reset, // FT232 interface output wr_n, output rd_n, output oe_n, inout [7:0]data, input txe_n, input rxf_n, output siwu_n, // tx fifo interface output tx_read, input [15:0]tx_data, input [1:0]tx_mask, input tx_ready, ...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const double EPS = 1e-9; int n, m, t[210][210], d[210][210]; bool active[210]; vector<pair<int, int> > x_sorted; double calc(int x, int y) { double ans = INF; vector<pair<int, int> > s; multiset<int> up; int down = -...
#include <bits/stdc++.h> using namespace std; vector<int> g[100006]; vector<int> located[100006]; int parent[100006], level[100006], visited[100006]; int ancestor[100006][18]; vector<int> st[100006][18]; void dfs(int u) { visited[u] = 1; for (int i = 0; i < g[u].size(); i++) { int v = g[u][i...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.3 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1ns/1ps ...
#include <bits/stdc++.h> const int N = 7 + 1e9; using namespace std; const int p = 1e6 + 10; int arr[p]; int power(int x, int y); void pre() { int j = 1; for (int i = 1; i < p; i++) { if (i % 3 != 0) { if (i % 10 != 3) { arr[j] = i; j++; } } } } ...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen */ `timescale 1ns/100ps /** * `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 bas...
#include <bits/stdc++.h> using namespace std; int main() { int singles, doubles, n; cin >> n >> singles >> doubles; int refused = 0, partlyOccDoubles = 0; for (int i = 0; i < n; i++) { int cur; cin >> cur; if (cur == 1) { if (singles > 0) { singles--; } el...
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; using namespace std; const double eps = 1e-8; const double pi = acos(-1.0); inline double sqr(double x) { return x * x; } int cmp(double x) { if (fabs(x) < eps) return 0; if (x > 0) return 1; return -1; } int n; ...
#include <bits/stdc++.h> using namespace std; vector<vector<long long>> dp(10, vector<long long>(1000005, 0)); long long g(long long n) { if (n < 10) return n; long long ans = 1; while (n) { if (n % 10) ans *= (n % 10); n /= 10; } return g(ans); } signed main() { ios_base::...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module receiver_logic #( parameter D...
module MPUC1307 ( CLK,DS ,ED, MPYJ,DR,DI ,DOR ,DOI ); parameter total_bits = 32; input CLK ; wire CLK ; input DS ; wire DS ; input ED; //data strobe input MPYJ ; //the result is multiplied by -j wire MPYJ ; input [total_bits-1:0] DR ; wire signed [total_bits-1:0] DR ; input [total_bits-1:0] DI ; ...
/** * microcode_rom.v - Microcoded Accumulator CPU * Copyright (C) 2015 Orlando Arias, David Mascenik * * 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 Licens...
#include <bits/stdc++.h> using namespace std; long long read() { long long a = 0, b = getchar(), c = 1; while (!isdigit(b)) c = b == - ? -1 : 1, b = getchar(); while (isdigit(b)) a = a * 10 + b - 0 , b = getchar(); return a * c; } void print(long long x) { if (x < 0) putchar( - ), x = -x;...
// (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; char s[1000005]; int main() { int n, k; while (scanf( %d%d , &n, &k) != EOF) { if (k > n || (n > 1 && k == 1)) { printf( -1 n ); break; } else { if ((n - k) % 2) { for (int i = 1; i <= n - k + 1; i++) { ...
module partsel_test001(input [2:0] idx, input [31:0] data, output [3:0] slice_up, slice_down); wire [5:0] offset = idx << 2; assign slice_up = data[offset +: 4]; assign slice_down = data[offset + 3 -: 4]; endmodule module partsel_test002 ( input clk, rst, input [7:0] a, input [0:7] b, input [1:0] s, output [7:0] ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; int n; string s; while (t--) { cin >> n >> s; int x = 0, y = 0; map<pair<int, int>, int> m; int l = 0, r = n + 1; m[{0, 0}] = 1; for (int i = 0; i < n; i++) { if (s[i] == L ) ...
// (C) 2001-2017 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0), eps = 1e-8; const int inf = ~0U >> 2; int mod = 1e9 + 7; int Pow(int x, long long t) { int r = 1; for (; t; t >>= 1, x = (long long)x * x % mod) if (t & 1) r = (long long)r * x % mod; return r; } const int N = 10...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; long long int cal(long long int num) { return (num * (num + 1)) / 2ll; } void solve() { long long int n; scanf( %lld , &n); n--; long long int ans = 0, k = 1; for (long long int i = 1; i <= n; i <<= 1) { ans += ((...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:37:23 10/06/2014 // Design Name: // Module Name: uart // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Re...
#include <bits/stdc++.h> const long long N = 1000006; using namespace std; const long long MOD = 1000000007LL; template <typename T> T gcd(T a, T b) { if (a == 0) return b; return gcd(b % a, a); } template <typename T> T power(T x, T y, long long m = MOD) { T ans = 1; while (y > 0) { ...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n, x; cin >> n; vector<vector<int>> adj(n); for (int i = 1; i < n; i++) cin >> x, x--, adj[x].push_back(i), adj[i].push_back(x); queue<int> q; q.push(0); ...
Require Import Coq.Sets.Ensembles. Require Import List. From OakIFC Require Import Lattice Parameters GenericMap ModelSemUtils RuntimeModel State Events. Import ListNotations. Arguments Ensembles.In {U}. Arguments Ensembles.Add {U}. Arguments Ensembles.Subtract {U}. Arguments Ensembles.Sing...
//Legal Notice: (C)2016 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...
/******************************************************************************* * 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 ...
/** * 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 double pi = acos(-1.0); const double eps = 1e-11; const int inf = 0x7FFFFFFF; template <class T> inline void checkmin(T &a, T b) { if (b < a) a = b; } template <class T> inline void checkmax(T &a, T b) { if (b > a) a = b; } template <clas...
#include <bits/stdc++.h> using namespace std; const int FFF = 200005; int a[FFF], b[FFF]; int qsearch(int x, int r) { int l = 1, mid; while (l <= r) { mid = (l + r) >> 1; if (b[mid] < x) l = mid + 1; else r = mid - 1; } return r; } int main() { int n, m;...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int n, x[2], need[N][2]; pair<int, int> p[N]; int main() { ios::sync_with_stdio(false); cin >> n >> x[0] >> x[1]; for (int i = 0; i < n; i++) { int c; cin >> c; p[i] = {c, i}; } sort(p, p + n); for (...
#include<bits/stdc++.h> #define ll long long #define ull unsigned long long #define in(ar,n) for(int i=0;i<n;i++)cin>>ar[i]; #define invec(ar,n)for(int i =0 ; i<n;i++){int temp;cin>>temp;ar.push_back(temp);} #define in2d(ar,n,m) for(int i=0;i<n;i++)for(int i=0;i<m;i++)cin>>ar[i] #define out(ar,n) f...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: ff_jbi_sc2_1.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/...
#include <bits/stdc++.h> using namespace std; int n, w[101], i, j, S, Sum, k, C, a, t; int main() { scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &k); for (j = 1; j <= k; j++) { scanf( %d , &a); Sum += a; t = j * 2 - k; if (t == 1) w[C++] = -...
#include <bits/stdc++.h> using namespace std; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; struct MCMF { enum { MAXN = 6500 }; struct Edge { int x, y; int cap, cost; }; vector<Edge> E; vector<int> adj[MAXN]; int N, prev[MAXN]; int dist[MAXN], phi[MAXN]; MCMF(in...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: rom_dispv.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ==============================...
#include <bits/stdc++.h> using namespace std; int a[5][5]; int b[] = {0, 1, 2, 3, 4}; long long sol() { int p0 = b[0]; int p1 = b[1]; int p2 = b[2]; int p3 = b[3]; int p4 = b[4]; long long p = a[p0][p1] + a[p1][p0] + a[p2][p3] + a[p3][p2]; p += a[p1][p2] + a[p2][p1] + a[p3][p4] + a[p...
// (C) 2001-2017 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: pcx_stall.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/or ...
/** * 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 = 1e6 + 10; int n, a[MAXN], d[MAXN]; bool pic[MAXN]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { int temp; scanf( %d , &temp); pic[temp] = 1; } fill(d, d + MAXN, 1); int ans = 0; for (int i =...
#include <bits/stdc++.h> using namespace std; int n, m, k, t, a[200010], f[200010]; long long ans; struct nood { int x, id; } b[200010]; int cmp(nood a, nood b) { return a.x > b.x; } int main() { scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); b[i].x...
/* Copyright (C) 2015-2016 by John Cronin * * 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, merg...
/* * .--------------. .----------------. .------------. * | .------------. | .--------------. | .----------. | * | | ____ ____ | | | ____ ____ | | | ______ | | * | ||_ || _|| | ||_ \ / _||...
#include <bits/stdc++.h> using namespace std; int n, m; char mp[510][510]; int minln, maxln, minrw, maxrw, cnt; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %s , mp[i] + 1); minln = n + 1; maxln = 0; minrw = m + 1; maxrw = 0; for (int i = 1; i <= n; i++) ...
`include "defines.v" module connectRouter #(parameter addr = 4'b0000) //No. 0 connect router, port 0 ( input `control_w port_in, input `control_w inj, input clk, input rst, output `control_w port_out, output `control_w bout, outpu...
#include <bits/stdc++.h> using namespace std; int cnt; string s; stack<int> st; int main() { cin >> s; for (int i = 0; i < s.size(); ++i) { if (s[i] == ( || s[i] == [ || s[i] == { || s[i] == < ) { st.push(int(s[i])); } else { if (st.empty()) { cout << Impo...
#include <bits/stdc++.h> using namespace std; const int N = 200005; const long long int P = 1000000007; const double eps = 1e-6; int val[N]; int deg[N]; vector<int> gr[N]; vector<long long int> mx(N); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int x, y, a, b; cin >> x >> y >> a >> b; int t = gcd(a, b); a /= t; b /= t; x /= a; y /= b; cout << a * min(x, y) << << b * min(x, y); cin >> a; return 0; ...
#include <bits/stdc++.h> using namespace std; int main() { int vp, vd, t, f, c, ans = 0; double tempt; double curs = 0; cin >> vp >> vd >> t >> f >> c; curs = vp * t; if (vp >= vd) { cout << 0 << endl; return 0; } while (curs < c) { tempt = curs / (vd - vp); c...
#include <bits/stdc++.h> int max(int a, int b) { if (a > b) return a; else return b; } int main() { int n, m, p, r, x, y, c, i, j, zb, maxz; int max1, max2, max3, max4, minz; scanf( %d %d , &n, &m); scanf( %d , &c); for (i = 1; i <= c; i++) { scanf( %d %d , &x, &y); ...
#include <bits/stdc++.h> using namespace std; int find_set(int v, vector<int> &p) { if (v == p[v]) return v; return p[v] = find_set(p[v], p); } void union_set(int a, int b, vector<int> &p) { a = find_set(a, p); b = find_set(b, p); if (a != b) { p[b] = a; } } long long int ans =...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Sun Jan 22 23:54:06 2017 // Host : TheMosass-PC running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; const int N = 3e3; long long dmod(long long x) { return x % MOD; } int n, k; int h[N + 5]; long long memo[N + 5][2 * N + 5]; long long dp(int idx, int gap) { if (idx > n) { if (gap > 0) return 1; 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 law...