text
stringlengths
59
71.4k
#pragma GCC optimize( -Ofast , -funroll-all-loops ) #pragma GCC optimize(2) #pragma GCC optimize(3, Ofast , inline ) #include<bits/stdc++.h> using namespace std; typedef long long ll; int _; int n; int a[30010]; void solve(){ cin >> _; while(_--){ cin >> n; int cn...
#include <bits/stdc++.h> using namespace std; void swap(int &a, int &b) { int temp = a; a = b; b = temp; } int main() { int n; cin >> n; int x[n], y[n], min_x = INT_MAX, max_y = INT_MIN; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; if (x[i] < min_x) min_x = x[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...
// 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 : Thu Oct 26 22:45:01 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; const int N = 201; set<int> graph[N]; map<pair<int, int>, int> edges; pair<int, int> bfs(int node) { int dist[N] = {0}; int vis[N] = {0}; queue<pair<int, int> > q; q.push({0, node}); while (!q.empty()) { int top = q.front().second; ...
#include <bits/stdc++.h> using namespace std; const int G = 3; const int MOD = 998244353; const int N = (1 << 15) + 5; int rev[N], w[N], inv_n; int bigMod(int a, int e, int mod) { if (e == -1) e = mod - 2; int ret = 1; while (e) { if (e & 1) ret = (long long)ret * a % mod; a = (long ...
//Legal Notice: (C)2018 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; const int maxn = 1e5 + 10, inf = 15e8; int A[maxn], B[maxn], C[maxn], ANSA, ANSB, n, l, r; vector<int> ed; vector<pair<int, int> > v[maxn]; int SZ[maxn], MX; bool mark[maxn]; pair<int, int> val[2 * maxn]; void dfsS(int u, int par = -1) { SZ[u] = 1; ...
`ifndef ALU_V `define ALU_V `include "adder.v" `include "multiplier.v" `include "divider.v" `include "shifter.v" `define OP_NOP 4'b0000 `define OP_ADD 4'b0001 `define OP_SUB 4'b0010 `define OP_MUL 4'b0011 `define OP_DIV 4'b0100 `define OP_LEFT_SHIFTL 4'b0101 `define OP_LE...
module top; reg pass; reg [7:0] vec; integer off; time delay; event trig; initial begin pass = 1'b1; delay = 1; // Assign before the vector (constant delay). vec = 8'hff; off = -1; vec[off] <= #1 1'b0; #2 if (vec !== 8'hff) begin $display("Failed the before vector (C) tes...
//-------------------------------------------------------------------------------- // Project : SWITCH // File : four_port_ddr_ctrl.v // Version : 0.1 // Author : Vipin.K // // Description: The four port DDR controller. // Port 0 : System to DDR DMA controller // Port 1 : User ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; string s[n]; map<string, int> m; set<string> k; int count = 0; for (int i = 0; i < n; i++) { cin >> s[i]; k.insert(s[i]); } for...
/** * 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; const int block_size = 320; const long long mod = 1e9 + 7; const long long inf = 1e9 + 7; const long double eps = 1e-9; const double PI = atan(1) * 4; template <typename T> inline int sign(const T &a) { if (a < 0) return -1; if (a > 0) return 1; ...
#include <bits/stdc++.h> int main(void) { int t, h, m; scanf( %d , &t); while (t--) { scanf( %d%d , &h, &m); printf( %d n , (23 - h) * 60 + (60 - m)); } return 0; }
/* SPDX-License-Identifier: MIT */ /* (c) Copyright 2018 David M. Koltak, all rights reserved. */ /* * Buffer GMII cycles and convert to TBI - send SGMII autoneg cycles */ module sgmii_tx_buf ( input clk_125mhz, input rst, input tbi_tx_clk, input sgmii_autoneg_start, input sgmii_autoneg_ack, ...
#include <bits/stdc++.h> using namespace std; int cnt[1005]; vector<long long int> csum; string str; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; int m; cin >> n >> m; long long int x; cin >> x; csum.push_back(x); for (int i = 1; i < n; i++) { cin...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; t = 1; while (t--) { int n, k, mx = 0, mn = 101, j; cin >> n >> k; int a[n]; for (int i = 0; i < n; i += 1) { cin >> a[i]; mx = max(mx, a[i]); ...
/* Copyright (c) 2015-2018 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri...
// // Copyright (c) 1999 Steven Wilson () // // This source code is free software; you can redistribute it // and/or modify it in source code form under the terms of the GNU // General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) // ...
#include<bits/stdc++.h> #define For(i,x,y) for (register int i=(x);i<=(y);i++) #define FOR(i,x,y) for (register int i=(x);i<(y);i++) #define Dow(i,x,y) for (register int i=(x);i>=(y);i--) #define Debug(v) for (auto i:v) cout<<i<< ;puts( ) #define mp make_pair #define fi first #define se second #defin...
// a barrel shifter to satisfy the single clock cycle constraint // and yet support the multibit shift operation // @requires: A 32-bit data input, a 32-bit control input; // @returns: A 32-bit left shifted output to support shift by 7 module shiftll (busSLL, busA, sel, zSLL, oSLL, cSLL, nSLL); output [31:0] busSLL;...
/* * lattice gas autmaton progation */ module cppg ( input CLK, input RST_X, input PPGRD, input PPGCL, input [9:0] C_VRAMADR_X, input [13:0] C_VRAMADR_Y, input [9:0] dsizx, input [9:0] dsizy, input rdata_valid, input vram_ack, input [...
// // Paul Gao 02/2021 // // This module handles the flow control (with incoming token clock) of // source-synchronous communication interface. // // data_i and data_o are both synchronous to clk_i and have zero-cycle latency. // module bsg_link_source_sync_upstream_sync #(parameter `BSG_INV_PARAM(widt...
/* * 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 long long N = 100005; const long long M = 998244353; long long pow1(long long a, long long b) { int res = 1; while (b > 0) { if (b & 1) { res = (res * a) % M; } a = (a * a) % M; b >>= 1; } return res % M; } 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. `include "verilated.v" module t; `verilator_file_descriptor file; integer chars; reg [1*8:1] letterl; reg [8*8:1] letterq; reg [16*8:1] letterw...
#include <bits/stdc++.h> using namespace std; const double one = 1.0; const double PI = 3.14159265; const long long maxn = 2e3 + 10; const long long maxx = 1e6 + 10; const long double eps = 1e-14; const long long max_len = 1e6 + 1; const long long mod1 = 1000000007; const long long mod2 = 998244353; ...
module simd_tb; //wires reg clk; reg rst; reg issue_alu_select, exec_rd_scc_value, rfa_queue_entry_serviced; reg [5:0] issue_wfid; reg [11:0] issue_source_reg1, issue_source_reg2, issue_source_reg3, issue_dest_reg1, issue_dest_reg2; reg [15:0] issue_imm_value0; reg [31:0] issue_imm_value1,...
#include <bits/stdc++.h> using namespace std; const int N = 101000; int n, z[N], a[N], b[N]; set<pair<int, int> > Set; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); } for (int i = 0; i < n; i++) { scanf( %d , &b[i]); } vector<int> ans; ...
`timescale 1 ns / 1 ps module axi_cfg_register # ( parameter integer CFG_DATA_WIDTH = 1024, parameter integer AXI_DATA_WIDTH = 32, parameter integer AXI_ADDR_WIDTH = 32, parameter integer CFG_DATA_DEFAULT = 0 ) ( // System signals input wire aclk, input wire ...
/** * 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 (C) 2016 Univ. of Nebraska - Lincoln // // 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 ve...
#include <bits/stdc++.h> using namespace std; const long long M = 100 + 19; long long d[M][M][M], n, m, k; char c; struct tuplee { long long x, y, z; }; vector<tuplee> v1, v2; long long go(long long x1, long long y1, long long z1, long long x2, long long y2, long long z2) { if (x1...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int fx[] = {+1, -1, +0, +0, +1, +1, -1, -1, +0}; int fy[] = {+0, +0, +1, -1, +1, -1, +1, -1, +0}; template <typename T> inline T GCD(T a, T b) { a = abs(a); b = abs(b); while (b) { a = a % b; swap(a, b); } ...
#include <bits/stdc++.h> using namespace std; const int mod = int(1e9) + 7; const int maxn = 200010; int n; long long a[maxn]; long long fact[maxn]; long long ans; void read() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %I64d , &a[i]); } long long exp(long long x) { long long ...
#include <bits/stdc++.h> using namespace std; int n, k; int arr[200005]; int brr[200005]; priority_queue<int, vector<int>, greater<int> > q; stack<int> s; int vis[200005]; int main() { while (cin >> n >> k) { while (!q.empty()) q.pop(); while (!s.empty()) s.pop(); memset(vis, 0, si...
/* * 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...
`timescale 1ns/1ps module sort_module #( parameter K = 128, parameter SORT_WIDTH=32, parameter PRI_POS_START = 0, parameter PRI_POS_END = 32 )( input clk, input reset, input sort_en, input place_en, input wren, input order, input [SORT_WIDTH-1:0] data_in, //we bring [key,val,delta_val,priority,pointer t...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); double a[1001][1001], x, y, z1, z2, z3, z4; long long t, n, i, j; for (i = 0; i < 1001; i++) { if (i == 0) a[0][0] = 0.0; else a[i][0] = 1.0; ...
#include <bits/stdc++.h> using namespace std; int n, q, a[2000000], f[2000000], fst[2000000], nx[2000000]; int main() { srand(time(0)); scanf( %d %d , &n, &q); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (; q--;) { long long b; cin >> b; int answer = 2e9, j = 1; lo...
/* * 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...
/* DCPU16 Verilog Implementation Copyright (C) 2012 Shawn Tan <> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:33:15 11/16/2015 // Design Name: // Module Name: ControlUnit // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: /...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll N = 2e5 + 10; const ll inf = 1e18; const ll MOD = 1e9 + 100; int n; int main() { int t; cin >> t; while (t--) { cin >> n; if (n < 4) printf( -1 n ); else { deque<int> q; q = {...
#include <bits/stdc++.h> using namespace std; int main() { long long test; test = 1; while (test--) { long long n; cin >> n; long long a[n], b[n]; for (long long i = 0; i < n; i++) cin >> a[i]; for (long long i = 0; i < n; i++) cin >> b[i]; long long aalone = 0, balon...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int n; int a[10001], c[10001], d[10001]; int ans = 0; char str[101]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %s , str); if (str[0] == M ) a[i] = 1; scanf( %d %d , &c[i], &d[i]);...
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { int t; cin >> t; while (t--) { int k1 = 0, k2 = 0; string s; cin >> s; if (s[0] == 0 ) k2++; if (s[0] == 1 ) k1++; for (int i = 1; i < s.size(); i++) { if (s[i - 1] != s[i]) { ...
#include <bits/stdc++.h> using namespace std; int n; long long c; int last, l, r; int q[200010]; long long a[400010], ans[200010]; int main() { scanf( %d%lld , &n, &c); for (int i = 1; i < 2 * n; i++) scanf( %lld , &a[i]), a[i] += a[i - 1]; for (int i = 1; i <= n; i++) { while (last < i ...
#include <bits/stdc++.h> const int N = 1e4 + 5; int ans, n; double f[2][N]; signed main() { scanf( %d%lf , &n, &f[1][1]); for (int i = 1; i <= n; i++) for (int j = 1; j <= i; j++) { if (f[i & 1][j] >= 1.0) { f[i & 1 ^ 1][j] += (f[i & 1][j] - 1.0) / 2.0; f[i & 1 ^ 1][j +...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable 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; int n; int m, q; int a[3]; string dday; int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string tostring(int x) { string temp = ; for (int i = 0; i < 2; i++) { temp = (char)( 0 + x % 10) + temp; x /= 10; } return ...
#include <bits/stdc++.h> using namespace std; int const INF = numeric_limits<int>::max(); long long const LLINF = numeric_limits<long long>::max(); long double const EPS = 1e-9; int n, m, k, q; int const N = 505; int a[N][N]; struct qu { int x, y, t; }; bool operator<(const qu& a, const qu& b) {...
#include <bits/stdc++.h> using namespace std; const int maxn = (1 << 18); struct segment { private: static const int maxn = (1 << 18); int arr[2 * maxn]; int private_sum(int node, int first, int last, int a, int b) { if (first >= a && last <= b) return arr[node]; if (a >= last || b <= f...
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n = 0; string s; long long int res = 0ll; cin >> n; cin >> s; res = (1ll * n * (n + 1)) / 2ll - 1ll * n; for (int i = 0; i + 1 < n; ++i) { ...
/* * Copyright (c) 2001 Stephen Rowland * * 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) * a...
#include <bits/stdc++.h> using namespace std; long long int min1(long long int a) { long long int mx = 0, mi = 10; while (a) { mx = max(mx, a % 10); mi = min(mi, a % 10); a /= 10; } return mi * mx; } int main() { int t; cin >> t; while (t--) { long long int a,...
/** * 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 2008 - 2013 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 /...
/* * 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 generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.2 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps mod...
#include <bits/stdc++.h> using namespace std; void solve() {} int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; long long k = 1; vector<long long> v; while (1) { long long tmp = ((1 << k) - 1) * (1 << (k - 1)); if (tmp > 100001) break; v.p...
// (C) 1992-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 simulati...
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 5; int main() { ios::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while (T--) { int n, m; cin >> n >> m; if (n % m == 0) cout << YES n ; else cout << NO n ; } }
//------------------------------------------------------------------------------ // (c) Copyright 2013-2014 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 propert...
`timescale 1ns / 1ps `define SIMULATION //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 00:55:11 12/07/2015 // Design Name: Peripheral_clk_generator // Module Name: C:/WINDOWS/system32/Timer/Periph_gen_clk_tst.v // Project Name: Timer...
#include <bits/stdc++.h> using namespace std; long long n, t, i, j, a[300006], q; int main() { scanf( %lld , &t); while (t--) { long long ans = 0; memset(a, 0, sizeof a); scanf( %lld%lld , &n, &q); for (i = 1; i <= n; i++) { scanf( %lld , &a[i]); } long long fla...
#include <bits/stdc++.h> using namespace std; int n, k, d[2][100005], q1[100005], q2[100005], x, y, st, en; char s[2][100005]; int main() { cin >> n >> k; cin >> s[0]; cin >> s[1]; d[0][0] = 1; for (en = 1; st < en;) { x = q1[st]; y = q2[st++]; if (y >= n - k) { cou...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; struct sl { int SC, LC, TS, TL; double p; } a[1005]; struct csl { long double score, tim; } f[1005][1561], ans; double a1, a2, p; int n, m, z, x, y; inline bool cmp(sl x, sl y) { return x.TL * x.p * (1 - y.p) < y.TL...
/** * 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 = 1e5 + 5; long long DP[N]; int n; int a[N]; int freq[N]; long long solve(int num) { if (num < 1) return 0; if (DP[num] != -1) return DP[num]; return DP[num] = max((long long)num * freq[num] + solve(num - 2), solve(num - ...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( O3 ) #pragma GCC optimize( O2 ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) template <typen...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int ar[n + 5]; int br[n + 5]; int mark[200005]; memset(mark, 0, sizeof mark); for (int i = 0; i < n; i++) { cin >> ar[i]; br[i] = ar[i]; } sort(br, br + n, greater<int>()); int sum...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10, C = 30; int nex[N][C], p, n, par[N], dfa[N][C]; string s, t; vector<pair<int, char> > adj_matrix[N]; long long ans; void dfs(int v, int p, int state) { if (state == (int)t.size()) ans++; for (auto pa : adj_matrix[v]) { int...
#include <bits/stdc++.h> using namespace std; int main() { int x = 0, y = 0; int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { char ch; cin >> ch; if (ch == * ) { x ^= i; y ^= j; } } } cout <<...
//***************************************************************************** // (c) Copyright 2009 - 2013 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 prope...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: fifo_174x128.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // ==============================...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.1 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; const int N = 1e5 + 5; int n; long long x, y, ans; bool comp[N]; vector<long long> primes; long long add(long long a, long long b) { return (a + b) % MOD; } long long mul(long long a, long long b) { return (a * b) % MOD; } long l...
`timescale 1ns / 1ps `include "Defintions.v" module MiniAlu ( input wire Clock, input wire Reset, output wire [7:0] oLed ); wire [15:0] wIP,wIP_temp; reg rWriteEnable,rBranchTaken; wire [27:0] wInstruction; wire [3:0] wOperation; reg signed [15:0] rResult; wire [7:0] wSourceAddr0...
#include <bits/stdc++.h> using namespace std; int Set(int N, int pos) { return N |= (1LL << pos); } int Reset(int N, int pos) { return N &= ~(1LL << pos); } bool Check(int N, int pos) { return N & (1LL << pos); } int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dy[] = {1, -1, 0, 0, 1, -1, -1, 1}; inline void cn(long...
#include <bits/stdc++.h> using namespace std; struct obj { int x, y, ind; obj(int x, int y, int ind) : x(x), y(y), ind(ind) {} obj() {} }; int main() { vector<obj> s; int n, x, y; scanf( %d , &n); for (int i = (1); i <= (n); ++i) { scanf( %d%d , &x, &y); s.push_back(obj(x...
#include <bits/stdc++.h> using namespace std; using PII = pair<int, int>; PII a[300005]; int idx[300005]; map<int, int> mp; int main() { int n; ; scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d %d , &a[i].first, &a[i].second); idx[i] = i; } sort(idx, idx + n, [&]...
#include <bits/stdc++.h> using namespace std; template <class T> inline T updmax(T& a, T b) { return a = max(a, b); } template <class T> inline T updmin(T& a, T b) { return a = min(a, b); } class Solution { public: void solve() { long long n; string s; cin >> n >> s; ...
#include <bits/stdc++.h> using namespace std; long long x[300009]; int main() { long long n; cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; sort(x, x + n); long long a = x[0], b = 1, ans = 0; for (int i = 1; i < n; i++) { ans = (ans + x[i] * (2 * b - 1) - a) % 1000000007; a...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int t; cin >> t; while (t--) { long long int n; cin >> n; string s; cin >> s; long long int oc = 0, zc = 0, fpos = -1, lpos; for (in...
`timescale 1 ns / 1 ps module PmodAD1_v1_0 # ( // Users to add parameters here // 2x89KSPS with these parameters parameter INCLUDE_DEBUG_INTERFACE = 0, parameter AD1_CLOCKS_PER_BIT = 20,//1 bit per 200ns parameter AD1_CLOCKS_BEFORE_DATA = 60,//600ns parameter AD1_CLOCKS_AFT...
#include <bits/stdc++.h> using namespace std; int arr[100007]; int main() { int i, n, k, distinct, r; map<int, int> M; while (scanf( %d%d , &n, &k) == 2) { bool flag = true; M.clear(); distinct = 0; for (i = 0; i < n; i++) { scanf( %d , &arr[i]); if (M[arr[i]] =...
#include <bits/stdc++.h> using namespace std; bitset<1000001> L, R; vector<int> H1, H2, V1, V2, res; multiset<int> AA, BB; int A[1000], B[1000]; bool solve(int *A, int s, int e, int S) { int m = (s + e) >> 1; if (s == e || S == 0) { if (S) res.push_back(A[m]); return true; } for ...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b > a) swap(a, b); if (a % b == 0) return b; else return gcd(b, a % b); } long long int a, b, k, k1, k2; int main() { cin >> a >> b; k = (a * b) / gcd(a, b); k1 = k / a; ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, t, ans = 0, i, a, b, m, x, y; cin >> t; while (t > 0) { cin >> n; vector<int> res; long long es = 0, os = 0; if ((n / 2) % 2 == 0) { cout << YES << endl; for (i = 0; i < n / 2; i++) { ...
#include <bits/stdc++.h> using namespace std; int a1, a2, b1, b2; bool sol(int a, int b) { if (b + 1 < a) return 0; if (b > (a + 1) * 2) return 0; return 1; } int main() { cin >> a1 >> a2 >> b1 >> b2; if (sol(a1, b2) || sol(a2, b1)) cout << YES ; else cout << NO ; ret...
#include <bits/stdc++.h> using namespace std; int st[100100][20]; vector<int> graph[100100], ind[100100]; int lev[100100]; int t[100100], l[100100], lg[100100]; int s[100100]; void blg(int n) { lg[0] = -1; for (int i = 0; i < n; ++i) lg[i + 1] = lg[i] + !(i & (i + 1)); } void dfs(int u, int p,...
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0); unsigned long long int binpow(unsigned long long int b, unsigned long long int n) { if (n == 0) return 1; if (n == 1) return b; if (n & 1) return binpow(b, n - 1) * b; else retu...
#include <bits/stdc++.h> using namespace std; int ax[4], ay[4], bx[4], by[4]; int xmin = 1000, xmax = -1000, ymin = 1000, ymax = -1000; bool f() { for (int i = 0; i < 4; i++) { if (bx[i] >= xmin && bx[i] <= xmax && by[i] >= ymin && by[i] <= ymax) { return 1; } } double X = ((doub...
// megafunction wizard: %RAM: 2-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: async_dpram_40W_32D.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ====================...