text
stringlengths
59
71.4k
`timescale 1 ns / 1 ps // LDAC is pulsed low after the 8 DAC registers are written module precision_dac # ( parameter CLK_DIV = 3 ) ( input wire clk, input wire [16*4-1:0] data, input wire valid, input wire [4-1:0] cmd, output reg ...
module bw_clk_cl_fpu_cmp ( so, dbginit_l, cluster_grst_l, rclk, si, se, adbginit_l, gdbginit_l, arst_l, grst_l, cluster_cken, gclk ); input si, se, adbginit_l, gdbginit_l, arst_l, grst_l, cluster_cken, gclk; output so, dbginit_l, cluster_grst_l, rclk; wire \I0/sync_cluster_master/N3 , \I0/sync_cluster...
#include <bits/stdc++.h> using namespace std; template <typename T> void out(T x) { cout << x << endl; exit(0); } const long long mod = 1e9 + 7; const int maxn = 1e6 + 5; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, start, x; int ans = 1e9 + 10; int beforeVal =...
/** * 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 long long INF = 1000 * 1000 * 1000 + 7; const long long LINF = INF * (long long)INF; const int MAX = 100 + 47; int A[MAX]; vector<int> B; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> ...
// file: main_dcm.v // // (c) Copyright 2008 - 2011 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 l...
/* Copyright (c) 2014-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...
//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...
/** * 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 a[105], b[105]; int main() { int n, i, j, k, x, y; while (~scanf( %d , &n)) { for (i = 1; i <= n; i++) { scanf( %d , &a[i]); } scanf( %d%d , &x, &y); for (i = 1, j = 0; i <= n; i++) { int count1 = 0, count2 = 0; ...
#include <bits/stdc++.h> using namespace std; inline bool smax(long long &a, long long b) { if (a < b) { a = b; return true; } else return false; } const long long MAXN = 1e5 + 100; long long dp[MAXN][4], par[MAXN][4], choose[MAXN][4], id[MAXN]; pair<long long, long long> p[MAXN], ...
/** * 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...
`timescale 1ns / 1ns module gui(clock, reset, keys, mode, //playback_keys colour, x, y, plot); input clock; input reset; input [3:0] keys; // input [3:0] playback_keys; // input [1:0] mode; output [2:0] colour; ...
#include <bits/stdc++.h> using namespace std; const int N = 510; const int mod = 1e9 + 7; long long mi1[N], mi[N], C[N][N], dp[N][N]; int main() { int n, m; scanf( %d%d , &n, &m); mi[0] = mi1[0] = 1; for (int i = 1; i <= n; i++) { mi[i] = mi[i - 1] * m % mod; mi1[i] = mi1[i - 1] * ...
#include <bits/stdc++.h> using namespace std; const int N = 5e3 + 5; int a[N], n; int dp[N][N / 2][2][2]; int solve(int idx, int lft, bool b4, bool b44) { if (lft < 0) return 1e9; if (idx == n) { if (lft) return 1e9; return 0; } int &ret = dp[idx][lft][b4][b44]; if (~ret) retur...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: fifo_64_12.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ============================================...
// ================================================================== // >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< // ------------------------------------------------------------------ // Copyright (c) 2006-2011 by Lattice Semiconductor Corporation // ALL RIGHTS RESERVED // --------...
// megafunction wizard: %RAM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: dmem16.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =============================...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int cnt = 0; int len = s.length(); for (int i = 0; i < len; i++) { if (s.at(i) == a ) cnt++; } int ltr = len - cnt; while (ltr >= cnt) { ltr--; len--; } cout << len; 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...
/** * 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 mod = 1000000007; int main() { int t; cin >> t; for (int tc = 0; tc < t; tc++) { long long a, b, c, d; cin >> a >> b >> c >> d; int temp = 1; if (a % 2) { temp *= -1; } if (b % 2) { temp *= -1; ...
#include <bits/stdc++.h> using namespace std; const long long int delta = 1e9 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int x; int d; cin >> x >> d; vector<long long int> ans; long long int cur = 1; for (int i = 31; i >= 0; i--) { long long int ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005, MAXM = 1000005, MAXT = 1 << 18; struct Edge { int to, val, next, id; } edge[MAXM]; struct MST { int u, v, w, id; } mst[MAXM]; int ppar[MAXN], head[MAXN], ist[MAXM], dep[MAXN], n, m, tot; void addedge(int u, int v, int w, int ...
#include <bits/stdc++.h> using namespace std; long long labs(long long a) { return a < 0 ? (-a) : a; } long long max(long long a, long long b) { return a > b ? a : b; } long long min(long long a, long long b) { return a < b ? a : b; } vector<long long> v; long long Intersect(pair<long long, long long> p1, ...
// vaziat meshki-ghermeze ! #include <bits/stdc++.h> #define pb push_back #define F first #define S second #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << : << x << n using namespace std; typedef long long ll; typedef long double ld; typedef string str; typedef pai...
/////////////////////////////////////////////////////////////////////////////// // vim:set shiftwidth=3 softtabstop=3 expandtab: // // Module: rm_hdr.v // Project: NF2.1 // Description: Removes any headers that might be on the packets // ///////////////////////////////////////////////////////////////////////////...
/** * 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 11/9/2014 // // Synchronous 1-port ram. // Only one read or one write may be done per cycle. `include "bsg_defines.v" module bsg_mem_1rw_sync_mask_write_bit #( parameter `BSG_INV_PARAM(width_p) , parameter `BSG_INV_PARAM(els_p) , parameter latch_last_read_p=0 , parameter enable_clock_gating_p=0 , par...
#include <bits/stdc++.h> using namespace std; int main() { long sum, i, j; cin >> sum; vector<long> length(3); for (i = 0; i < 3; i++) cin >> length[i]; vector<vector<long> > dp(2, vector<long>(sum + 1, INT_MIN)); dp[3 % 2][0] = 0; for (i = 2; i >= 0; i--) { for (j = 0; j <= sum; j...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long SZ = 107; const long long N = 1e6 + 7; const long long M = 1e4 + 7; long long n, m, c; void solve() { long long n; cin >> n; long long a[n]; vector<long long> b, c; for (long long i = 0; i < n;...
//============================================================================== // File: $URL: svn+ssh:///public/Projects/GateLib/branches/dev/Firmware/UART/Hardware/UATransmitter.v $ // Version: $Revision: 26904 $ // Author: Greg Gibeling (http://www.gdgib.com) // Copyright: Copyright 2003-2010 UC Berkeley //======...
#include <bits/stdc++.h> using namespace std; const int M = 998244353; struct modint { int val = 0; modint() {} modint(int a) : val(a) { while (val < 0) { val += M; } while (val >= M) { val -= M; } } modint(long long a) : val(a % M) { if (val < 0) ...
#include <bits/stdc++.h> using namespace std; int main() { long n, d, a[100000], diff; long sum = 0; cin >> n >> d; for (long i = 0; i < n; i++) cin >> a[i]; for (long i = 1; i < n; i++) { if (a[i - 1] >= a[i]) { diff = a[i - 1] - a[i]; a[i] = a[i] + (diff / d + 1) * d; ...
#include <bits/stdc++.h> using namespace std; long long A, B, N; long long l, t, m; int main() { cin >> A >> B >> N; for (int i = 0; i < N; i++) { cin >> l >> t >> m; if (t < A + (l - 1) * B) { cout << -1 << endl; } else { long long left = l, right = (t - A) / B + 1; ...
#include <bits/stdc++.h> using namespace std; typedef pair<long long, long long> ll; typedef vector<long long> vl; typedef vector<ll> vll; typedef vector<vl> vvl; template <typename T> ostream &operator<<(ostream &o, vector<T> v) { if (v.size() > 0) o << v[0]; for (unsigned i = 1; i < v.size(); i+...
#include <bits/stdc++.h> using namespace std; class IntTree { public: IntTree(int size) : nodes_(4 * size + 10, 0), size_(size) {} void Set(int pos, char ch) { Set(0, 1, size_, pos, ch); } int Count(int left, int right) { int mask = Mask(0, 1, size_, left, right); return CountBits(mask); ...
#include <bits/stdc++.h> using namespace std; double pa[2020], pb[2020], pab[2020]; int n, a, b; double dp[2020]; int opt[2020]; pair<int, int> solve(double mida, double midb) { dp[0] = 0; opt[0] = 0; for (int i = 1; i <= n; i++) { double& d = dp[i]; int& o = opt[i]; d = dp[i -...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector<pair<int, int>> vec; int n, a, b; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; if (a != b) { cout << rated ; return 0; } vec.push_bac...
#include <bits/stdc++.h> using namespace std; int read() { char ch = getchar(); int f = 0, x = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) x = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { f = (f << 1) + (f << 3) + ch - 0 ; ch = getchar(); } return ...
`timescale 1 ns / 1 ps `include "Video_PR_v1_0_tb_include.vh" // lite_response Type Defines `define RESPONSE_OKAY 2'b00 `define RESPONSE_EXOKAY 2'b01 `define RESP_BUS_WIDTH 2 `define BURST_TYPE_INCR 2'b01 `define BURST_TYPE_WRAP 2'b10 // AMBA AXI4 Lite Range Constants `define S_AXI_MAX_BURST_LENGTH 1 `define S_AX...
// Accellera Standard V2.5 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2010. All rights reserved. `ifdef OVL_XCHECK_OFF //Do nothing `else `ifdef OVL_IMPLICIT_XCHECK_OFF //Do nothing `else wire valid_test_expr; assign valid_test_expr = ~((^test_expr) ^ (^test_expr)); `endif // OVL_...
module first_nns_seq # ( parameter W = 15 ) ( clk, rst, g_input, e_input, o ); function integer log2; input [31:0] value; reg [31:0] temp; begin temp = value; for (log2=0; temp>0; log2=log2+1) temp = temp>>1; end endfunction localparam LOGW = log2(W); input clk; input rst; input [W-1:0] g_in...
// megafunction wizard: %LPM_CONSTANT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: lpm_constant // ============================================================ // File Name: lpm_constant4.v // Megafunction Name(s): // lpm_constant // // Simulation Library Files(s): // lpm // =======================...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 09:49:29 11/17/2015 // Design Name: bit_ctrl // Module Name: C:/Users/Camilo/Documents/Xilinx_Workspace/I2C_Module/bit_ctr2l_tst.v // Project Name: I2C_Module // Tar...
#include <bits/stdc++.h> using namespace std; using Point = complex<int>; using ll = long long; ll cross(Point a, Point b) { return 1LL * a.real() * b.imag() - 1LL * b.real() * a.imag(); } ll det(Point a, Point b, Point c) { return cross(b - a, c - a); } namespace std { bool operator<(const Point& a...
#include <bits/stdc++.h> using namespace std; int N, a[55], P; double dp[55][55][55]; double fac(int n) { double ans = 1; for (int i = 0; i < (n); i++) ans *= (i + 1); return ans; } int main(int argc, char *argv[]) { scanf( %d , &N); for (int i = 0; i < (N); i++) scanf( %d , a + i); ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, OO = 0x3f3f3f3f; const int mod = 1e9 + 7; int a[60][60]; int ans[60]; bool done[60]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { scanf( %d , &a[i][j]); ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2012 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; // verilator lint_off MULTIDRIVEN ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a == b) cout << a << endl; else cout << 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; double p = 0, x = 0, m, n, i; cin >> m >> n; for (i = m; i >= 1; i--) { p += (1 - pow(((i - 1) / m), n) - x) * i; x += 1 - pow(((i - 1) / m), n) - x; } cout << fi...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:43:39 11/19/2015 // Design Name: // Module Name: ID_EX // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // R...
/** * 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 MAX = 1200; int x, y; bool run() { bool fox = true; while (1) { if (fox) { if (x == 0) { if (y >= 22) { y -= 22; } else { return false; } } else if (x == 1) { if ...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:64000000 ) int prec[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; const int mod = 1000000000 + 7; int n, k; long long doIt(int m, int bse) { int b[10]; for (int i = 0; i < 10; i++) b[i] = 0; int res = 0; while (!b[m]) { ...
// This counter is a one hot counter; so exactly one output bit is set at all times. // For example if the value of the counter is zero, then bit 0 will be set. // This counter makes it extremely fast to detect whether the counter is a particular value. // The logic is relatively expensive, since it scales with the num...
#include <bits/stdc++.h> using namespace std; void ins(long long int a[], long long int n, long long int i = 0) { for (long long int i = 0; i < n; i++) a[i] = i; } template <typename t> void ins(t a[], long long int n, t b = 0) { for (long long int i = 0; i < n; i++) a[i] = b; } void print(long 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 la...
/* Is not working :-( */ `include "DEF.v" /* module icachel2(address, data, read, out_address, out_data, out_read); input [31:0] address; input [127:0] out_data; output [127:0] data; output [31:0] out_address; input read; output out_read; reg [127:0] icache [12'hFFF:0]; reg [31:0] tag [12'hFFF:0]; ...
#include <bits/stdc++.h> using namespace std; template <typename T> void maxtt(T& t1, T t2) { t1 = max(t1, t2); } template <typename T> void mintt(T& t1, T t2) { t1 = min(t1, t2); } bool debug = 0; int n, m, k; string direc = URDL ; const long long MOD2 = (long long)1000000007 * (long lon...
`include "hglobal.v" `default_nettype none module formal_top (); wire cn_clk; wire cn_req; wire cn_ack; wire [`ADDRESS_SIZE-1:0] cn_addr; wire [`DATA_SIZE-1:0] cn_data; wire cn_err; wire [`DATA_SIZE-1:0] cn_o_data; cellnet_source cn_src_1 ( .i_clk(cn_clk), .o_addr(cn_addr), .o_dat(cn_data), .o_r...
#include <bits/stdc++.h> using namespace std; long long t, n, S, s, up, down, mid, mx, mn, a, b, k, l, r, ans, raod; pair<long long, long long> p[300005]; int main() { cin >> t; while (t--) { cin >> n >> S; mn = 1e10; mx = 0; for (k = 1; k <= n; k++) { cin >> a >> b; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long n, m, i, ans = 0, z, j; pair<long long, long long> a[105]; vector<pair<long long, long long> > q; cin >> n >> m; for (i = 1; i <= n; i++) a[i].second = 0; for (i = 1; i <= n; i++) 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 la...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: sctag_cpx_rptr_2.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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n, a[100], b[100], i, c = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; if ((b[i] - a[i]) >= 2) c++; } cout << c; }
`timescale 1ns/10ps module simpledpram(clock, wraddress, wrdata, wren, rdaddress, rddata); parameter DATA_WIDTH = 32; parameter ADDR_WIDTH = 7; parameter INIT_FILE = "somefile.mif"; input clock; input [(ADDR_WIDTH-1):0] rdaddress; out...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 2; struct { int x; int last; string it; } a; struct kek { string w, e, r, t; }; map<char, int> bak; vector<string> st[N + 5][7], q; vector<pair<string, string> > be, en; vector<kek> ans; int n, m; string ins; cha...
//////////////////////////////////////////////////////////////////////////////// // Original Author: Schuyler Eldridge // Contact Point: Schuyler Eldridge () // button_debounce.v // Created: 4.5.2012 // Modified: 4.5.2012 // // Testbench for button_debounce.v. // // Copyright (C) 2012 Schuyler Eldridge, Boston Univer...
#include <bits/stdc++.h> using namespace std; string s; int kappa[100]; void incc(int jj) { if (kappa[jj] > 9) { kappa[jj + 1]++; kappa[jj] %= 10; incc(jj + 1); } } void get_count(int a1, int a2, int a3) { int i, j; if (a2 - a3 == 2) { j = 0; for (i = a2; i >= a...
#include <bits/stdc++.h> using namespace std; char t[5][13] = { S , M , L , XL , XXL }; char s[13]; int a[5], p[] = {0, 1, -1, 2, -2, 3, -3, 4, -4}; int main() { for (int i = 0; i < (5); ++i) scanf( %d , &a[i]); int n; scanf( %d , &n); while (n--) { scanf( %s , s); int x = 0; ...
#include <bits/stdc++.h> const double PI = 3.141592653589793238462643383279502884197169399375105820974944; using namespace std; const int MOD = 1e9 + 7; double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); } template <typename T> T mymax(T a, T b) { return (a > b) ? a : b; ...
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9; const long long inf64 = 1e18; const long long MOD = inf + 7; long long a[100005], p[100005]; long long n, m; bool check(long long mid) { long long last = 0; for (long long i = 0; i < (long long)n; i++) { if (last == m) ...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > v; int n, a, b; int max(int a, int b) { if (a > b) return a; return b; } bool checkNorm(pair<int, int> f, pair<int, int> s) { int x1, y1; x1 = max(f.first, s.first), y1 = f.second + s.second; if (x1 <= a && y1 <= b) re...
#include <bits/stdc++.h> using namespace std; template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>; void setupIO(const string &PROB = ) { ios::sync_with_stdio(false); cin.tie(nullptr); if (PROB.length() != 0) { ifstream infile(PROB + .in ); if (infile.good()) {...
#include <bits/stdc++.h> using namespace std; template <typename T> T modpow(T base, T exp) { T result = 1; while (exp > 0) { if (exp & 1) result = (result * base); base = (base * base); exp >>= 1; } return result; } int main() { queue<string> poss; long long int n, q...
#include <bits/stdc++.h> using namespace std; void small(long long m, long long s) { vector<long long> v; long long p = (s % 9 == 0) ? s / 9 - 1 : s / 9; for (long long i = 0; i < p; i++) { v.push_back(9); s -= 9; } if (m - p == 1) { v.push_back(s); } if (m - p >= 2) { ...
/* * 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 n, k; string s; long long md = 1000000007; int a[2100]; long long dp[2100][2100]; long long sdp[2100][2100]; int main() { cin >> n >> k >> s; for (int i = 0; i < n; i++) a[i] = s[i] - a ; dp[n][0] = 1; sdp[n][0] = 1; for (int i = n -...
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { long long a, b; cin >> a >> b; if (a < b) puts( -1 ); else printf( %.12f n , (a + b) / (2. * ((a + b) / (2 * b)))); return 0; }
#include <bits/stdc++.h> using namespace std; bool a[30][30]; void fun(int x, int y) { a[x][y] = a[y][x] = true; } int main() { ios_base::sync_with_stdio(false); int t; cin >> t; while (t--) { memset(a, false, sizeof a); int n, p; cin >> n >> p; if (n % 2 == 0) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 500; int n; long long a[maxn], ans; long long dfs(int l, int r, int now) { if (l == r) { return 1; } long long fenge = r + 1; for (int i = l; i <= r; i++) { if (a[i] & (1 << now)) { fenge = i; brea...
#include <bits/stdc++.h> using namespace std; int arr[4]; int aux[100010]; int next(int x) { if (x == 0) { if (arr[1] > 0) return 1; else return -1; } if (x == 1) { if (arr[0] > 0) return 0; else if (arr[2] > 0) return 2; else ret...
`include "mrfm.vh" module mrfm_iir (input clock, input reset, input strobe_in, input serial_strobe, input [6:0] serial_addr, input [31:0] serial_data, input wire [15:0] sample_in, output reg [15:0] sample_out); wire [5:0] coeff_addr, coeff_wr_addr; wire [4:0] data_addr, data_wr_addr; re...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016 // Date : Fri Sep 22 20:11:26 2017 // Host : vldmr-PC running 64-bit Service Pack 1 ...
#include <bits/stdc++.h> using namespace std; using LL = long long; const int MOD = 998244353; int f[1002][1000]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> x(n); for (int i = 0; i < n; ++i) cin >> x[i]; sort(x.begin(), x.end()); ...
#include <bits/stdc++.h> using namespace std; const int nm = 100010; int n, k; long long x[nm], y[nm]; set<pair<long long, int> > ngang, doc; vector<int> xoa1, xoa2, xoa3, xoa4; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; ++i) { int a, b, c, d; scanf( %d%d%d%d , &a, &b,...
// Copyright (c) 2000-2012 Bluespec, Inc. // 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, pub...
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; long long a = 0; long long b = 0; void dfs(vector<vector<int>> &g, vector<bool> was, int v, int lvl) { was[v] = true; if (lvl % 2 == 0) a++; else b++; for (int x : g[v]) { if (!was[x]) dfs(g, was, x, lvl +...
#include <bits/stdc++.h> using namespace std; const int MAX_N = (int)1e5 + 15; bool isAns = 1; int n, m; vector<vector<int>> gr; vector<int> a, b; void in() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; gr.resize(n + 5); for (int i = 0; i < m; ++i) { int a, b; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int mex = 1e9; for (int i = 0; i < m; i++) { int l, r; cin >> l >> r; mex = min(mex, r - l + 1); } cout << mex << n ; for (int i = 0; i < n; i++) { cout << i % mex << ; } ...
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int idx[2 * n + 1], chk = 2 * n; vector<long long int> coin; coin.push_back(0LL); for (long long int i = 1; i <= 2 * n; i++) { ...
#include <bits/stdc++.h> using namespace std; int ar[1000009]; int main() { long long a, s, d, f, g, h, j, k, l; cin >> a; k = 0; for (s = 1; s <= a; s++) { scanf( %d , &ar[s]); if (ar[s]) k++; } d = 0; l = 0; for (s = 1; s <= a; s++) { if (ar[s] == 1) { d...
#include <bits/stdc++.h> using namespace std; int prim[100000]; int main() { int a, b; cin >> a >> b; bool ok = false; int x = 0; for (int i = 3; i <= a; i++) { for (int j = 2; j < i / 2; j++) { if (i % j == 0) { ok = true; break; } } if (o...
#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { int n; cin >> n; long long int sum = 0; for (int i = 1; i < n; i++) { sum += ((n - i) * i); } cout << sum + n; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int i, n, k, r; cin >> n >> k; long long int a[n]; for (i = 0; i < n; i++) { cin >> a[i]; } long long int *m = min_element(a, a + n); r = 0; for (i = 0; i < n; i++) { if ((a[i] - *m) % k == 0) { ...
#include <bits/stdc++.h> using namespace std; map<int, int> f, num; int Q; int find(int x) { if (!f.count(x)) return x; int fa = find(f[x]); num[x] ^= num[f[x]]; return f[x] = fa; } int main() { scanf( %d , &Q); int last = 0; while (Q--) { int opt, l, r, x; scanf( %d ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 12:12:30 05/13/2015 // Design Name: // Module Name: FSMinput // Project Name: // Target Devices: // Tool versions: // Description: // // Depend...
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> int32_t mod = 1e9 + 7; void solveCase() { int n = 0, m = 0; cin >> n >> m; vector<vector<int>> mp(m, vector<int>(26, 0)); for (int i = 0; i < n; i++) { string s; ...