text
stringlengths
59
71.4k
/** * bsg_cache_to_dram_ctrl_tx.v * * @author tommy * */ `include "bsg_defines.v" module bsg_cache_to_dram_ctrl_tx #(parameter `BSG_INV_PARAM(num_cache_p) , parameter `BSG_INV_PARAM(data_width_p) , parameter `BSG_INV_PARAM(block_size_in_words_p) , parameter `BSG_INV_PARAM(dram_ctrl_burst_len_p)...
#include <bits/stdc++.h> using namespace std; long long GCD(long long x, long long y) { if (y == 0) return x; return GCD(y, x % y); } long long LCM(long long x, long long y) { return (x * y) / (GCD(x, y)); } long long LOGK(long long x, long long k) { if (x >= k) return 1 + LOGK(x / k, k); retu...
#include <bits/stdc++.h> using namespace std; struct arc_t { int u, v, c; arc_t(int _u, int _v, int _c) : u(_u), v(_v), c(_c) {} bool operator<(const arc_t& rhs) const { return c < rhs.c; } }; int pa[2001]; void set_init(int n) { for (int i = 1; i <= n; i++) pa[i] = i; } int set_find(int x...
// This file ONLY is placed into the Public Domain, for any use, // without warranty, 2013. module t ( input logic clk, input logic daten, input logic [8:0] datval, output logic signed [3:0][3:0][35:0] datao ); logic signed [3:0][3:0][3:0][8:0] datat; genvar i; generate ...
/* * Copyright (c) 2009 Zeus Gomez Marmolejo <> * * This file is part of the Zet processor. This processor is free * hardware; 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, or (at your option) an...
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin...
//Multiplier Functional Unit which multiplies 2 numbers module multiplier ( clk, //clock reset, //reset the Multiplier x, //First Number to be multiplied y, //Second Number to be multiplied prod, //result of multiplication ready //signals if the result is ready ); parameter bits = 8; //----Input Ports--- input clk...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 05/12/2015 06:11:28 PM // Design Name: // Module Name: system_controller // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Fri Oct 27 14:51:03 2017 // Host : Juice-Laptop running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; using namespace chrono; const int N = 250005; vector<int> G[N], leaf; int n, k, dep[N], par[N], ans; void dfs(int d, int u, int p) { dep[u] = d; par[u] = p; if (d >= n / k) ans = 1; int c = 0; for (auto v : G[u]) { if (dep[v]) continue;...
// // Generated by Bluespec Compiler, version 2018.10.beta1 (build e1df8052c, 2018-10-17) // // // // // Ports: // Name I/O size props // CLK I 1 clock // RST_N I 1 reset // // No combinational paths from inputs to outputs // // `ifde...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: player2.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ================================...
//-------------------------------------------------------------------------------- // Project : SWITCH // File : ethernet_top.v // Version : 0.2 // Author : Shreejith S, Vipin K // // Description: Ethernet Controller Top File // //-------------------------------------------------------------------------...
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long> > v, par; long long QN, cmd, nums = 0; map<long long, long long> ans; long long solve(long long l, long long r, long long x) { long long st = l, en = r; while (st <= en) { long long mid = (st + en) / 2; if (x <...
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y; map<long long, long long> mx, my; map<tuple<long long, long long>, long long> mt; scanf( %lld , &n); for (int i = 0; i < n; i++) { scanf( %lld%lld , &x, &y); tuple<long long, long long> a = make_tuple(x, y)...
module VgaSyncGenerator ( input CLK , output reg VGA_HS , output reg VGA_VS , output wire [10:0] VGA_POS_X , output wire [9 :0] VGA_POS_Y , output wire VGA_ENABLE ); // ------------------- Параметры синхрогенератора для выбранного разрешения -...
/** * 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 MOD = 1000000007; const int MAXN = 107; int A[50007]; int F[107][107]; unsigned long long b[107][107]; struct matrix { int n, m; int arr[MAXN][MAXN]; matrix() {} matrix(int x, int y, int V = 0) { n = x; m = y; for (i...
#include <bits/stdc++.h> using namespace std; const int maxn = 300 + 10; const int maxm = maxn * maxn; const int INF = 0x3f3f3f3f; int connect[maxn][maxn], edgecnt[maxn]; int price[maxn], vis[maxn * 2], match[maxn * 2]; int n; bool extend(int u) { vis[u] = true; for (int i = 1; i <= edgecnt[u]; ...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.1 (lin64) Build 881834 Fri Apr 4 14:00:25 MDT 2014 // Date : Thu May 22 12:56:05 2014 // Host : macbook running 64-bit Arch Linux // ...
#include <bits/stdc++.h> using namespace std; int maps[501][501]; char str[501]; int dx[11] = {-1, 0, 1, 0, -1, -1, 1, 1, -1, -1}; int dy[11] = {0, 1, 0, -1, 0, 1, 1, -1, -1, 1}; int dp[550][550][10]; int n, m; int pan(int x, int y) { if (x < 1 || x > n || y < 1 || y > m) return 1; if (maps[x][y...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const long long INFLL = 0x3f3f3f3f3f3f3f3f; const int maxn = 1e6 + 10; struct Edge { int to, nxt; long long cost; Edge() {} Edge(int to, int nxt, long long cost) : to(to), nxt(nxt), cost(...
`default_nettype none `timescale 1ns / 1ps module sia_receiver_tb(); reg [15:0] story; reg clk_i = 0, reset_i = 0; reg rxd_i = 1, rxc_i = 0; reg rxreg_oe_i = 0, rxregr_oe_i = 0; wire idle_o; wire [63:0] dat_o; wire sample_to; sia_receiver #( .SHIFT_REG_WIDTH(64), .BAUD_RATE_WIDTH(32), .BITS_WIDTH...
//Legal Notice: (C)2014 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; int main(int argc, char const *argv[]) { int n; char s[105][105]; while (~scanf( %d , &n)) { for (int i = 1; i <= n; ++i) scanf( %s , s[i] + 1); vector<pair<int, int> > r; bool rc = true; for (int i = 1; i <= n; ++i) { int j; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, name[100], cnt; string str; char ch; cin >> n >> k; cnt = 0; for (i = 1; i <= k - 1; i++) { name[i] = ++cnt; } for (i = k; i <= n; i++) { cin >> str; if (str[0] == N ) { name[i] = name[...
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); std::cout.tie(0); std::cin.tie(0); int n; std::cin >> n; int a[n]; for (int i = 0; i < n; ++i) std::cin >> a[i]; std::sort(a, a + n); for (int i = n - 1; i >= 0; --i) { int t = sqrt(a[i]); if (t * ...
//////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2014, University of British Columbia (UBC); All rights reserved. // // // // Redistribution and use in source and binary forms, w...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: ucb_bus_in.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 and/or...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double EPS = 1e-7; const int INF = 1000000000; char buf[100]; int maxl[2000000]; int maxr[2000000]; int minl[2000000]; int minr[2000000]; pair<int, int> g[2000000]; int n; int X = 0; void dfs(int, int); void ad...
//############################################################################# //# Purpose: SPI master IO state-machine # //############################################################################# //# Author: Andreas Olofsson # ...
// (C) 2001-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 simulation // files), and any associated doc...
/** * 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) 2003 Stephen Williams () * * 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; inline int read() { int x = 0; char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return x; } struct Question { int x, l, r, dat; inline Question(int tmp1 = 0, int tmp2 = 0...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 2e5 + 10; int per(int tot, int cur) { return (cur * 100 + tot / 2) / tot; } int main() { int n, k; cin >> n >> k; map<pair<int, int>, int> mc; queue<int> q; for (int i = 1; i <= n; i++) { int x...
`include "../../../rtl/verilog/gfx/gfx_wbm_read.v" module wbm_r_bench(); // wishbone signals reg clk_i; // master clock reg reg rst_i; // synchronous active high reset wire cyc_o; // cycle wire wire stb_o; // strobe output wire [ 2:0] cti_o; // cycle type id wire [ 1:0] bte...
/* * Copyright (c) 2003 Stephen Williams () * * 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 step[8][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; template <class T> inline T abs1(T a) { return a < 0 ? -a : a; } const int maxn = 100110; template <class t> struct segment_node { ...
#include <bits/stdc++.h> using namespace std; int n, m; int R[101]; double dp[100100], sum[100100]; int main() { scanf( %d%d , &n, &m); if (m == 1) { puts( 1 ); return 0; } int score = 0; dp[0] = 1; double f = 1. / (m - 1); for (int i = 0; i < n; ++i) { scanf( %d ...
#include <bits/stdc++.h> using namespace std; vector<char> v; int n; string s; bool potR() { int freq[1000]; freq[ G ] = 0; freq[ B ] = 0; freq[ R ] = 0; for (int i = 0; i < s.size(); ++i) { ++freq[s[i]]; } int cnt1 = freq[ B ]; int cnt2 = freq[ G ]; if (cnt1 >= 1 && ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int dp[4][N]; string str2[N], str3[N]; set<string> ans; int n; int cal(int len, int idx) { if (dp[len][idx] != -1) return dp[len][idx]; if (idx == n - 1) return dp[len][idx] = 1; ; int x = 0; if (idx + 2 < n) { ...
#include <bits/stdc++.h> using namespace std; char getc() { char c = getchar(); while ((c < A || c > Z ) && (c < a || c > z ) && (c < 0 || c > 9 )) c = getchar(); return c; } long long gcd(long long n, long long m) { return m == 0 ? n : gcd(m, n % m); } long long read() { long l...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; bool prime[N]; int phi[N], deg[N]; void sieve(); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); sieve(); int n, k; cin >> n >> k; priority_queue<pair<int, int>, vector<pair<int, int>>, ...
// -- (c) Copyright 2010 - 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 // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a...
#include <bits/stdc++.h> using namespace std; int main() { long long int r, x, y, x1, y1, t, u; double ans = 0; cin >> r >> x >> y >> x1 >> y1; t = abs(x - x1); u = abs(y - y1); ans = t * t + u * u; ans = sqrt(ans); ans = ans / (2 * r); ans = ceil(ans); cout << ans; retur...
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; if (a == 1) { cout << 1 << << 1 << endl << 1 << endl; } else { cout << 2 * (a - 1) << << 2 << endl << 1 << << 2 << endl; } return 0; }
/* Copyright 2018 Nuclei System Technology, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except i...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c =...
#include <bits/stdc++.h> using namespace std; int a[200005]; long double b[200005]; int n; long double dp1[200005], dp2[200005]; long double check(long double val) { int i; for (i = 0; i < n; i++) b[i + 1] = a[i] - val; dp1[1] = b[1]; long double ans = b[1]; for (i = 2; i <= n; i++) { ...
`include "assert.vh" `include "cpu.vh" module cpu_tb(); reg clk = 0; // // ROM // localparam MEM_ADDR = 4; localparam MEM_EXTRA = 4; reg [ MEM_ADDR :0] mem_addr; reg [ MEM_EXTRA-1:0] mem_extra; reg [ MEM_ADDR :0] rom_lower_bound = 0; reg [ MEM_ADDR :0] rom_upper_bo...
#include <bits/stdc++.h> using namespace std; const long long is_query = -(1LL << 62); struct line { long long m, b; mutable function<const line*()> succ; bool operator<(const line& rhs) const { if (rhs.b != is_query) return m < rhs.m; const line* s = succ(); if (!s) return 0; ...
module RAMB16_S18_S18( input WEA, input ENA, input SSRA, input CLKA, input [9:0] ADDRA, input [15:0] DIA, input [1:0] DIPA, // output [3:0] DOPA, output [15:0] DOA, input WEB, input ENB, input SSRB, input CLKB, input [9:0] ADDRB, input [15:0] DIB, input [1:0] DIPB, // output [3:0] DOPB, ...
#include <bits/stdc++.h> using namespace std; vector<int> v[300010]; int centroid[300010], Next[300010], par[300010], sz[300010]; void dfs(int cur) { sz[cur] = 1; int maxx = 0; Next[cur] = 0; for (int u : v[cur]) if (u != par[cur]) { dfs(u); sz[cur] += sz[u]; if (sz...
#include <bits/stdc++.h> using namespace std; set<int> si; int n, k; bool solve(set<int> &cands, vector<int> &chosen) { if (cands.empty()) { if (chosen.empty()) { return false; } for (int i = 0; i < k; ++i) { int cnt = 0; for (const int num : chosen) { cnt...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> A(n); vector<int> P(n + 1); for (auto &x : A) cin >> x; for (int i = 0; i < n; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 200000; const long long mod = 1e9 + 7; long long fac[maxn + 5], inv[maxn + 5]; long long f[2005]; struct node { long long x, y; } data[2005]; long long qmod(long long a, long long b) { long long ans = 1; a = a % mod; while (b...
// -- (c) Copyright 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 proper...
/* * 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...
/* * Front-end instruction pre-fetch unit with wishbone master interface * Copyright (C) 2013 Charley Picker <> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by ...
////////////////////////////////////////////////////////////////////// //// //// //// eth_crc.v //// //// //// //// This file is part of the Ether...
#include <bits/stdc++.h> using namespace std; int n; long long val[100000], dp[100000][2]; vector<int> g[100000]; void dfs(int v, int p) { long long c1 = 0, c2 = 0; for (int i = 0; i < (g[v].size()); i++) { int next = g[v][i]; if (next != p) { dfs(next, v); c1 = max(c1, dp[...
/** * 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...
/////////////////////////////////////////////////////////////////////// //// //// //// WISHBONE rev.B2 Wishbone Master model //// //// //// //// ...
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/verunilibs/data/unisims/IOBUF.v,v 1.9 2007/05/23 21:43:39 patrickp Exp $ /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2004 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////...
#include <bits/stdc++.h> using namespace std; const int N = 200100; int n, l, r, m, a[N], b[N], c, pos, mi, ma; pair<int, int> t[4 * N]; void build(int v, int tl, int tr) { if (tl == tr) { t[v].first = a[tl]; t[v].second = b[tl]; return; } int tm = (tl + tr) / 2; build(2 * v,...
`timescale 1ns / 1ps `define SIM_FULL module async_fifo_t; // ins reg wclk; reg wrst; reg [7:0] data_i; reg ack_i; reg rclk; reg rrst; reg pop_i; async_fifo uut( .wclk(wclk), .wrst(wrst), .data_i(data_i), .ack_i(ack_i), .rclk(rclk), .rrst(rrst), .pop_i(pop_i)); parameter T_WCLK = 10; pa...
#include <bits/stdc++.h> using namespace std; inline int ckmax(int &a, int b) { return a < b ? a = b, 1 : 0; } inline int ckmin(int &a, int b) { return a > b ? a = b, 1 : 0; } char s[500100], t[500100]; int n, m, wt, p[500100], sta[500100], pre[500100], nex[500100], top; int main() { scanf( %d%d%d , &n,...
#include <bits/stdc++.h> using namespace std; long long int modulo = 1000000007; const int limite = 1000001; long long int elev[limite]; int ocupado[limite]; int main() { ios_base::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; elev[0] = 1; for (int i = 1; i < limite; i++) elev...
// It looks like for the models to be correctly annotated with timings from // SDF in Icarus Verilog the timescale provided here must match the one in SDF. // VPR writes SDFs in picoseconds hence here it is set to picoseconds as well. `timescale 1ps/1ps // VPR routing interconnect module module fpga_interconnect(datai...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2010 by Wilson Snyder. module t; integer v = 19; initial begin if (v==1) begin end else if (v==2) begin end else if (v==3) begin end else if (v==4) beg...
#include <bits/stdc++.h> using namespace std; const int N = 300010; int dia, n; long long a[N], ans; map<long long, int> mp; int main() { cin >> dia >> n; ans = (long long)n * (n - 1LL) * (n - 2LL) / 6LL; for (int i = 1, s, f; i <= n; ++i) { cin >> s >> f; if (!s) f += dia; f %...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6 + 7; int n; long long dp[2][maxn]; int main() { cin >> n; int now = 1; dp[0][1] = 1; dp[0][2] = 1; long long ans = 0; ans += dp[0][n]; for (int i = 1; i <= 19; i++) { memset(dp[now], 0, sizeof(dp[now])); ...
/** * 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 / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 08/01/2016 04:10:04 PM // Design Name: // Module Name: Convert_Fixed_To_Float_V // Project Name: // Target Devices: // Tool Versions: // Description: // // Depende...
module env_io (/*AUTOARG*/ // Outputs DI, // Inputs clk, iorq_n, rd_n, wr_n, addr, DO ); input clk; input iorq_n; input rd_n; input wr_n; input [7:0] addr; input [7:0] DO; inout [7:0] DI; reg [7:0] io_data; reg [7:0] str_buf [0:255]; reg io_cs; integer buf_ptr, ...
#include <bits/stdc++.h> using namespace std; const int N1[] = {1, -1}, NINF = (int)0x80808080u, MAXN = 30000, MAXK = 200; long long int dp[MAXN][MAXK + 1][2][2], mdp[MAXN][MAXK + 1][2]; int arr[MAXN], cs[MAXN], n, k; inline long long int max(long long int a, long long int b) { return a > b ? a : b; } ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int calc(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = (res * a) % MOD; a = (a * a) % MOD; n /= 2; } return res; } int main() { ios_base::sync_with_stdio(0); long ...
#include <bits/stdc++.h> using namespace std; const int B = 27397, MOD = 1e9 + 7; const int B1 = 33941, MOD1 = 1e9 + 9; int t; inline void solve() { int r, n; scanf( %d%d , &n, &r); --r; int sum = 0; for (int i = 0; i < n - 1; ++i) { int x; scanf( %d , &x); --x; sum...
#include <bits/stdc++.h> using namespace std; long long niz[1000000]; long long kum[1000000]; int main() { ios_base::sync_with_stdio(false); cout.precision(10); cout << fixed; int n, s, f; cin >> n; for (int i = 1; i <= n; i++) { cin >> niz[i]; } cin >> s >> f; long lon...
#include <bits/stdc++.h> using namespace std; int tag[10]; int main() { string a, b; while (cin >> a >> b) { memset(tag, 0, sizeof(tag)); ; int len = a.size(); int len1 = b.size(); for (int i = 0; i < len1; i++) { int num = b[i] - 0 ; tag[num]++; } ...
#include <bits/stdc++.h> int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); int a[n]; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); } for (int i = 0; i < n; i++) { for (int j = 0; j < n - i - 1; j++) { if (a[j + 1] <...
////////////////////////////////////////////////////////////////////// //// //// //// Phy_sim.v //// //// //// //// This file is part of the E...
#include <bits/stdc++.h> using namespace std; const int N = 1010; int n, w, a[N]; int main() { cin >> n >> w; for (int i = 0; i < n; i++) { cin >> a[i]; } int lo = 0, hi = w, n_lo = 0, n_hi = w; for (int i = 0; i < n; i++) { n_lo += a[i]; n_hi += a[i]; if (n_lo > w ||...
/** * 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; long long pwr(long long a, long long b, long long mod) { if (b == 0) return 1; long long temp = pwr(a, b / 2, mod); temp = (temp * temp) % mod; if (b & 1) temp = (temp * a) % mod; return temp; } long long pwr(long lo...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a; cin >> b; cin >> c; int d = a + b - c; int e = b + c - a; int f = a + c - b; if (d < 0 || e < 0 || f < 0 || e % 2 || d % 2 || f % 2) { cout << Impossible ; return 0; } cout << d / 2...
Require Import List. Import ListNotations. Require Import Coq.Sets.Ensembles. From OakIFC Require Import Lattice Parameters GenericMap State ModelSemUtils. (* This file is the top-level model of the Oak runtime *) (* RecordUpdate is a conveninece feature that provides functional updates for * reco...
/** * 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> char map[55][55]; int main() { int n, ans = 2147483647; std::pair<int, int> s, t; std::queue<std::pair<int, int> > q; std::vector<std::pair<int, int> > vec1, vec2; scanf( %d %d %d %d %d , &n, &s.first, &s.second, &t.first, &t.second); for (int i = 1; i <= n; ++i) sca...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.4 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
#include <bits/stdc++.h> using namespace std; int main() { long long k4, k7, i, l; char s[100]; long long n; gets(s); l = strlen(s); k4 = 0; k7 = 0; for (i = 0; i < l; i++) { if (s[i] == 4 ) k4++; if (s[i] == 7 ) k7++; } if (k4 == 0 && k7 == 0) cout << -1;...
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, m, lim, p = 1, a[N], nex[N * 2], spot[N * 2], head[N], fa[N], f[N], g[N]; int maxcolor[N][2], c[N]; bool color[N], v[N]; void add(int x, int y) { nex[++p] = head[x], head[x] = p, spot[p] = y; nex[++p] = head[y], head[y] = p, ...
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, n, cnt = 0, flag = 0, k = 0; string str; cin >> n >> str; for (i = 0; i < n; i++) { if (str[i] == ( ) { cnt++; if (cnt == 2) j = i; } else cnt--; if ((cnt == -2) && (!k)) k = i; ...
//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 associate...
#include <bits/stdc++.h> using namespace std; long long t, xiaoyud, dayu, n, x, pos, ans1, mo = 1e9 + 7, ans2, ans; int main() { cin >> n >> x >> pos; long long l = 0, r = n; while (l < r) { long long mid = (l + r) / 2; if (mid <= pos) { l = mid + 1; if (mid != pos) xiaoyud...
#include <bits/stdc++.h> using namespace std; string a, b, c; long long n, x, y, z; pair<long long, long long> f[2000]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> a >> b >> c; for (auto i : a) { f[i].first++; x = max(x, f[i].first); } ...
#include <bits/stdc++.h> using namespace std; inline int Int() { int x; scanf( %d , &x); return x; } inline long long Long() { long long x; scanf( %lld , &x); return x; } void err(istream_iterator<string> it) { cout << endl; } template <typename T, typename... Args> void err(istr...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1505; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; int visx[MAX_N][MAX_N]; int visy[MAX_N][MAX_N]; char A[MAX_N][MAX_N]; int sx, sy; int n, m; queue<pair<int, int> > q; bool in(int x, int y) { return x >= 0 && x < n...