text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int h1, h2; int a, b; int ans = 0; int main() { scanf( %d%d , &h1, &h2); scanf( %d%d , &a, &b); h1 += a * 8; if (h1 >= h2) printf( 0 n ); else if (h1 < h2 && b >= a) printf( -1 n ); else if (h1 < h2 && b < a) { int num1 = ...
#include <bits/stdc++.h> using namespace std; struct QUERY { int query, time, number; }; vector<map<int, int> > tree; void update(int v, int tl, int tr, int pos, int query, int value) { int tm = (tl + tr) / 2; if (query == 1) { if (tl == tr) return; tree[v][value]++; if (pos <= t...
#include <bits/stdc++.h> using namespace std; const int N = 355001; const int SQRTN = 320; const int LOGN = 20; const long double PI = acos(-1); const long double TAU = 2 * PI; int n, a[N], idx[N], last, m, an[N]; long long ans; signed main() { cin >> n >> m; for (int i = 1; i <= n; i++) { ...
#include <bits/stdc++.h> using namespace std; struct node { int x, y; }; int main() { int n; while (scanf( %d , &n) != EOF) { int i, j, cnt = 0; node a[110]; for (i = 0; i < n; i++) { scanf( %d%d , &a[i].x, &a[i].y); } bool u[110] = {0}; queue<int> q; ...
module premuat3_16( enable, inverse, i_0, i_1, i_2, i_3, i_4, i_5, i_6, i_7, i_8, i_9, i_10, i_11, i_...
module mux_16to1 ( input [3:0] s, input i15, i14, i13, i12, i11, i10, i9, i8, i7,i6, i5, i4, i3, i2, i1, i0, output z); wire int0 , int1 , int2 , int3 , int4 , int5 , int6 , int7; wire int8 , int9 , int10, int11, int12, int13, int14, int15; not (s0_bar, s[0]); not (s1_bar, s[1]); not (s2_bar, s[2]); not (s3_...
#include <bits/stdc++.h> using namespace std; const int N = 1111; int n; struct Edge { int u, v; long long weight; int adj(int x) { return x == u ? v : u; } }; struct Path { int u, v; long long weight; }; vector<Edge> E; vector<int> G[N]; vector<Path> res; int Trace[N]; int F...
//---------------------------------------------------- // A four level, round-robin arbiter. This was // orginally coded by WD Peterson in VHDL. //---------------------------------------------------- module arbiter ( clk, rst, req3, req2, req1, req0, gnt3, gnt2, gnt1, gn...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll OO = 1e18; int di[8] = {0, 0, 1, -1, -1, 1, -1, 1}; int dj[8] = {1, -1, 0, 0, 1, 1, -1, -1}; string ys = YES , no = NO ; void fast() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } string s1, s2; int...
#include <bits/stdc++.h> using namespace std; int main() { int n, c = 0; cin >> n; int a[n], b[n]; map<int, int> mp; for (int i = 1; i <= 1001; i++) { mp[i] = 0; } for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n - 1; i >= 0; i--) { if (mp[a[i]] == 0)...
/******************************************************************************* * 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 ...
`timescale 1 ns / 1 ps `default_nettype none `define WIDTH 32 module j1b(input wire clk, input wire resetq, output wire uart0_wr, output wire uart0_rd, output wire [7:0] uart_w, input wire uart0_valid, input wire [7:0] uart0_data ); wire io_rd, io_wr...
///////////////////////////////////////////////////////////////////// //// //// //// WISHBONE DMA WISHBONE Interface //// //// //// //// ...
/** * 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 M1 = 998244353; long long M2 = 1000000007; long long fact[100005]; long long prime[169] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, ...
#include <bits/stdc++.h> using namespace std; int main() { long long int x, d, nxt = 1, arr[10001] = {0}, pos = 0; cin >> x >> d; for (int j = 30; j >= 0; j--) if (x >= (((long long int)1 << j))) { x -= ((long long int)1 << j); for (int i = 1; i <= j; i++) arr[pos++] = nxt; ...
/** * 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 M = 2e5 + 10; int n, k, m, kk, x, b[M]; int main() { int T; cin >> T; while (T--) { cin >> n >> k; kk = 1; m = 0; for (int i = 1; i <= n; i++) { cin >> x; if (x % 2) { m++; if (kk < k)...
#include <bits/stdc++.h> using namespace std; long long max(long long x, long long y) { return x > y ? x : y; } long long min(long long x, long long y) { return x < y ? x : y; } long long gcd(long long p, long long q) { if (q == 0) return p; return gcd(q, p % q); } bool check(long long b, long long ...
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}; int dy[] = {1, 0, -1, 0, 1, -1, 1, -1}; void fast() { std::ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } string t; bool solve(int m) { return t.substr(0, m) == t.substr(t.size() - m...
/* * Milkymist VJ SoC * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * * 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, version 3 of the License. * * This program is distributed ...
#include <bits/stdc++.h> using namespace std; int n, x, y, z, a[200005], o, X, Y, Z, XY, XZ, YZ; bool ok(int t) { X = Y = Z = XY = XZ = YZ = 0; for (int i = o; i; i--) { if (X + XY + XZ < t && a[i] <= x) X++; else if (Y + XY + YZ < t && a[i] <= y) Y++; else if (Z + XZ + Y...
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; const int N = 2e5 + 10; const int M = 300; int a[N]; int b[N]; int typ[N]; int flag[N]; int root[N]; int tmp[N]; int q[N]; int qn; int find_root(int u) { if (u == root[u]) { return u; } root[u] = find_r...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, s1, s2, s3, s4; cin >> a >> b >> c; s1 = a + c + b; s2 = a + a + b + b; s3 = a + c + c + a; s4 = b + c + c + b; cout << min(s1, (min(s2, min(s3, s4)))); }
#include <bits/stdc++.h> using namespace std; long long t; long long a[200005]; int main() { ios_base::sync_with_stdio(false); cin >> t; while (t--) { long long n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] >= 0) a[i] %= n; 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; long long solve(int n) { if (n < 5) return n * (n - 1) / 2; long long ans = 0; int x = 0; for (int i = 0; i <= 8; i++) { int xx = 5 * pow(10, i); if (n < xx) { if (n < 2 * xx / 10) { if (n != 2 * xx / 10 - 1) ret...
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; int a[maxn]; unordered_map<int, int> b, c; unordered_map<int, int>::iterator it, it2; vector<int> ans; int main() { ios_base::sync_with_stdio(0); int n, m, p; cin >> n >> m >> p; int x; for (int i = 0; i < n; ++i) c...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000 * 1000 * 1000 + 9; const int MAX_N = 1000 * 1000 + 10; long long dp1[MAX_N]; int main() { int n; scanf( %d , &n); n /= 2; if (n == 1) { printf( %d n , 10); return 0; } dp1[1] = 5; for (int i = 2; i <= n ...
#include <bits/stdc++.h> using namespace std; template <typename T> T sqr(T x) { return x * x; } template <typename T> T abs(T x) { return x < 0 ? -x : x; } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } int f[1 << 20]; int g[1 << 20]; void upd_min(int &x, ...
#include <bits/stdc++.h> using namespace std; bool check(int c1, int c2, int c3, int v1, int v2, int v3, int m) { return (c1 >= v1 && c1 <= 2 * v1 && c2 >= v2 && c2 <= 2 * v2 && c3 >= v3 && c3 <= 2 * v3 && 2 * m >= c3 && 2 * m < c2 && c3 < c2 && c2 < c1 && m <= c3); } int main() { ...
#include <bits/stdc++.h> using namespace std; int main() { string x; cin >> x; int c1 = 0, c0 = 0; bool f = 0; for (int i = 0; i < x.size(); i++) { if (x[i] == 0 ) { c0++; } else if (x[i] == 1 ) { c1++; } if (c0 < 7 && x[i] == 1 ) { c0 = 0; ...
#include <bits/stdc++.h> using namespace std; const long long int nax = 1e5 + 5; void solve() { long long int n; cin >> n; vector<long long int> a(n); for (auto &x : a) cin >> x; long long int sum = 0, mx = 0; for (long long int i = 0; i < n - 1; i++) { sum += max((long long int)0, a...
#include <bits/stdc++.h> using namespace std; struct ljb { int dest, flow, cost; ljb *next, *other; }; int n, s, ans1, ans2, flag[10000], cost[10000], flow[10000], u[100000], hh[10000], lim[10000]; ljb *p, *head[10000], *tail[10000], *hu[10000]; string ct, cs[10000]; void push(int x, int y, ...
#include <bits/stdc++.h> using namespace std; const int max_n = 22, inf = 1111111111; int n, m, dp[1 << max_n], a[max_n][max_n], nmask[max_n][max_n], res[max_n][max_n]; string s[max_n]; bool get_bit(int x, int poz) { return (bool)(x & (1 << poz)); } int main() { cin >> n >> m; for (int i = 0; ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; int n, k; char str[100005]; long long jie[100005]; long long ni[100005]; long long sum[100005]; long long extend_gcd(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1...
// niosII_system_tristate_conduit_pin_sharer_0.v // This file was auto-generated from altera_tristate_conduit_pin_sharer_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 12.1sp1 243 at 2017.02.07.13:28:19 `timescale 1 ps / 1 ps module niosII_system_tristate_conduit_pi...
`timescale 1 ns / 1 ps module axis_packetizer # ( parameter integer AXIS_TDATA_WIDTH = 32, parameter integer CNTR_WIDTH = 32, parameter CONTINUOUS = "FALSE", parameter ALWAYS_READY = "FALSE" ) ( // System signals input wire aclk, input wire ...
#include <bits/stdc++.h> using namespace std; int main() { int t, s, x; cin >> t >> s >> x; int tmp = x - t; if ((tmp % s == 0 || tmp % s == 1) && tmp >= 0 && tmp != 1) cout << YES ; else cout << NO ; 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...
////////////////////////////////////////////////////////////////// // // // Waveform Dumping Control // // // // This file is part of the Amber project ...
#include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; using ll = long long; using dbl = double; using ii = pair<int, int>; const ll MOD = 998244353; ll z1[2000005], z2[2000005], dp[1000005], psum[1000005]; void solveZ(string s, ll z[]) { z[0] = 0; ll L = 0, R = ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 10; long long c[2][2][maxn][maxn]; int lowbit(int s) { return s & (-s); } void modify(int x, int y, int v) { for (int i = x; i < maxn; i += lowbit(i)) for (int j = y; j < maxn; j += lowbit(j)) c[x & 1][y & 1][i][j] ^= v; return...
#include <bits/stdc++.h> using namespace std; int mp[28]; bool fl[28]; int main() { int n, k; cin >> n >> k; string s; cin >> s; memset(mp, 0, sizeof(mp)); for (int i = 0; i < s.size(); i++) { mp[s[i] - a + 1]++; } int cnt = 0; int ans = 0; for (int i = 1; i <= 26...
//`timescale 1 ns / 100 ps module dv_emmu(); parameter DW = 32; //data width of parameter AW = 32; //data width of parameter IW = 12; //index size of table parameter PAW = 64; //physical address width of output parameter MW = PAW-AW+IW; //table data width paramet...
// 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 : Fri Oct 27 10:20:39 2017 // Host : Juice-Laptop running 64-bit major relea...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const int INF = 0x3f3f3f3f; int sgn(double a) { return ((a > EPS) ? (1) : ((a < -EPS) ? (-1) : (0))); } int cmp(double a, double b = 0.0) { return sgn(a - b); } struct node { int x, y; node(int x = 0, int y = 0) : x(x), y(y) {} ...
#include <bits/stdc++.h> using namespace ::std; const long long maxn = 52; const long long mod = 1e9 + 7; const long long inf = 1e9 + 500; long long dp[2][maxn][maxn][maxn][maxn]; long long d[maxn]; bool bit; long long kv; void add(long long a, long long b, long long c, long long d, long long z) { ...
#include <bits/stdc++.h> using namespace std; using ii = int; int main() { ii n, i; cin >> n; ii* ar = (ii*)malloc(sizeof(ii) * n); for (i = 0; i < n; i++) { cin >> ar[i]; } ii max = *max_element(ar, ar + n); if (n == 1) cout << max - max << endl; else { ii count ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, c = 0, x; int max, min; cin >> n >> m >> min >> max; for (int i = 0; i < m; i++) { cin >> x; if (x > min && x < max) c++; if (x < min || x > max) return cout << Incorrect , 0; } if (c + 2 <= n) cout...
`timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time unit must be 1 10 or 100 * -base is the time base for each unit, ranging from seconds * to femtoseconds, and must be:...
`timescale 1ns / 1ps `define intN 32 `define addrN 9 `include "primitives.v" `define axi_module tests_stream_compute_fn `include "tests_stream_compute_fn.v" `include "array.v" module tests_axi_lite_slave_top ( input wire s_axi_aclk, input wire s_axi_aresetn, input wire `addrT s_axi_awaddr, in...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops ) #pragma GCC optimize( no-stack-protector,fast-math ) using namespace std; const long long N = 2e5 + 100, OO = 1e9 + 7, T = 1e6 + 10, M = 1e9 + 7, P = 6151, SQ = 280, lg = 20; long long n; long long pw(lo...
#include <iostream> #include <cstdio> using namespace std; #define MAXN 200005 int t, n; int a[MAXN]; int pre[MAXN], suf[MAXN]; bool pre_ok[MAXN], suf_ok[MAXN]; bool ans; int main() { //freopen( CF#696D.in , r , stdin); scanf( %d , &t); while(t --) { ans =...
/* ------------------------------------------------------------------------------- * (C)2012 Korotkyi Ievgen * National Technical University of Ukraine "Kiev Polytechnic Institute" * ------------------------------------------------------------------------------- * * *** NOT FOR SYNTHESIS *** * */ module LAG_r...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2014 Xilinx, Inc. // // 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 // /...
/////////////////////////////////////////////////////////////////////////////// // // Copyright 2010-2012 by Michael A. Morris, dba M. A. Morris & Associates // // All rights reserved. The source code contained herein is publicly released // under the terms and conditions of the GNU Lesser Public License. No part of...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int max = 2000000001, min = -2000000001; long long int x, y; string question; char answer; int i; for (i = 0; i < n; i++) { int tmp; cin >> question; cin >> x >> answer; cin....
/* * 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 = 1e6; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; set<long long> ss; for (int i = 1; i <= 1e6; i++) { long long need = i * 2; long long cards = (i * (i + 1)) / 2; l...
#include <bits/stdc++.h> using namespace std; const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1}; const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1}; const int N = 212345; int n, m, q, p[N], a[N]; int f[N], g[N], last[N]; vector<int> loc[N]; int maxm[N]; int my_find(int id, int val) { int l = 0, r = loc[id].s...
#include <bits/stdc++.h> using namespace std; int n; void result() { set<int> s; s.insert(0); int i = 1; while (i * i <= n) { int d = n / i; s.insert(d); s.insert(n / d); i++; } cout << s.size() << n ; for (auto v : s) { cout << v << ; } cout ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int N = 10e6 + 6; int p[N]; int nx[N]; int n; priority_queue<int> r; bool vis[N]; int main(void) { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { cin >> p[i]; nx[p[i] - 1] = i...
// 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 May 21 18:47:25 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> const long long int mrx = 1e6 + 5, M = 1e9 + 7; long long int mx = INT_MIN, mn = INT_MAX; using namespace std; long long int x1, x2, s, t1, t2, p, d; long long int poezd, igor; int main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cin >> s >> x1 >> x2; cin >> ...
#include <bits/stdc++.h> using namespace std; int n, x, y, pos[100001]; vector<int> d[100001]; void sieve() { memset(d, 0, sizeof(d)); for (int i = 1; i < 100001; i++) for (int j = i; j < 100001; j += i) d[j].push_back(i); memset(pos, 0, sizeof(pos)); } int main() { sieve(); scanf(...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018 // Date : Tue Sep 17 15:49:28 2019 // Host : varun-laptop running 64-bit Service Pac...
// Chuck Benz, Hollis, NH Copyright (c)2002 // // The information and description contained herein is the // property of Chuck Benz. // // Permission is granted for any reuse of this information // and description as long as this copyright notice is // preserved. Modifications may be made as long as this // notice i...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const vector<int> mods = {998244353, 1000000007, 1000000009}; const long long inf = 3e18; const double pi = acos(-1.0); const double eps = 0.0000001; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <c...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const long long int lim = 1e17; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int T = clock(); long long int n, k; cin >> n >> k; map<long long int, long long in...
#include <bits/stdc++.h> using namespace std; int n, a[200005], d[200005], m(0), id, x; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i], ++d[a[i]]; for (int i = 1; i <= n; i++) if (d[a[i]] > m) m = d[a[i]], id = i, x = a[i]; cout << n - m << n ; for (int i = id - 1; i; ...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2015.4 // Copyright (C) 2015 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1ns/1ps modul...
#include <bits/stdc++.h> using namespace std; const long long MX = 3009; long long x[MX], par[MX], num[MX], ans = 0; pair<long long, pair<long long, long long> > edg[MX]; void MS(long long v) { par[v] = -1; num[v] = x[v]; } long long FS(long long v) { if (par[v] < 0) return v; return par[v...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 228; const int big = 2e9; const int md = 1e9 + 7; struct node { int l, r, s; }; int n, m, a[N], pr[N], root[N], k, tex, jj; node t[N * 40]; bool ok; void build(int v, int l, int r) { if (l == r) return; t[v].l = ++k; t...
#include <bits/stdc++.h> using lli = long long int; int main() { std::string str; lli q, a, b, n, needSum; lli ost = 0; std::cin >> q; for (int i = 0; i < q; ++i) { std::cin >> a >> b >> n >> needSum; if (a * n == needSum || b == needSum) { std::cout << Yes << std::endl; ...
#include <bits/stdc++.h> using namespace std; string str1, str2; int main() { cin >> str1 >> str2; if (str1 == str2) cout << str1; else puts( 1 ); return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m; vector<pair<long long, long long> > a; vector<pair<long long, long long> > fact(2, {1, 0}); long long pow2(long long i, long long m) { long long r = 1, a = 2, b = i; while (b != 0) { if (b % 2 == 1) { r = (r * a) % m; ...
#include <bits/stdc++.h> inline int read() { register int s = 0, f = 1; char c; for (c = getchar(); c < 0 || c > 9 ; c = getchar()) if (c == - ) f = -1; while (c >= 0 && c <= 9 ) s = (s * 10 + (c ^ 0 )), c = getchar(); return s * f; } inline void print(register int x) { if (x...
#include <bits/stdc++.h> using namespace std; const long double pi = 3.14159265359; inline long long add(long long a, long long b, long long m) { if ((a + b) >= m) return (a + b) % m; return a + b; } inline long long mul(long long a, long long b, long long m) { if ((a * b) < m) return a * b; r...
#include <bits/stdc++.h> using namespace std; const int maxn = 505; const int mod = 1e9 + 7; long long int dp[1005][1005] = {0}; int main() { long long int n, m, k; cin >> n >> m >> k; if (2 * k > n - 1 || 2 * k > m - 1) cout << 0 << endl; else { dp[0][0] = 1; for (int i = 1;...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2004 Xilinx, Inc. // // 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 // //...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, a[N]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int s = 0; for (int i = 1; i <= n; i++) s ^= a[i]; if (n % 2 == 0) { if (s != 0) { cout << NO n ; return 0; } ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000005; const long long MOD = 1000000007; long long k, w, ans; long long fac[MAXN]; long long inv[MAXN]; long long power(long long a, long long b) { long long res = 1; while (b) { if (b & 1) (res *= a) %= MOD; (a *= a) %= ...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> adj, CC; const int MX = 1e5 + 69; int n, m, q, vis[MX], dis[MX], pa[MX], compsz[MX], D[MX]; int parent(int x) { if (x == pa[x]) return x; return pa[x] = parent(pa[x]); } bool cmp(int a, int b) { if (dis[a] != dis[b]) return dis[...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1...
#include <bits/stdc++.h> using namespace std; int t, n, m; int tot; int op[1005 * 1005 * 3][7]; string s; int a[1005][1005]; int p[1005][1005]; int sum; void check(int x1, int x2, int x3, int x4, int x, int y, int add) { sum = x1 + x2 + x3 + x4; if (!sum) return; if (sum == 1) { 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; const int maxn = 1005; char st[maxn][maxn]; char tmp[maxn][maxn]; int row[maxn], rs; int col[maxn], cs; int n, m; void init() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %s , st[i] + 1); } void work() { rs = 0; for (int i...
#include <bits/stdc++.h> constexpr int N = 55; int n; char a[N][N]; int f[N][N][N][N]; int dfs(int x, int y, int xx, int yy) { if (~f[x][y][xx][yy]) { return f[x][y][xx][yy]; } else { if (x == xx && y == yy) { return f[x][y][x][y] = (a[x][y] == # ); } else { int res ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> int arr[101]; int N; int min = 999999999; int memo[101][3]; int findMin(int idx, int prev) { int min_Rest = 999999999; if (idx == N + 1) return 0; if (memo[idx][prev] != -1) return memo[idx][prev]; if (prev != 1 && (arr[idx] == 1 || arr[idx] == 3)) min_Rest = ((m...
#include <bits/stdc++.h> using namespace std; int n, f[2][30], a[100005], b[100005]; string s; int main() { scanf( %d , &n); int now = 1, pre = 0; for (int i = 1; i <= n; i++, swap(now, pre)) { cin >> s; int len = s.length(); memset(f[now], 0, sizeof f[now]); for (int j = 0; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 300005; int sum; int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 0, x; i < n; ++i) scanf( %d , &x), sum += x; for (int i = 0;; ++i) { if (2 * sum >= (2 * k - 1) * (n + i)) { printf( %d n , i); break; ...
/* SPDX-License-Identifier: MIT */ /* (c) Copyright 2018 David M. Koltak, all rights reserved. */ /* * Convert GMII bus to Ten Bit Interface (TBI) used in SGMII. * The TBI interface connects to a SERDES transceiver. This is * the top level module. It instantiates the decode/encode, autneg, * and FIFO submodules. ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Xy Chen // // Create Date: 14:46:02 03/26/2016 // Design Name: // Module Name: sobel // Project Name: // Target Devices: zynq_7000 // Tool versions: vivado 2014.4 // Desc...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
// -- (c) Copyright 2010 - 2012 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ `timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time uni...
#include <bits/stdc++.h> template <class C, class E> inline bool contains(const C &container, const E &element) { return container.find(element) != container.end(); } 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) { ...