text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n; double f1[N], f2[N], f3[N], a[N], ans; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; f1[i] = a[i] * (f1[i - 1] + 1); f2[i] = a[i] * (f2[i - 1] + 1 + 2 * f1...
#include <bits/stdc++.h> using namespace std; long long n, m; int gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); long long a, b = 0, c = 0, t, lj = 0, k = 0, r = 0, l = 0, sum = 0, rr, ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int qtn; cin >> qtn; vector<long long int> resp(qtn + 1); resp[qtn] = 1000000000000000010; for (int i = 0; i < qtn >> 1; i++) { long long int n; cin >> n; resp[qtn - i -...
#include <bits/stdc++.h> using namespace std; const int N = 2505; int n, a[N][N]; struct node { int x, y, v; node() {} node(int _x, int _y, int _v) : x(_x), y(_y), v(_v) {} bool operator<(const node k) const { return v < k.v; } }; vector<node> p; bitset<N> r[N], c[N], t; int main() { ...
#include <bits/stdc++.h> using namespace std; vector<int> adj[3003]; int cost[3003], par[3003]; bool vis[3003]; map<pair<int, int>, bool> mark; void path(int x, int y) { if (x == y) return; cost[x] = 0; path(par[x], y); } void dfs(int u) { vis[u] = true; for (int v : adj[u]) { ...
module testbench_CSA(); parameter bits = 4; reg [bits-1:0] a; reg [bits-1:0] b; reg [bits-1:0] cin; wire [bits-1:0] sum; wire [bits-1:0] cout; integer i; integer j; integer k; integer errorFlag = 0; reg [bits-1:0] expectSum; reg [bits-1:0] expectCout; initial begin for(i = 0;i < (1<<bits-1); i = i+1) begin ...
#include <bits/stdc++.h> template <class t> inline void read(t &s) { s = 0; register int f = 1; register char c = getchar(); while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar(); s *= f; return; ...
/** * 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) 2015, Microsoft Corporation 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 source code ...
// 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:02 2017 // Host : Juice-Laptop running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 10; long long n, d, b, a[N], f[N]; int main() { long long i, j, k, t = 0, ans; scanf( %I64d%I64d%I64d , &n, &d, &b); for (i = 1; i <= n; i++) scanf( %I64d , &a[i]), f[i] = f[i - 1] + a[i]; for (i = 1; i <= n / 2; i++) ...
#include <bits/stdc++.h> using namespace std; int n, k; long long l; long long mo = 998244353; long long A[4005][4005][2]; long long B[4005]; long long a, b; long long f(long long x, long long y) { long long mid = 1; while (y) { if (y & 1) { mid = mid * x % mo; } x = x ...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-2; struct cplx { double x, y; cplx(double x1 = 0, double x2 = 0) { x = x1, y = x2; } } g[2000001], f[2000001]; cplx operator+(cplx a, cplx b) { return cplx(a.x + b.x, a.y + b.y); } cplx operator-(cplx a, cplx b) { return cplx(a.x - ...
#include <bits/stdc++.h> using namespace std; long long M = 1e9 + 7; long long powmodM(long long a, long long b, long long c = M) { long long res = 1; while (b) { if (b & 1) res = (res * a) % M; a = (a * a) % M; b /= 2; } return res; } long long power(long long a, long long b...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } class fraction { public: int a, b; fraction() { a = 0, b = 1; } fraction(int a, int b) { if (b < 0) { a *= -1; b *= -1; } if (a == 0) b = 1; int g = gcd(abs...
#include <bits/stdc++.h> using namespace std; int t[24], n; bool ok(int n) { set<int> u; int e = 0; for (int(i) = (0); (i) < (n); (i)++) for (int(j) = (0); (j) < (i); (j)++) { e++; u.insert(abs(t[i] + t[j])); } return (e == u.size()); } int main() { scanf( %d , ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int a, b, c, d; cin >> a >> b >> c >> d; long double t = (a * 1.0 / b) * (1.0 / (1 - (1 - a * 1.0 / b) * (1 - c * 1.0 ...
#include <bits/stdc++.h> using namespace std; int main() { long long n; while (cin >> n) { long long i = 5, cnt = 1, x, ans = 0, y, z = 5, m; if (n < 5 || n == 5) { if (n == 1) cout << Sheldon << endl; else if (n == 2) cout << Leonard << endl; else...
#include <bits/stdc++.h> using namespace std; struct node { int a, b, c, ty; } a[100010]; struct Tnode { int x, f, tag, ls, rs; } t[3000000]; int n, m, k, K, ans, rt, tot; bool cmp(node x, node y) { return x.a < y.a; } int getfull(int l, int r) { int s = 0; l--; for (int j = 1; j <= ...
module cache(clk,rst_n,addr,wr_data,wdirty,we,re,rd_data,tag_out,hit,dirty); input clk,rst_n; input [13:0] addr; // address to be read or written, 2-LSB's are dropped input [63:0] wr_data; // 64-bit cache line to write input wdirty; // dirty bit to be written input we; // write enable for cache line input...
#include <bits/stdc++.h> using namespace std; int main() { string s; int dif; cin >> s >> dif; set<char> st; for (int i = (0); i < s.length(); i++) st.insert(s[i]); if (s.length() < dif) { cout << impossible << endl; } else if (st.size() >= dif) cout << 0; else co...
/** * 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...
/** * 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 unit...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100 + 10; int a[MAX_N]; int main() { int n, count = 0, f = 0, h = 0, b; cin >> n; for (int i = 0; i < n; i++) { cin >> b; if (b < 0) count++; if (count == 3) { f++; a[f] = i - h; h += a[f]; ...
#include <bits/stdc++.h> using namespace std; int n, k; map<int, int> m; string s; long long ans; bool flag; void solve() { cin >> n; cin >> k; vector<int> a(n); int maxi = 0; for (auto i = 0; i < n; i++) cin >> a[i]; ; for (auto i = 0; i < n; i++) { maxi = max(maxi, a[i]...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 20:46:58 11/16/2015 // Design Name: // Module Name: AluControl // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: //...
#include <bits/stdc++.h> using namespace std; void solve() { string n; int s; cin >> n >> s; int sum = 0; vector<int> digit; for (int i = 0; i < (int)n.size(); i++) { digit.push_back(n[i] - 0 ); sum += digit[i]; } if (sum <= s) { cout << 0 << n ; return; ...
// // 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> using namespace std; const int N = 305, MOD = 1e4 + 7; char s[N]; int n, m, ndc, f[N][N][N]; int getf(int cnt, int l, int r) { if (cnt < 0) return 0; if (~f[cnt][l][r]) return f[cnt][l][r]; if (l == 1 && r == m) return f[cnt][l][r] = !cnt; int ret = 0; if (l > 1 &&...
// wasca_nios2_gen2_0.v // This file was auto-generated from altera_nios2_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 193 `timescale 1 ps / 1 ps module wasca_nios2_gen2_0 ( input wire clk, // cl...
// // 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> using namespace std; const int N = 6e5 + 5, mod = 998244353; vector<int> num; long long A[N]; int a[N]; long long sumup = 0, sumdown = 0; long long qpow(long long a, long long b) { long long c = 1; while (b) { if (b & 1) c = (a * c) % mod; b >>= 1; a = (a...
#include <bits/stdc++.h> namespace IO { const unsigned int Buffsize = 1 << 15, Output = 1 << 23; static char Ch_[Buffsize], *S_ = Ch_, *T_ = Ch_; static char Out[Output], *nowps = Out; inline void flush() { fwrite(Out, 1, nowps - Out, stdout); nowps = Out; } template <typename T> inline T Read()...
// // Paul Gao 03/2019 // // This is the sender part of bsg_link_ddr, a complete DDR communication // endpoint over multiple source-synchronous channels. // // * This module MUST be mirrored with bsg_link_ddr_downstream, which is // instantiated on the destination chip or FPGA. It is not a must to // use upstream ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFF = 1e18; const double pi = acos(-1.0); const double inf = 1e18; const double eps = 1e-9; const long long mod = 1e9 + 7; const int maxmat = 10; const unsigned long long BASE = 133333331; inline void RI(int &...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\controllerPeripheralHdlAdi_tc.v // Created: 2014-09-08 14:12:09 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // ------------------------------------------------------------- // --------...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; struct Point { int x, y; Point(int x_ = 0, int y_ = 0) : x(x_), y(y_) {} Point(std::istream &in) { in >> x >> y; x *= 2; y *= 2; } }; bool operator<(const Point &a, const Point &b) { return (a.x < b...
/* * 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 law...
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const int N_MAX = 50; int pwr(int a, int b) { if (b == 0) return 1; if (b & 1) return 1LL * pwr(a, (b ^ 1)) * a % MOD; int aux = pwr(a, (b >> 1)); return 1LL * aux * aux % MOD; } int n; int invf[N_MAX + 2]; struct T...
/* * 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, m; char block[][3][4] = {{ ### , .#. , .#. }, { #.. , ### , #.. }, { .#. , .#. , ### }, { ..# , ### , ..# }}; int cell[10][10], anscell[10][10]; int bcnt, ans; bool isPlacable...
#include <bits/stdc++.h> long long int const MOD = 1000000007; long long int const N = 1000005; long long int const LN = 20; long long int const inf = 8e18; using namespace std; long long int n, m, a[N]; vector<pair<long long int, long long int> > v[N]; struct data { long long int d, second, prev, i...
#include <bits/stdc++.h> using namespace std; long long int prime[1000010] = {0}; vector<long long int> pr; void sieve() { prime[0] = 1; prime[1] = 1; for (long long int i = 2; i <= sqrt(1000010); i++) { if (prime[i] == 0) { for (long long int j = i * i; j < 1000010; j += i) { ...
#include <bits/stdc++.h> long long mpow(long long a, long long n, long long mod) { long long ret = 1; long long b = a; while (n) { if (n & 1) ret = (ret * b) % mod; b = (b * b) % mod; n >>= 1; } return (long long)ret; } using namespace std; int a[100000 + 5]; map<int, int...
/* * 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; int main() { int arr[105]; int n; cin >> n; for (int x = 0; x < n; x++) { cin >> arr[x]; } sort(arr, arr + n); for (int x = 0; x < n; x++) { cout << arr[x] << ; } }
`include "hglobal.v" `default_nettype none `define NS_MAX_DATA_VAL MAX_DATA_VAL[DSZ-1:0] module hprb_sink #(parameter MY_LOCAL_ADDR=0, PRB_SRC_ADDR=0, ASZ=`NS_ADDRESS_SIZE, DSZ=`NS_DATA_SIZE, RSZ=`NS_REDUN_SIZE )( `NS_DECLARE_GLB_CHNL(gch), `NS_DECLARE_IN_CHNL(rcv0), `NS_DECLARE_ERR_CHNL(err0) ); pa...
Require Export Arith. Require Export ArithRing. Require Export Omega. Ltac CaseEq f := generalize (refl_equal f); pattern f at -1 in |- *; case f. Fixpoint div4 (n:nat) : nat * nat := match n with | S (S (S (S p))) => let (q, r) := div4 p in (S q, r) | a => (0, a) end. Fixpoint bsqrt (n b:nat) {struct...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11.06.2017 19:11:16 // Design Name: // Module Name: clock_divider // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; int n; int main() { scanf( %d , &n); if (n <= 2) { puts( No ); return 0; } puts( Yes ); if (n & 1) { printf( 2 1 %d n , n); printf( %d , n - 2); for (int i = 2; i < n; i++) printf( %d , i); puts( ); } els...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000100; int N; long long arr[MAXN]; long long csum; long long nv[MAXN]; long long dp[MAXN][2]; long long gogo(long long x) { nv[0] = 0; for (int i = 0; i < N; i++) { nv[i + 1] = (nv[i] + arr[i]) % x; } for (int i = 0; ...
// DESCRIPTION: Verilator: Verilog Test module // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2009 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc = 0; reg [63:0] crc; re...
#include <bits/stdc++.h> using namespace std; void read() { freopen( in.txt , r , stdin); freopen( out.txt , w , stdout); } bool voi(char c) { return (c == a || c == e || c == i || c == y || c == o || c == u ); } long long log_pow(long long b, long long p) { if (p == 0) return 1...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* This file is part of JT12. JT12 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. JT12 program is distribute...
#include <bits/stdc++.h> using namespace std; bool vis[10010][51]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int m, n; cin >> m >> n; for (int i = 0; i < m; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int temp; cin >> temp; ...
#include <bits/stdc++.h> using namespace std; int n, m, ya, yb, a[100003], b[100003], l[100003], dp[2][100003], ans; int main() { cin >> n >> m >> ya >> yb; ans = n; for (int i = 0; i < n; i++) scanf( %d , a + i); for (int i = 1; i <= m; i++) scanf( %d , b + i); b[0] = -998244353; m++; ...
#include <bits/stdc++.h> using namespace std; int n, k; int a[5005]; int q, x; bool bfind(int p) { int lf = 0; int rt = n - 1; int mid; while (lf <= rt) { mid = (lf + rt) / 2; if (a[mid] < p) { lf = mid + 1; } else if (a[mid] > p) { rt = mid - 1; } else ...
#include <bits/stdc++.h> using namespace std; const int maxn = 10e5; int minc, maxk = 0; long long int a[maxn], c[maxn]; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(30); int n, s; cin >> n >> s; for (int i = 0; i < n; i++) cin >> a[i]; int l = 0,...
// AJ, Beck, and Ray // addition testbench // 5/4/15 `include "adder_subtractor.v" `include "flag.v" `include "Implementation/mux2_1.sv" `include "adder16b.v" `include "adder4b.v" `include "fullAdder1b.v" `include "lookAhead4b.v" `include "addition.v" module additiontest(); // localize variables wire [31:0] busADD; ...
/** * decoder_complex.v - Microcoded Accumulator CPU * Copyright (C) 2015 Orlando Arias, David Mascenik * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the Lice...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, h, k; cin >> n >> m >> h >> k; cout << ((n > m) ? First : Second ) << endl; return 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 with non-Xilinx ...
#include <bits/stdc++.h> const double pi = 3.1415926535; using namespace std; int main() { double n, r; cin >> n >> r; r = sin(pi / n) * r / (1 - sin(pi / n)); cout << fixed << setprecision(7) << r; return 0; }
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; template <typename T> inline T Bigmod(T base, T power, T MOD) { T ret = 1; while (power) { if (power & 1) ret = (ret * base) % MOD; base = (base * base) % MOD; power >>= 1; } return ret; } bool ...
#include <bits/stdc++.h> using namespace std; const long long M = 2100000; const long long N = 210000; struct node { long long inx; long long a, b; long long m; long long lt, rt; }; vector<node> odd_nodes[M]; vector<node> even_nodes[M]; bool cmp(node a, node b) { if (a.lt == b.lt) ...
#include <bits/stdc++.h> using namespace std; const int DIM = 1005; bitset<DIM> oki; int val[DIM], nxt[DIM]; int main(void) { ios ::sync_with_stdio(false); cin.tie(); cout.tie(); int n, m, ans = 0; cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> val[i], nxt[i] = -1; for (int i =...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2010 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Version : 11....
#include <bits/stdc++.h> const int maxn = 5e5 + 5; const int logn = 21; const int lim = 2e1; const int maxq = 5e5 + 5; struct w { int l, r, id; friend bool operator<(w now, w oth) { return now.r < oth.r; } } qu[maxq]; int b[logn], p[logn]; void insert(int gave, int id) { for (int i = lim; i ...
#include <bits/stdc++.h> using namespace std; const long long int inf = 1e18; const int N = 1e5 + 5; void solve() { int n; cin >> n; set<int> st; for (int i = 0; i < n; i++) { int x; cin >> x; if (x % 2 == 0) st.insert(x); } int ans = 0; while (!st.empty()) { ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL); long long n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << YES ; return 0; } vector<long long> v; ...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: ninja2.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =============================...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const int maxn = 200; long long x, y, l, r; void solve() { set<long long> a, b, S; a.insert(1); b.insert(1); long long base = x; while (base <= INF) { a.insert(base); if (INF / base < x || x == 1) break; ...
#include <bits/stdc++.h> using namespace std; const int N = 60; map<double, int> p; bitset<N * N> g[N * N + 5]; int n, m; double ya[N + 5], yb[N + 5]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %lf , &ya[i]); for (int i = 1; i <= m; i++) scanf( %lf , &yb[i]); 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...
module top #(parameter CLOCK_FREQ = 33_000_000, parameter BAUD_RATE = 921600) ( input [3:0] lpc_ad, input lpc_clock, input lpc_frame, input lpc_reset, input ext_clock, input fscts, input fsdo, output fsdi, output fsclk, output lpc_clock_led, output lpc_frame_led, output lpc_reset_led, output valid_lpc_outp...
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; int n; long long x1, x2; struct sss { long long val; int num; } a[maxn]; bool cmp(const sss &a, const sss &b) { return a.val > b.val; } void scanff() { scanf( %d%I64d%I64d , &n, &x1, &x2); for (int i = 1; i <= n; i++)...
//--------------------------------------------------------------------------- // Testbench //--------------------------------------------------------------------------- // //*************************************************************************** // DISCLAIMER OF LIABILITY // // This file contains proprietary and ...
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { int num; cin >> num; mp[num]++; } if (mp.size() != 2) { cout << NO ; exit(0); } i...
#include <bits/stdc++.h> using namespace std; struct Graph { struct Edge { int u, v; int cost; Edge(int _u, int _v, int _cost) : u(_u), v(_v), cost(_cost) {} }; int n, m; bool is_digraph; vector<vector<int>> g; vector<Edge> e; Graph(int _n) : n(_n), m(0) { assert(...
/** * 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...
/////////////////////////////////////////////////////////////////////////////// // // Module: dest_ip_filter.v // Project: NF2.1 // Description: matches the ip destination to on in a list and indicates hits // /////////////////////////////////////////////////////////////////////////////// module dest_ip_filter #...
#include <bits/stdc++.h> using namespace std; int n, m, i, a[1005], b[1005], Id[1005]; int ans, ans1, ans2; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); b[i] = a[i]; Id[b[i]] = i; } sort(a + 1, a + n + 1); i = 1; while (i <= n) { ...
// (c) Copyright 1995-2017 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 ...
#include <bits/stdc++.h> using namespace std; template <class T> inline void chkmax(T &x, T y) { if (x < y) x = y; } template <class T> inline void chkmin(T &x, T y) { if (x > y) x = y; } int t, n, m, k, cnt[26]; bool vis[200020]; char s[200020]; int solve() { int ans = 1000000007; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int M = 1e4 + 10; const int MOD = 1e9 + 7; const int inf = 1e9; const double pi = acos(-1.0); const double eps = 1e-6; int dx[] = {0, -1, 0, 1}; int dy[] = {1, 0, -1, 0}; int n, m; int a[101]; int sum[102]; int l, r; ...
#include <bits/stdc++.h> using namespace std; struct IO { char buf[(1 << 20)], *p1, *p2; char pbuf[(1 << 20)], *pp; IO() : p1(buf), p2(buf), pp(pbuf) {} inline char gc() { return getchar(); if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, (1 << 20), stdin); return p1 == p2 ? : *p1...
// -------------------------------------------------------------------- // Copyright (c) 20057 by Terasic Technologies Inc. // -------------------------------------------------------------------- // // Permission: // // Terasic grants permission to use and modify this code for use // in synthesis for all Te...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 23:03:23 03/21/2014 // Design Name: // Module Name: LC3_MIO // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> const int N = 100000 + 10; int n; std::vector<int> adj[N]; bool flag[N]; void dfs(int a, int fa = -1) { if (adj[a].size() > 2) return; flag[a] = true; for (int i = 0; i < adj[a].size(); ++i) { int b = adj[a][i]; if (b != fa) dfs(b, a); } } int main() { ...
#include <bits/stdc++.h> using namespace std; const long long MAX = 1e9; vector<long long> lucky_nums; void generate_lucky(long long n) { if (n > MAX) return; long long n1 = 10 * n + 4; lucky_nums.push_back(n1); generate_lucky(n1); long long n2 = 10 * n + 7; lucky_nums.push_back(n2); ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 13:25:20 11/19/2015 // Design Name: // Module Name: MEM_WB // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // ...
/* * 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 const N = 100; int const M = 900; typedef double (*F)[N]; int a[N]; double _f[N][N], _g[N][N]; F f = _f, g = _g; inline int c2(int n) { return n * (n + 1) >> 1; } int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 0; i < n; ++i) sca...
/* ------------------------------------------------------------------------------- * (C)2007 Robert Mullins * Computer Architecture Group, Computer Laboratory * University of Cambridge, UK. * *(C)2012 Korotkyi Ievgen * National Technical University of Ukraine "Kiev Polytechnic Institute" * ------------------...
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; long long int mxm = 1e18; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int a[n], i; set<long long ...
/* * 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 main() { int t; cin >> t; while (t--) { int n; cin >> n; string s(200, a ); cout << s << endl; for (int i = 0; i < n; i++) { int u; cin >> u; s[u] = s[u] == a ? b : a ; cout << s << endl...