text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int a[400005]; int q, x; int main() { int aux, cnt = 0, maxim = 0; cin >> q >> x; for (int i = 1; i <= q; i++) { cin >> aux; a[aux % x]++; while (a[cnt] > maxim) { cnt++; if (cnt == x) { cnt = 0; maxi...
// // Copyright 2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is dis...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int q; unsigned long long a, b, c; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> q; while (q--) { cin >> a >> b >> c; unsigned long long sum = a + b + c; cout << sum / 2 << n ; sum = 0; ...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; if (k % 2 == 1) { cout << -1 << endl; return 0; } for (int i = 0; i < k; i++) { if (i > 0) cout << endl; for (int j = 0; j < k; j++) { for (int l = 0; l < k; l++) { int layer = m...
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000; const int MOD = INF + 7; const int XD = 100100; int facts[XD << 1]; void calcFacts(int n) { facts[0] = 1; for (int i = 1; i <= n; ++i) { facts[i] = 1LL * facts[i - 1] * i % MOD; } } int exgcd(int a, int b...
#include <bits/stdc++.h> using namespace std; int read() { int x = 0; bool flg = false; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) flg = true; for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48); return flg ? -x : x; } int n, m; c...
#include <bits/stdc++.h> using namespace std; int n; double s; vector<int> E[100005]; int dist[100005], pa[100005]; int dfs(int u, int p, int d) { dist[u] = d; int ans = u; for (int v : E[u]) { if (v == p) continue; int tmp = dfs(v, u, d + 1); pa[v] = u; if (dist[ans] < d...
/** * 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...
// (c) Copyright 1995-2015 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 license and does not grant ...
/** * 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...
// MBT 7/25/2014 // async credit counter // // In this design, there are two clock domains. The first // clock domain (w_) receives incoming credits. The second // clock domain (r_) spends the credits. The first clock domain // never needs to know how many credits are spent; it just // accumulates how many have been re...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:03:56 02/27/2016 // Design Name: Register // Module Name: C:/Users/Ranolazine/Desktop/Lab/lab5/test_for_reg_with_reset.v // Project Name: lab5 // Target...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 13:06:52 06/28/2009 // Design Name: // Module Name: dcm // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: // R...
// $Id: c_align.v 5188 2012-08-30 00:31:31Z dub $ /* Copyright (c) 2007-2012, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of s...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k, p, x; cin >> n >> k >> p; std::vector<int> even, odd; for (int i = 0; i < n; ++i) { cin >> x; if (x % 2) odd.emplace_back(x); else ...
#include <bits/stdc++.h> using namespace std; const int N = 1000004; int a[N], arr[N], nxt[N], big[N], len[N]; int main() { int n; scanf( %d , &n); int i, idx; int mx1 = 0, mx2 = -1; for (i = 0; i < n; i++) { scanf( %d , &a[i]); if (a[i] > mx1) { mx2 = mx1; mx1 = ...
/** * 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, x, a, b, in[100], on[100], i = 0, r, y; cin >> n >> x; int t = n; while (t--) { cin >> a >> b; r = min(a, b); y = max(a, b); in[i] = r; on[i] = y; i++; } sort(in, in + n); sort(on, on + ...
// megafunction wizard: %LPM_ADD_SUB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: LPM_ADD_SUB // ============================================================ // File Name: alu_sub.v // Megafunction Name(s): // LPM_ADD_SUB // // Simulation Library Files(s): // lpm // ====================================...
#include <bits/stdc++.h> const int MAXINT = 2147483640; const long long MAXLL = 9223372036854775800LL; const long long MAXN = 1000000; using namespace std; int l[MAXN], r[MAXN]; int n; int ans[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while (T--) ...
#include <bits/stdc++.h> using namespace std; int n, m; int k; bool debug = false; char mp[170][170]; int l[170], r[170]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { scanf( %s , mp[i]); l[i] = m; r[i] = -1; for (int j = 0; j < m; j++) if (mp[i][j] == ...
// ---------------------------------------------------------------------- // Copyright (c) 2015, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> using namespace std; const int N = 2000000; const int mod = 998244353; int used[N][2]; int f[N][2]; bool ok[N]; int solve(int n, int k) { if (used[n][k]) { return f[n][k]; } if (!ok[n]) { return 0; } int last = 0; int m = n; int j = 0; f...
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; int m; cin >> m; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; if (x + y - d >= 0 && x - y - d <= 0 && x - y + d >= 0 && x + y - 2 * n + d <= 0) { cout << YES n ; ...
#include <bits/stdc++.h> using namespace std; int ans[300005]; int main() { int n, m; scanf( %d%d , &n, &m); set<int> alive; for (int i = 1; i <= n; i++) alive.insert(i); for (int i = 0; i < m; i++) { int l, r, x; scanf( %d%d%d , &l, &r, &x); set<int>::iterator it = alive.low...
/* * 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> const long long int inf = 9e18; const long double pi = 2 * acos(0.0); using namespace std; long long int power(long long int a, long long int n) { if (n == 0) { return 1; } long long int p = power(a, n / 2) % 998244353; p = (p * p) % 998244353; if (n % 2 == 1) ...
/* Copyright (C) 2016 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 http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distribute...
/** * 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 law...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double eps = 1e-6; const int mod = 1000000007; int modpow(int x, int y, int md) { if (y == 0) return 1; int ret = modpow(x, y >> 1, md); ret = (long long)ret * ret % md; if (y & 1) ret = (long long)ret * x % md; ...
`timescale 1 ns / 1 ps module axis_gpio_reader # ( parameter integer GPIO_DATA_WIDTH = 8, parameter integer GPIO_INPUT_WIDTH = 2, parameter integer GPIO_OUTPUT_WIDTH = 6 ) ( // System signals input wire aclk, input wire aresetn, inout wire [GPIO_DATA_WID...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n, a[maxn]; struct node { int pre; bool flag; int other; } num[2 * maxn]; int main(int argc, char const *argv[]) { while (cin >> n) { bool flag = true; for (int i = 0; i <= n; i++) { cin >> a[i]; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 150; const double eps = 1e-8; struct point { double x, y; point() {} point(double _x, double _y) : x(_x), y(_y) {} friend bool operator<(const point &a, const point &b) { if (fabs(a.x - b.x) < eps) { return a.y < b.y; ...
#include <bits/stdc++.h> using namespace std; const int M = 10 + 10; int minn0[M][M]; int minn[M][M]; int dig[M]; int dignum; int fac(int x) { int ans = 1; for (int i = 1; i <= x; i++) { ans = ans * i; } return ans; } int ex(int a, int x) { int ans = 1; for (int i = 1; i ...
#include <bits/stdc++.h> using namespace std; int work() { long long n, q; cin >> n >> q; while (q--) { long long x, y; cin >> x >> y; if ((x + y) % 2 == 0) { long long w = 0; long long a = (x - 1) / 2; w += a * n; if (x % 2 == 1) { w += (y + 1...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, i, l, k; cin >> t; while (t--) { cin >> n >> k >> l; int s = 0, f = 2 * k - 1, dep, flg = 1; for (i = 1; i <= n; i++) { cin >> dep; if (!flg) continue; if (l < dep) { cout << NO << ...
#include <bits/stdc++.h> using namespace std; inline long long GCD(long long a, long long b) { while (b != 0) { int t = a; a = b; b = t % b; } return a; } inline long long LCM(long long a, long long b) { if (a == 0 || b == 0) return GCD(a, b); return a * b / GCD(a, b); } ...
#include <bits/stdc++.h> using namespace std; const int maxn = 510; const int MOD = 1e9 + 7; long long dp[2][maxn][maxn]; int N, M; char s[maxn][maxn]; void add(long long &x, long long y) { x += y; if (x >= MOD) x -= MOD; } int main() { scanf( %d%d , &N, &M); for (int i = 1; i <= N; i+...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; string a[N]; int r[N], c[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; for (int i = 0; i <= n; i++) r[i] = 0; for (int j = 0; j <= m;...
module aes_8_bit (rst, clk, key_in, d_in, d_out, d_vld); input rst, clk; input [7:0] key_in; input [7:0] d_in; output [7:0] d_out; output reg d_vld; //key scheduler controller wire [3:0] round_cnt_w; reg input_sel, sbox_sel, last_out_sel, bit_out_sel; reg [7:0] rcon_en; ...
// ---------------------------------------------------------------------- // Copyright (c) 2016, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
/* File: pulse2toggle.v This file is part of the Parallella FPGA Reference Design. Copyright (C) 2013 Adapteva, Inc. Contributed by Roman Trogan <> 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 Softwar...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const double PI = 3.1415926535897932; const int dir[8][2] = {-1, -1, -1, 0, -1, 1, 0, -1, 0, 1, 1, -1, 1, 0, 1, 1}; const int maxn = 2e5 + 5; const int MOD = 998244353; int n, m; long long A[maxn], invA[maxn]; int w[maxn]; bool ...
(** * Rel: Properties of Relations *) Require Export SfLib. (** This short, optional chapter develops some basic definitions and a few theorems about binary relations in Coq. The key definitions are repeated where they are actually used (in the [Smallstep] chapter), so readers who are already comfortable...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11:35:06 04/15/2014 // Design Name: // Module Name: diff_d2e // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // /...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 10; string s[105]; int n, last_hh, last_mm, last_tme, cur_tme, cur_mm, cur_hh, ans = 1, cnt = 0; int calch(int i) { return (s[i][1] - 0 ) * 10 + s[i][2] - 0 ; } int calcm(int i) { return (s[i][4] - 0 ) * 10 + s[i][5] - 0 ; } int main(...
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 10; int a[N], b[N]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> ans; for (int i = 1; i <= n; i++) { b[i] = a[i] - a[i - 1]; } for (int i = 1; i <= n; i+...
module top ( // CLOCKS input CLOCK50, RESET_N, // SWITCH Y LEDS input [3:0]SWITCH_ARRAY_IO, output [7:0]LED_ARRAY_IO, // QSYS BULLSHIT output wire hps_io_hps_io_emac1_inst_TX_CLK, output wire hps_io_hps_io_emac1_inst_TXD0, output wire hps_io_hps_io_emac1_inst_TXD1, output wir...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; struct dsu { int forests = 0, parent[N], groupsize[N]; void add(int x) { parent[x] = x; groupsize[x] = 1; forests++; } int findset(int node) { if (parent[node] == node) return node; return parent[nod...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: alt_rom.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ================================...
/** * 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...
#include <bits/stdc++.h> using namespace std; namespace fastIO { bool IOerror = 0; inline bool blank(char ch) { return ch == || ch == n || ch == r || ch == t ; } inline long long read() { bool sign = 0; char ch = getchar(); long long x = 0; for (; blank(ch); ch = getchar()) ...
#include <bits/stdc++.h> using namespace std; const int N = 105, mod = 1e9 + 7; int dp[N][N * N]; bool done[N][N * N]; int fact[N], inv[N]; int arr1[N]; int arr2[N]; int n, k; long long m; inline int add(int a, int b) { int res = a + b; if (res >= mod) res -= mod; return res; } inlin...
#include <bits/stdc++.h> using namespace std; const int maxN = 11111; pair<int, int> a[maxN]; short dp[maxN][maxN]; int s[maxN]; bool mycmp(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) return (a.second < b.second); return (a.first > b.first); } int main() { ios_base::sync_...
#include <bits/stdc++.h> using namespace std; long long n, d; bool b; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { cin >> n >> d; b = false; if (d <= n) { cout << YES n ; continue; } for (long long x = 1;...
#include <bits/stdc++.h> using namespace std; const int N = 200004 * 4 + 11; long long k[N], add[N]; int a[200004]; int n, m; int x, y; long long z; long long ans; int build(int l, int r, int o) { add[o] = 0; if (l == r) return k[o] = a[l]; int mid = ((l + r) >> 1); return k[o] = build...
`timescale 1 ns / 1 ns ////////////////////////////////////////////////////////////////////////////////// // Company: Rehkopf // Engineer: Rehkopf // // Create Date: 01:13:46 05/09/2009 // Design Name: // Module Name: address // Project Name: // Target Devices: // Tool versions: // Description: Address logic w/ S...
/** * 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 = 2e5 + 3; int a[MAXN], b[MAXN], p[MAXN]; int read() { int x = 0, w = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) w = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = (x << 3) + (x << ...
/* * 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> const int maxn = 200005, K = 37, mod = 1e9 + 7; int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; } int dec(int a, int b) { return a - b < 0 ? a - b + mod : a - b; } int mul(int a, int b) { return 1ll * a * b % mod; } int ksm(int a, int b = mod - 2) { int ret = 1;...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: info_fifo.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // =================================...
#include <bits/stdc++.h> using namespace std; long long n, m, a[100005], tot = 0, tmp; int main() { ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); cin >> n >> m; for (long long i = 1; i <= m; i++) { cin >> a[i]; if (i + a[i] - 1 > n) { cout << -1 << endl; ...
//======================================================= // ECE3400 Fall 2017 // Lab 3: Template top-level module // // Top-level skeleton from Terasic // Modified by Claire Chen for ECE3400 Fall 2017 //======================================================= `define ONE_SEC 25000000 module DE0_NANO( //...
#include <bits/stdc++.h> using namespace std; bool a[55][55], b[55][55], ans[55][55]; int n, m, ans_cnt; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j]; for (int i = 1; i <= n - 1; i++) for (int j = 1; j <= m - 1; j++) if (a[i...
#include <bits/stdc++.h> using namespace std; struct edge { int v, w; edge* next; }; const int N = 100010; int n, p, ordcnt; bool vis[N], cut[N]; int ord[N], sum[N], mex[N], q[N], dep[N], digit[N], rdigit[N], rprod[N], prod[N]; edge* g[N]; void add_edge(int u, int v, int w); void calc_...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 21:24:17 03/23/2016 // Design Name: sumcomp4s // Module Name: C:/XilinxP/Practica2/sumcomp4s_test.v // Project Name: Practica2 // Target Device: // Tool...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, m, k, l; cin >> n >> m >> k >> l; if (((k + l + m - 1) / m) * m > n) { cout << -1; return 0; } cout << (k + l + m - 1) / m; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m1 = 0, m2 = 0; cin >> n; vector<vector<long long> > m(n, vector<long long>(n)); vector<int> a(n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> ...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: log_fifo.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ==============================================...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1E5 + 5; long long m, n, k, alice[MAXN], bob[MAXN]; bool cmp(int x, int y) { return x > y; } int main() { cin >> n >> m >> k; for (int i = 0; i < n; i++) cin >> alice[i]; for (int i = 0; i < m; i++) cin >> bob[i]; if (n > m) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; int main() { int i, j; int n, pare[maxn], mark[maxn]; while (scanf( %d , &n) != EOF) { memset(pare, 0, sizeof(pare)); memset(mark, 0, sizeof(mark)); for (i = 2; i <= n; i++) { scanf( %d , &pare[i]); ...
//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...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; const int N = 100100; struct point { int id, val, sum; } a[N], b[N]; bool cmp(point x, point y) { return x.val > y.val; } int main() { int n, m; scanf( %d%d , &n, &m); int na = 0; int nb...
#include <bits/stdc++.h> using namespace std; const int N = 3010; const int M = 11; const int INF = 1 << 30; const double EPS = 1e-8; const int MOD = 1000000007LL; int n, tot[N]; vector<int> edge[N], edge2[N]; int dfs(int u, int fa) { int num = 0, sz; sz = edge[u].size(); for (int i = 0; i...
#include <bits/stdc++.h> using namespace std; int main() { int k; vector<int> A; for (int i = 0; i < 4; ++i) { cin >> k; A.push_back(k); } sort(A.begin(), A.end()); if (A[0] + A[1] + A[2] == A[3] or A[0] + A[3] == A[1] + A[2]) { cout << YES ; } else { cout << NO...
#include <bits/stdc++.h> using namespace std; int main() { long long n, s[3010], c[3010], ans = 1e10; cin >> n; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) cin >> c[i]; for (int i = 0; i < n; i++) { long long min1 = 1e10, min2 = 1e10; for (int j = 0; j < i; j...
// ---------------------------------------------------------------------- // Copyright (c) 2015, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
/** * 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 Header Begin ========================================== // // OpenSPARC T1 Processor File: cpx_buf_p4.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 2004,2007 Tommy Thorn - All Rights Reserved // // 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 Foundatio...
// // fixed for 9.1 jan 21 2010 cruben // //`include "timescale.v" `include "i2c_master_defines.v" module i2c_opencores ( wb_clk_i, wb_rst_i, wb_adr_i, wb_dat_i, wb_dat_o, wb_we_i, wb_stb_i, /*wb_cyc_i,*/ wb_ack_o, wb_inta_o, scl_pad_io, sda_pad_io ); // Common bus signals input wb_clk_i; // WISHBONE cloc...
#include <bits/stdc++.h> using namespace std; int n, m; char grid[55][55]; char vis[55][55]; int di[] = {0, 1, -1, 0}; int dj[] = {1, 0, 0, -1}; bool dfs(int pi, int pj, char c, int li = -1, int lj = -1) { if (vis[pi][pj]) return true; vis[pi][pj] = true; for (int d = 0; d < 4; d++) { in...
/* * 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...
/* File: eio_tx.v This file is part of the Parallella Project . Copyright (C) 2014 Adapteva, Inc. Contributed by Fred Huettig <> 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, eithe...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const long double PI = acosl(-1.0); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; int a[n][m], ans[n][m]; for (long long i = 0; i < n; i++) for (long long j = 0; j < m; j++) cin...
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; long long int inf = 1e9 + 7; void solve() { long long int n, m; cin >> n >> m; vector<vector<long long int> > v(n, vector<long long int>(m)); long long int i, j; for (i = 0; i < n; i++) { for (j = 0; j < m; j++)...
/* module for a simple PWM generator stage */ module pwm_output_stage (clk, reset, sel, adr, data, pwm_out); parameter REG_WIDTH = 32; //width of internal registers and counter, determines min frequency parameter ADR_FREQ = 2'b00; //the different register adresses parameter ADR_ON = 2'b01; parameter ADR_CO...
#include <bits/stdc++.h> const long long N = 5e5 + 5; const int MOD = 1e9 + 7; using namespace std; int n; int a[N]; long long b[N], c[N]; multiset<long long> s; void xuly() { cin >> n; for (int i = (1); i <= (n); ++i) cin >> a[i]; sort(a + 1, a + 1 + n); cout << (n - 1) / 2 << n ; ...
#include <bits/stdc++.h> using namespace std; int a[100010], dp[100010], rec[100010]; int n; int main() { while (~scanf( %d , &n)) { int maxn = 0; for (int i = 1; i <= n; i++) { dp[i] = 1; scanf( %d , &a[i]); } for (int i = 1; i <= n; i++) { rec[a[i]] = 1; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 12:08:40 11/19/2015 // Design Name: // Module Name: EX_MEM // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // ...
#include <bits/stdc++.h> using namespace std; int n, a[211111]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } long long l = 0; long long r = 0; long long suml = 0; long long sumr = 0; for (int i = 0; i < n; i++) { if (a[i] == 1) { r++; ...
module Timer(clk_i, signal_i, second_o); input clk_i; input [2:0] signal_i; output [31:0] second_o; reg [31:0] counter; reg [1:0] state; reg [31:0] second; assign second_o = second; `define SSTOP 2'b00 `define SSTART 2'b01 `define SPAUSE 2'b10 initial begin state = `SSTOP; counter = 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; int main() { int n, i, j, k, l, m, t; vector<int> a[10001]; cin >> n; for (i = 1; i < n; i++) { cin >> m >> t; a[m].push_back(t); a[t].push_back(m); } l = 0; m = 0; int b[30001], c[30001]; for (t = 1; t <= n; t++) { ...