text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int n, m; struct BIT { long long val[500005]; void add(int x, int w) { for (; x <= m; x += x & -x) val[x] += w; return; } long long sum(int x) { long long sum = 0; for (; x; x -= x & -x) sum += val[x]; return sum; } ...
`timescale 1ns/1ps module chip (/*AUTOARG*/ // Inputs rstn ); parameter ROM_ADDRESS_SIZE = 14; input rstn; /*AUTOINPUT*/ /*AUTOOUTPUT*/ /*AUTOREG*/ /*AUTOWIRE*/ wire [31:0] pc_fetch; wire [31:0] next_pc_fetch; wire [31:0] next_pc_inc; wire [31:0] instruction; wire [31:0] ...
//############################################################################# //# Function: Falling Edge Sampled Register # //############################################################################# //# Author: Andreas Olofsson # ...
#include <bits/stdc++.h> using namespace std; #define int long long int scalar(int Ax, int Ay, int Bx, int By) { return Ax * Bx + Ay * By; } bool isok(int x1, int y1, int x2, int y2, int x3, int y3) { int Ax = x1 - x2; int Ay = y1 - y2; int Bx = x3 - x2; int By = y3 - y2...
/** * 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() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long a, b; cin >> a >> b; cout << YES << endl; for (long long i = a; i <= b; i += 2) cout << i << << i + 1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, a[200005], b[200005], s[200005], t[200005], dp[200005]; vector<int> v[200005]; bool flag; void dfs(int x, int y) { s[x] = 1; dp[x] = t[x] = b[x]; int best = 0; for (int i = (0); i < (v[x].size()); i++) { int V = v[x][i]; if (V...
#include<bits/stdc++.h> using namespace std; #define int long long int n, k; int mod(int i){return (i%n+n)%n;} int q(int x){ x = mod(x) + 1; cout << ? << x << endl; int ret; cin >> ret; return ret; } int32_t main(){ cin >> n >> k; int i=0, j=0, x; int lo, hi; while(1...
// Omar_Elaraby #include <bits/stdc++.h> using namespace std; typedef long long ll; #define EPS 1e-9 int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); // freopen( in.txt , r , stdin); // freopen( out.txt , w , stdout); int tt; cin >> tt; while (tt--) { 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; const int N = 2002; int a[N][N], b[N][N], color[N / 2]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; if (n & 1) { cout << NONE << endl; return 0; } for (int j = 0; j < n; j+...
#include <bits/stdc++.h> using namespace std; using namespace std; long long n, m, f, t, d, val; vector<long long> a, c; set<pair<long long, long long> > s; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cin >> n >> m; a.resize(n); c.resize(n); for (auto& i : a) c...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Rose-Hulman Institute of Technology // Engineer: Adam and Mohammad // Create Date: 20:09:31 10/24/2015 // Design Name: Phase 1 I2C controller // Module Name: ControllerI2C // Summary: Determin...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2003 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t; real n0; initial n0 = 0.0; real n1; initial n1 = 1.0; real n2; initial n2 = 0.1; rea...
`default_nettype none `timescale 1ns / 1ps module nkmd_progrom( input wire clk, output wire [31:0] data_o, input wire [31:0] addr_i); reg [31:0] data_ff; always @(posedge clk) begin case (addr_i) // ArithInsn{M[---] d=c0 alu=OpAdd s=c0 memrs=MNone t=c0 memrt=MNone} 16'h0000: data_ff <= 32'h00000000;...
// (C) 2001-2016 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...
/* ---------------------------------------------------------------------------------- Copyright (c) 2013-2014 Embedded and Network Computing Lab. Open SSD Project Hanyang University All rights reserved. ---------------------------------------------------------------------------------- Redistribution and use ...
/** * 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 = 1000050; bool arr[N]; int main() { int n, x; cin >> n; vector<int> v; for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); } sort(v.begin(), v.end()); if (v.size() == 1) cout << 0 << n ; else { ...
`timescale 1ns/10ps module sdram_pll_0002( // interface 'refclk' input wire refclk, // interface 'reset' input wire rst, // interface 'outclk0' output wire outclk_0, // interface 'outclk1' output wire outclk_1, // interface 'outclk2' output wire outclk_2, // interface ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10/02/2016 // Design Name: // Module Name: noise_generator // Project Name: // Target Devices: // Tool versions: // Description: generate random bit on edge ...
#include <bits/stdc++.h> using namespace std; long long mod = (long long)(1e13) + 7LL; long long osn = 137LL; long long getHash(string &s) { long long res = 0LL, curr = osn; for (int i = 0; i < s.size(); i++) { if (s[i] >= 65 && s[i] <= 90) s[i] += 32; if (s[i] == o ) s[i] = 0 ; if (...
/* Copyright (c) 2014-2016 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...
#include <bits/stdc++.h> using namespace std; int main() { int n, a, mx = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a; if (a > mx) mx = a; } if (mx - 25 > 0) cout << mx - 25 << endl; else cout << 0 << endl; return 0; }
// megafunction wizard: %LPM_RAM_DP+% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: dpram_64_32x32.v // Megafunction Name(s): // altsyncram // ============================================================ // **...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, m, x, y, cost, i, j; string s; cin >> t; while (t--) { cost = 0; cin >> n >> m >> x >> y; y = min(y, 2 * x); for (i = 0; i < n; i++) { cin >> s; for (j = 0; j < m; j++) { if (s[j] =...
`timescale 1ns / 1ps `default_nettype none ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:16:16 02/06/2014 // Design Name: // Module Name: zxuno // Project Name: // Target Devices: // Tool versions: // Description: // //...
#include <bits/stdc++.h> using namespace std; signed main() { int n; cin >> n; int ar[n]; for (int i = 0; i < n; i++) cin >> ar[i]; int max_n = pow(2, n); bool ans = false; for (int i = 0; i < max_n; i++) { int temp = i; int val = 0; for (int j = 0; j < n; j++) { ...
/* Copyright (C) {2014} {Ganesh Ajjanagadde} <> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed i...
module behavioral(out, a, b, e, w); output out; reg a, b, e, w; if (~a && ~b && ~e && ~w) begin a = 1'b0; b = 1'b0; out = 1'b1; end if (~a && ~b && ~e && w) begin a = 1'b0; b = 1'b1; out = 1'b1; end if (~a && ~b && e && ~w) begin a = 1'b1; b = 1'b0; out = 1'b1; end if (~a && ~b && e && w) begin a = 1'b...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); long long n, p, w, d; cin >> n >> p >> w >> d; bool been[int(1e5)] = {}, can = 0; long long cnt = p / w, dif = 0; while (cnt >= 0) { dif = p - cnt * w; if (been[dif % d]) break; ...
/** Micro Mezz Macro Flation -- Overheated Economy ., Last Update: Mar. 3th 2013 **/ //{ /** Header .. **/ //{ #define LOCAL #include <functional> #include <algorithm> #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <numeric> #include <cstring> #include ...
#include <bits/stdc++.h> using namespace std; template <int _mod = 998244353> class Modular { private: static constexpr int mod = _mod; static_assert(_mod > 0, mod must be positive ); int value; public: Modular() : value(0) {} template <typename U> Modular(const U& _val...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; int main() { ios_base::sync_with_stdio(0); long long cnt1, cnt2, cnt3, cnt4; cin >> cnt1 >> cnt2 >> cnt3 >> cnt4; cnt3 = (cnt3 != 0 ? 1 : 0); cnt1 -= cnt3; cnt4 -= cnt3; if (cnt1 >= 0 && cnt4 >= 0 && cnt1 == cnt4...
#include <bits/stdc++.h> using namespace std; int n; string s, t, a; void dfs(int i, int c4, int c7, bool d) { if (c4 + n - i < n / 2 || c7 + n - i < n / 2) return; if (i == n) { a = t; return; } if (d) { t[i] = 4 ; dfs(i + 1, c4 + 1, c7, 1); if (a != ) return; ...
// ============================================================== // 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...
`timescale 1ns / 1ps /* ** ** This file is accompanied by the document ** "METU CENG232 FPGA Board User Manual" ** ** v1.0, 07-April-2012 ** ** www.ceng.metu.edu.tr */ module Board232 ( input mclk, input [3:0] btn, input [7:0] sw, output [7:0] led, output reg [6:0] seg, output reg [3:0] an, ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Xilinx Inc // Engineer: Parimal Patel // // Create Date: 10/13/2017 05:12:39 AM // Design Name: GCLK Generation for RaspberryPi IOP // Module Name: counter // Description: Designed to generate up to 125 ...
/* * 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; long long int m = 1000000007; long long int n1, n2 = 0, sum = 0; long long int gcd(long long int a, long long int b) { return (b == 0) ? a : gcd(b, a % b); } bool compare(pair<string, long long int> p1, pair<string, long long int> p2) { if (p1.second != ...
/* * 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...
// megafunction wizard: %LPM_MULT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: lpm_mult // ============================================================ // File Name: lpm_mult_4_hybr_ref_pre.v // Megafunction Name(s): // lpm_mult // // Simulation Library Files(s): // lpm // =============================...
module \$__NX_MUL36X36 (input [35:0] A, input [35:0] B, output [71:0] Y); parameter A_WIDTH = 36; parameter B_WIDTH = 36; parameter Y_WIDTH = 72; parameter A_SIGNED = 0; parameter B_SIGNED = 0; MULT36X36 #( .REGINPUTA("BYPASS"), .REGINPUTB("BYPASS"), .REGOUTPUT("BYPASS") ) _TECHMAP_REPLACE_ ( .A(A), .B...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; const ll llinf = (1ll << 61) - 1; const double eps = 1e-6, ldeps = 1e-9; template <class C, size_t Y> struct tp { void operator()(ostream &os, const C &t) { tp<C, Y - 1>(...
#include <bits/stdc++.h> using namespace std; int n; vector<int> v[10005]; int color[10005]; int flag[10005]; void dfs(int src, int p, int ctr) { if (src == p) { return; } flag[src] = ctr; int i; for (i = 0; i < v[src].size(); i++) { if (color[v[src][i]] == color[src]) { ...
///////////////////////////////////////////////////////////////////// //// //// //// OpenCores MC68HC11E based SPI interface //// //// //// //// Author: Richard Herveille ...
#include <bits/stdc++.h> using namespace std; int w1, w2, h1, h2; int main() { scanf( %d%d%d%d , &w1, &h1, &w2, &h2); printf( %d n , (h1 + h2) * 2 + 4 + max(w1, w2) * 2); 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 la...
#include <bits/stdc++.h> using namespace std; long long n, m, mn, mx, l, t, mn2 = INT_MAX, mx2 = INT_MIN; set<long long> q; int main() { cin >> n >> m >> mn >> mx; long long a[m]; for (int i = 0; i < m; i++) { cin >> a[i]; if (a[i] < mn2) mn2 = a[i]; if (a[i] > mx2) mx2 = a[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 pkt_in_buf( input clk, input reset, input pkt_metadata_nocut_out_valid, input [359:0] pkt_metadata_nocut_out, input [138:0] pkt_nocut_data, input pkt_nocut_data_valid, output [7:0] pkt_nocut_data_usedw, input buf_addr_wr, input [3:0] buf_addr, output r...
////////////////////////////////////////////////////////////////////- // Design unit: Data Path Unit (Module) // : // File name : du.v // : // Description: Data Path Unit for Vending Machine // : // Limitations: None // : // System : Verilog // : // Author ...
//Com2DocHDL /* :Project FPGA-Imaging-Library :Design ContrastTransform :Function Get a reversal all ponit's color. Give the first output after 1 cycle while the input enable. :Module Main module :Version 1.0 :Modified 2015-05-16 Copyright (C) 2015 Tianyu Dai (dtysky) <> This library is free software; you can r...
`include "defines.v" `include "HRbridge.v" `timescale 1ns/1ps /*module connectRouter_nobuffer #(parameter addr = 4'b0000) //No. 0 connect router, port 0 ( input `control_w port_l0_i, output `control_w port_l0_o, input `control_w FIFO_l0_i, output `control_w FIFO_l0_o, input bfull_...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 2, K = 102, P = 102; int dp[3][K][P], a[N], mn[N][K], pre[N]; int main() { ios::sync_with_stdio(), cin.tie(0), cout.tie(0); int n, k, p; cin >> n >> k >> p; for (int i = 0; i < n; i++) { cin >> a[i]; a[i] %= p; } ...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; long long d = abs(a - b); long long p1 = (d + 1) / 2, p2 = d / 2; long long s1 = (p1 * (p1 + 1)) / 2, s2 = (p2 * (p2 + 1)) / 2; cout << s1 + s2; }
#include <bits/stdc++.h> using namespace std; set<int> vis; vector<int> ans; map<int, int> d; int main() { int n, m; cin >> n >> m; queue<int> q; int count = 0; for (int i = 0; i < n; i++) { int x; scanf( %d , &x); q.push(x); vis.insert(x); d[x] = 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 (C) 2017 Systems Group, ETHZ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed t...
#include <bits/stdc++.h> int pow(int a) { int o = 1; for (int i = 0; i < a; i++) { o = (o * 2) % 998244353; } return o; } int main(void) { int n, m; scanf( %d%d , &n, &m); printf( %d , pow(n + m)); }
#include <bits/stdc++.h> using namespace std; void solve(); int main() { solve(); return 0; } void solve() { long long int n, x, y; cin >> n >> x >> y; if (n > y) { cout << -1; return; } if ((y - n + 1) * (y - n + 1) + n - 1 >= x) { for (int i = 1; i < n; ++i) { ...
#include <bits/stdc++.h> using namespace std; int n, p, q; unsigned int C[132]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int a[132]; void Init() { C[0] = 1; for (int i = 1; i <= min(p, n - 1); ++i) { a[0] = 0; for (int j = 0; j < i; ++j) a[++a[0]] = n - j; for (int k...
#include <bits/stdc++.h> using namespace std; long long bipow(long long a) { if (a == 0) return 1; long long aea = bipow(a / 2) % 998244353; if (a % 2 == 0) return (aea * aea) % 998244353; else return ((aea * aea) % 998244353 * 2) % 998244353; } int main() { ios_base::sync_with_s...
// file: clk_divider_exdes.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 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...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename T> using vec = vector<T>; template <typename T> using Prior = priority_queue<T>; template <typename T> using prior = priority_queue<T...
/** * 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 string yno[2] = { NO n , YES n }; int dem(vector<int> &a, int k) { return upper_bound(a.begin(), a.end(), k) - lower_bound(a.begin(), a.end(), k); } int dem(long long k) { int ans = 0; while (k) { ans += k & 1; k >>= 1; ...
#include <bits/stdc++.h> using namespace std; void OJ() {} void solve() { long long n; cin >> n; long long digit = 1000000, a = -1, b = -1; for (long long i = 0; i < 1e6; ++i) { if (n >= 4 * i) if ((n - 4 * i) % 7 == 0) { if ((n - 4 * i) / 7 + i <= digit) digit ...
/* * 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; vector<vector<int>> adj; vector<int> a, b, t; vector<int> dep, sz; void dfs(int v, int p) { dep[v] = dep[p] + 1; for (auto c : adj[v]) { if (c != p) { dfs(c, v); sz[v] += sz[c]; } } } int main() { ios_base::sync_with...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long number; cin >> number; if (number == 2) { cout << 0 << endl; } else if (number == 1) { cout << 0 << endl; } else { if (number % 2 == 0) { co...
#include <bits/stdc++.h> using namespace std; int main() { int i, n; char a[1000][10]; cin >> n; cin >> a[0]; for (i = 1; i <= n; i++) { cin >> a[i]; } if (n % 2 == 0) cout << home ; else cout << contest ; return 0; }
module TopModule ( input EXT_CLK , //input EXT_RESET , //input EXT_OE , // ----------- TO MEMORY -------------- inout wire [7:0] EXT_MEM_DATA , output wire [18:0] EXT_MEM_ADDR , output wire EXT_MEM_WE , output wire EXT_MEM_O...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:29:35 03/29/2015 // Design Name: // Module Name: regfileparam_behav // Project Name: // Target Devices: // Tool versions: // Description: // ...
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx ) using namespace std; using ll = int64_t; const size_t kBuben = 10; const int kNone = -1; struct Pair { int value, count; }; struct ByValue { inline bool operator()(const Pair& a, const Pair& b) const { r...
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; if (n % 2) cout << setprecision(0) << fixed << - << ceil((1.0 * n) / 2) << n ; else cout << fixed << n / 2 << n ; } int main() { solve(); }
//***************************************************************************** // (c) Copyright 2009 - 2010 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 la...
#include <bits/stdc++.h> using namespace std; const long long N = 1e9 + 5; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, m, c, cost = 0; cin >> n >> m; for (long long i = 0; i < n; i++) { long long temp = N; for (long long j = 0; j < m; j...
#include <bits/stdc++.h> using namespace std; int ord[100100]; int inv_ord[100100]; int dep[100100]; int fa[100100][17]; vector<int> g[100100]; set<int> ss; int ts; void dfs(int p, int f) { ord[p] = ++ts; inv_ord[ord[p]] = p; dep[p] = dep[f] + 1; fa[p][0] = f; for (int i = 0; i < 1...
/* ------------------------------------------------------------------------------- * (C)2007 Robert Mullins * Computer Architecture Group, Computer Laboratory * University of Cambridge, UK. * ------------------------------------------------------------------------------- * * Virtual-Channel Buffers * ===========...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: fpu_div_exp_dp.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 an...
#include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Ford(i, a, b) for(int i = a; i >= b; i--) #define make_pair(a,b) mp(a, b) using namespace std; const int N= 2e5 + 1067, K = 17, md=1e9 + 7; int n, k; int f[N][30], g[1 << K], dem[30]; string s; bool check(int x) {...
// (C) 2001-2011 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 doc...
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_7_b2s_wrap_cmd.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module ax...
#include <bits/stdc++.h> int b[12][12]; int main() { int a; int i, j; int sum; scanf( %d , &a); memset(b, 0, sizeof(b)); for (i = 1; i <= 10; i++) for (j = 1; j <= 10; j++) { b[1][j] = b[i][1] = 1; b[i][j] = b[i - 1][j] + b[i][j - 1]; } printf( %d , b[a][a]); ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int P = 1e9 + 7; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 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 la...
// ---------------------------------------------------------------------- // Copyright (c) 2016, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> using namespace std; class Solver { public: void input() { cin >> n; a.resize(n); for (int i = 0; i < n; i++) { cin >> a[i]; } } void print() { cout << solve() << endl; } private: vector<int> a; int n; long long f(int x) { ...
#include <bits/stdc++.h> int main() { int a, b; scanf( %d%d , &a, &b); if (a == b) printf( %d n , a); else printf( 2 n ); return 0; }
#include <bits/stdc++.h> #pragma GCC target( avx2 ) using namespace std; const int N = 1e3 + 7; const int SZ = 1e6 * 14; int val[SZ]; pair<int, int> ans; int A[N], X[N], vis[N], maxind; void solve(int need, int pos, int mask = 0, int sum = 0) { if (pos > maxind) { if (need != 0) return; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; int tree[4 * MAXN]; int maxTree[4 * MAXN]; int p[MAXN]; int n; void push(int v) { if (tree[v]) { tree[2 * v] += tree[v]; tree[2 * v + 1] += tree[v]; maxTree[2 * v] += tree[v]; maxTree[2 * v + 1] += tree[v];...
/*+-------------------------------------------------------------------------- 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 ...
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } struct Edge { int ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; ++i) v[i] = i + 2; int n_colors = 1; vector<bool> prime(n, true); vector<int> colors(n); for (int i = 0; v[i] <= sqrt(n + 1); ++i) { if (prime[i]) { for ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; int n, k, m; int a[N]; int main() { scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + 1 + n); long long ans = 0; ans += 1ll * (m / (k + 1)) * (1ll * k * a[n] + a[n - 1]); an...
// // 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) // ...