text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; struct edge { int to, next; } e[200010]; int n, m, q, cnt, father[100010], fa[100010][30], a[100010], dis[100010], deep[100010], head[100010]; inline void add(int u, int v) { cnt++; e[cnt].to = v; e[cnt].next = head[u]; head[u] = cnt; }... |
//////////////////////////////////////////////////////////////////////
/// ////
/// ORPSoC testbench for Altera de1 board ////
/// ////
/// Franck Jullien, ... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; const int N = 201; int n, a[N], cum[N][N], k, freq[N]; vector<int> hs; int calc(int l, int r) { priority_queue<int> qu; int res = 0; for (int i = l; i <= r; ++i) { qu.push(-hs[a[i]]); res += hs[a[i]]; } int sz = hs.size(), op = k; ... |
#include <bits/stdc++.h> using namespace std; struct segtree { vector<long long> t; segtree(long long _n) { t.resize(4 * _n); } void update(long long id, long long l, long long r, long long pos, long long val) { if (l == r) { t[id] = val; return; } long ... |
module wb_stream_reader_tb;
localparam FIFO_AW = 5;
localparam MAX_BURST_LEN = 32;
localparam WB_AW = 32;
localparam WB_DW = 32;
localparam WSB = WB_DW/8; //Word size in bytes
localparam MEM_SIZE = 128*WSB; //Memory size in bytes
localparam MAX_BUF_SIZE = 32*WSB; //Buffer size in bytes
... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; int n; vector<int> A(100); bool f(int m) { int k1 = 0, k2 = 0; for (int i = 0; i < n; i++) { k1 += A[i]; k2 += m - A[i]; } if (k2 > k1) return true; else return false; } int main() { cin >> n; int MAX = -1; ... |
// megafunction wizard: %RAM: 1-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: arria2gx_dmem.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// ==========================... |
// file: sdram_clk_gen.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 no... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
// (C) 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... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 10000; const int MAXK = 20; int V[MAXK + 3][MAXN + 3], Ans[MAXK + 3][MAXN + 3]; int main() { V[0][1] = 0; for (int j = 2; j <= MAXN; j++) { V[0][j] = 1; } for (int i = 1; i <= MAXK; i++) { int k = 1; for (int j = ... |
#include<bits/stdc++.h> #define R register #define I inline #define ll long long #define ull unsigned long long #define LL __int128 #define db double using namespace std; #define pii pair<int,int> #define mp(x,y) make_pair(x,y) #define piii pair<pair<int,int>,int> #define mp3(x,y,z) make_pair(make... |
#include <bits/stdc++.h> using namespace std; int main() { vector<long long> v; long long t, p; char c; int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { p = 0ll; cin >> t >> c; p = ((p << 8) | t); cin >> t >> c; p = ((p << 8) | t); cin >> t >> c; ... |
//////////////////////////////////////////////////////////////////////
//// ////
//// eth_clockgen.v ////
//// ////
//// This file is part of the Ether... |
module etx_core(/*AUTOARG*/
// Outputs
tx_data_slow, tx_frame_slow, txrd_wait, txrr_wait, txwr_wait,
etx_cfg_access, etx_cfg_packet,
// Inputs
nreset, clk, tx_rd_wait, tx_wr_wait, txrd_access, txrd_packet,
txrd_full, txrr_access, txrr_packet, txrr_full, txwr_access,
txwr_packet, txwr_full, etx_cfg_... |
#include <bits/stdc++.h> const int mxn = 1 << 19, mod = 998244353; inline int qpow(int x, int n) { int ans = 1; for (; n; n >>= 1, x = 1LL * x * x % mod) if (n & 1) ans = 1LL * ans * x % mod; return ans; } int r[mxn], w[mxn]; void fft_init(int n) { for (int i = 1; i < n - 1; ++i) r[i] = ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; int h[100000], max[100001]; cin >> n; for (int i = 0; i < n; ++i) { cin >> h[i]; } max[n] = h[n - 1] - 1; for (int i = n - 1; i >= 0; --i) { if (h[i] > max[... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 20:29:19 07/23/2015
// Design Name: knns_seq
// Project Name: kNNS_TD
// Target Device:
// Tool versions:
// Description:
//
// Verilog Test Fixture created by IS... |
// See LICENSE.SiFive for license details.
//VCS coverage exclude_file
import "DPI-C" function int jtag_tick
(
output bit jtag_TCK,
output bit jtag_TMS,
output bit jtag_TDI,
output bit jtag_TRSTn,
output bit sysrstn,
input bit jtag_TDO
);
module SimJTAG #(
parameter TICK_DELAY = 50
... |
/**
* 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... |
/***************************************************************************************************
** fpga_nes/hw/src/cart/cart.v
*
* Copyright (c) 2012, Brian Bennett
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the foll... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 20; long long int dp[MAXN][MAXN]; long long int tav[MAXN]; long long int n; string s; long long int dtoc(char x) { return x - 0 ; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); tav[0] = 1; for ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 2000000000000000001, mod = 1000000007; long long toi(string s) { long long a; istringstream in(s); in >> a; return a; } int main() { string s; cin >> s; for (int i = 1; i < s.length(); i++) if (s[i] == s[i - ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T sqr(T a) { return a * a; }; template <typename T> void dprint(T begin, T end) { for (auto i = begin; i != end; i++) cerr << (*i) << ; cerr << n ; }; const int maxn = 500 + 5; int n, step[maxn * 2]; string a... |
module fetch(IR_load_mux,new_IR_multi,equ,pr2_IR ,pr3_IR ,pr4_IR, pr5_IR,fromPipe2_PCim, fromPipe2_970, fromPipe3RFOut, fromPipe3PCInc, fromPipe4_Aluout, fromPipe5Mem, PCWrite, PCOut, IROut, incPCOut, clk, reset);
output [15:0] PCOut, IROut, incPCOut;
input [15:0]new_IR_multi;
wire [15:0] next_IR;//read from instru... |
#include <bits/stdc++.h> using namespace std; const double pi(3.14159265358979); int a[100010], d[100010]; int main() { int x, i, j, n; scanf( %d , &n); scanf( %d , &x); for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 0; i < n; i++) d[i] = abs(a[i] - x); int ans = 0; ... |
#include <bits/stdc++.h> using namespace std; int n, a[200100], b[200100]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { int x; cin >> x; b[x] = i; } int mx = ... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2019 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc = 0;
reg [63:0] cr... |
/**
* 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 main;
parameter use_wid = 4;
reg [use_wid-1:0] d;
wire [use_wid-1:0] q;
reg clk;
B #(.wid(use_wid)) dut (.Q(q), .D(d), .C(clk));
initial begin
clk = 0;
d = 4'b0000;
#1 clk = 1;
#1 clk = 0;
if (q !== 4'b0000) begin
$display("FAILED -- d=%b, q=%b", d,... |
module rx_frontend
#(parameter BASE = 0,
parameter IQCOMP_EN = 1)
(input clk, input rst,
input set_stb, input [7:0] set_addr, input [31:0] set_data,
input [15:0] adc_a, input adc_ovf_a,
input [15:0] adc_b, input adc_ovf_b,
output [23:0] i_out, output [23:0] q_out,
input run,
output [... |
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016
// Date : Wed May 24 17:28:31 2017
// Host : GILAMONSTER running 64-bit major release (... |
//
// 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)
// ... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: ctu_bottom_rptr2.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 ... |
/**
* 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 law... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 13.07.2017 21:09:25
// Design Name:
// Module Name: t_scp
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revisio... |
`timescale 1 ps / 1 ps
module onetswitch_top(
inout [14:0] DDR_addr,
inout [2:0] DDR_ba,
inout DDR_cas_n,
inout DDR_ck_n,
inout DDR_ck_p,
inout DDR_cke,
inout DDR_cs_n,
inout [3:0] DDR_dm,
in... |
#include <bits/stdc++.h> using namespace std; int n, m, q, ans[600005]; bitset<505> a[505][505], b[505][505]; char mp[505][505]; struct ccf { int x1, y1, x2, y2, id; }; void solve(int l, int r, vector<ccf> qus) { if (!qus.size()) return; int mid = (l + r) >> 1; for (int i = mid; i >= l; i-... |
/*
******************************************************************************
* File Name : tb_ada_reg_file.v
* Project : NR1K processor
* Version : 0.1
* Date : Aug 17th, 2014
* Author : Angel Terrones <>
*
* Disclaimer : Copyright © 2014 Angel Terrones
* ... |
//****************************************************************************/
// Copyright (C) yyyy Ronan Barzic -
// Date : Fri Apr 22 09:40:43 2016
//
// 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... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = n * (n + 1) / 2; for (int i = n; i > 0; i--) { sum += (n - i) * (i - 1); } cout << sum; } |
#include <bits/stdc++.h> const int maxn = 301, maxk = 10, maxs = 1 << 9, INF = 0x3f3f3f3f; int n, a[maxn], c[maxn], tot, fact[maxk], f[maxs], ans = INF; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , a + i); for (int i = 1; i <= n; ++i) scanf( %d , c + i); for (int i = 1, j... |
/* Generated by Yosys 0.3.0+ (git sha1 3b52121) */
(* src = "../../verilog/byteregister.v:1" *)
module ByteRegister(Reset_n_i, Clk_i, D_i, Q_o, Enable_i);
(* src = "../../verilog/byteregister.v:14" *)
wire [7:0] \$0\Q_o[7:0] ;
(* intersynth_port = "Clk_i" *)
(* src = "../../verilog/byteregister.v:5" *)
input... |
//bug1061
//typedef logic [7:0] foo_t;
module ptype
(
/*AUTOINPUT*/
// Beginning of automatic inputs (from unused autoinst inputs)
input foo_t a, // To b0 of ptype_buf.v, ...
// End of automatics
/*AUTOOUTPUT*/
// Beginning of automatic outputs (from unused autoinst outputs)
ou... |
/*
* 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... |
//////////////////////////////////////////////////////////////////////
//// ////
//// eth_rxaddrcheck.v ////
//// ////
//// This file is part of the Ether... |
// synopsys translate_off
`include "rtl/verilog/or1200/timescale.v"
// synopsys translate_on
`include "rtl/verilog/or1200/or1200_defines.v"
/*
***********************************************************
davide 07/03/2017 - 14:00 :
looks like working as expected. just changed enable signal to softreset.
now the m... |
`timescale 1ns / 1ps
`define BCR_ADDR (23'b000_10_00_0_0_011_1_0_0_00_01_0_001)
// || | | ||| | | || | |||
// Address BCR -+' | | ||| | | || | |||
// Synchronous -------' | ||| | | || | |||
// Variable latency ---------' ||| | | || | |||
// ... |
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0); const int oo = 2e9; const int N = 205; const int AL = 26; vector<int> idx[AL]; vector<int> adj[N]; int clr[N]; bool dfs(int u, int c = 0); int main() { int n; scanf( %d , &(n)); string s(n, ); for (int i ... |
#include <bits/stdc++.h> using namespace std; uint64_t rnd_data = 0xDEADBEEFDULL; inline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; } inline int my_rand() { rnd_data = rnd_data * 0x5DEECE66DULL + 0xB; return (rnd_data >> 17) & 0x7FFFFFFF; } template <typename T> void my_... |
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)1e18 + 7; int n, m; map<char, int> ch_num; int main() { int n; cin >> n; vector<string> ee(n); for (int i = 0; i < n; i++) { cin >> ee[i]; } vector<int> can_zero(27, -1); vector<pair<int, int> > le... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; int n, t, h, s; char road[500001]; int H[500001], S[500001]; bool time(int k) { vector<pair<int, int> > step; step.push_back(make_pair(-1, -1)); for (int i = 0, j = 0; i < h; i++) { if (k) { k--; step.pu... |
`default_nettype none
module memory_pipe_arbiter(
input wire iCLOCK,
input wire inRESET,
//Data(Core -> Memory)
input wire iDATA_REQ,
output wire oDATA_LOCK,
input wire [1:0] iDATA_ORDER,
input wire [3:0] iDATA_MASK,
input wire iDATA_RW,
input wire [13:0] iDATA_ASID,
input wire [1:0] iDATA_MMUMOD,... |
#include <bits/stdc++.h> using namespace std; long long a[11111111]; long long b[11111111]; int len = 0; long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); } int counter(int x) { int res = 0; while (x) { res++; x /= 10; } return res; } void printK(in... |
#include <bits/stdc++.h> using namespace std; struct cube { int ind, val, h; }; int rcount[101]; int compare1(cube a, cube b) { return a.val < b.val; } int compare2(cube a, cube b) { return a.ind < b.ind; } int main() { int n; scanf( %d , &n); vector<cube> v; vector<int> one, two; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int vis[maxn], son[maxn], f[maxn], sum, root, ans[maxn]; vector<int> g[maxn]; void getroot(int x, int fa) { son[x] = 1; f[x] = 0; for (int i = 0; i < g[x].size(); i++) { int v = g[x][i]; if (v == fa || vis[v]) con... |
#include <bits/stdc++.h> using namespace std; int vis[200010]; int addnum, vel[400010], head[400010], ne[400010]; int fath[200010][21]; int fa[200010], dep[200010]; pair<int, int> s[200010]; int tot, n, m; vector<int> o, o1, o2; int id[11]; int d[200010], f[200010][2]; int num; int p[200010]; ... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 13:45:00 05/22/2016
// Design Name: RICPU
// Module Name: Y:/TEOCOA/EXPR9/TESTRICPU.v
// Project Name: EXPR9
// Target Device:
// Tool versions:
// D... |
#include <bits/stdc++.h> using namespace std; const int N = 100 * 1000 + 10; vector<int> u[N], v[N], v2[N]; vector<pair<int, int> > q[N]; int t, st[N], fi[N], di[N], g[N], par[N]; int root(int u) { return (par[u] == u) ? u : par[u] = root(par[u]); } void merge1(int x, int y) { int dx = root(x), dy = r... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; int m; cin >> n >> m; int l; int r; int arr[n]; int pos = 0; int neg = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] == -1) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int m = 1e9 + 7; int bin_pow(int x, int k) { if (k == 0) return 1; int g = bin_pow(x, k / 2); g = (1ll * g * g) % m; if (k % 2 > 0) g = (1ll * g * x) % m; return g; } signed main() { iostream::sync_with_st... |
/*
* 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 double PI = acos(-1.0); const int INF = 1000000000; const int MOD = 1073741824; const int M = INF; const double RRR = 180.0 / PI; vector<vector<pair<int, int> > > g; vector<int> used; void dfs(int v, int l, int r) { used[v] = 1; for (int i = ... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2011(c) Analog Devices, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// a... |
#include <bits/stdc++.h> using namespace std; int N, M; int timew, cnt; stack<int> si; int low[2000005], dep[2000005], siz[2000005], dfn[2000005], nex[2000005], las[2000005], Arrive[2000005], st[2000005], cnt1; bool isin[2000005]; void jt(int xx, int yy) { cnt++; nex[cnt] = las[xx]; las[... |
/*
* This file is part of the DSLogic-hdl project.
*
* Copyright (C) 2014 DreamSourceLab <>
*
* 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 2 of the License, or
... |
/**
* 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> int main() { long long n, m; scanf( %lld %lld , &n, &m); long long res = 1, p = 2; while (m != 0) { if (m % 2 != 0) res = res * p % 1000000007; p = p * p % 1000000007; m >>= 1; } res--; p = res; res = 1; while (n != 0) { if (n % 2 !=... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18 + 1; inline long long input(void) { char t; long long x = 0; int neg = 0; t = getchar(); while ((t < 48 || t > 57) && t != - ) t = getchar(); if (t == - ) { neg = 1; t = getchar(); } while (t >= ... |
#include <bits/stdc++.h> using namespace std; const long long Max = 2e5 + 9, inf = 1e18; long long A[Max], B[Max], d[Max]; int find_nxt(long long id, long long x) { if (A[id] - B[id] >= x) return B[id] += x, id; d[id] = find_nxt(d[id], x - A[id] + B[id]), B[id] = A[id]; return d[id]; } int main(... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> ve; const int MAX = 51; long long C[MAX][MAX]; void build() { for (int i = 0; i < MAX; ++i) for (int j = 0; j < MAX; ++j) C[i][j] = (j == 0) ? 1 : ((i == 0) ? 0 : C[i - 1][j - 1] + C[i - 1][j]); } double memo[MAX][MAX]... |
#include <bits/stdc++.h> using namespace std; int main() { long long T, n, i, l, r, mid, res; scanf( %lld , &T); while (T--) { scanf( %lld , &n); l = 2; r = n - 1; res = n - 1; while (l <= r) { mid = (l + r) >> 1; if (mid * (mid - 1) / 2 + (n - mid) <= 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 la... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9+7, M = (1e9+7), MAXN = 1 * 2e5; int A[MAXN], C[MAXN]; int64_t modpow(int64_t a, int64_t b) { int64_t res = 1; for(; b; b >>= 1) { if(b&1) res=res*a%M; a=a*a%M; } return res; } ... |
// UART transmitter.
module UART_TX(
input rst, clk, baud_edge, data_ready,
input [7:0] data,
output reg tx, data_accepted
);
localparam START = (1 << 0), DATA = (1 << 1), END = (1 << 2);
reg [7:0] data_reg;
reg [2:0] data_counter;
reg [3:0] state;
initial begin
tx <= 1;
... |
// Implementation of a 100% asynchronous "OR" function between
// request signals
// using arbitrer_r1_2ph
module or_r1_2ph (/*AUTOARG*/
// Outputs
a1, a2, r,
// Inputs
r1, r2, a, rstn
);
// Input ports
input r1;
output a1;
input r2;
output a2;
// output port
output r;
inpu... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); vector<int> v(n + 1); for (int i = 1; i <= n; ++i) cin >> v[i]; int x, y; scanf( %d %d , &x, &y); for (int i = 1; i <= n; ++i) { int a = 0, b = 0; for (int j = 1; j <= n; ++j) { if (j <... |
#include <bits/stdc++.h> using namespace std; int heliqi; int main() { long long N, M, K; cin >> N >> M >> K; long long ans = -1; if (N + M < K + 2) { cout << -1 << endl; return 0; } long long t = 2; while (t--) { if (K < N) ans = max((N / (K + 1)) * M, ans)... |
/*
Copyright (C) 2013 Adapteva, Inc.
Contributed by Andreas Olofsson <>
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 ve... |
/*
* 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... |
//Legal Notice: (C)2017 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; template <typename T> struct outputer; struct outputable {}; template <typename T> inline auto sqr(T x) -> decltype(x * x) { return x * x; } template <typename T1, typename T2> inline bool umx(T1& a, T2 b) { if (a < b) { a = b; return 1... |
/*
* 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; string s; int main() { cin >> s; int n = s.size(); bool flag = 1; for (int i = 1; i < n; i++) if (!(s[i] >= A && s[i] <= Z )) flag = 0; if (flag) { for (int i = 0; i < n; i++) if ( a <= s[i] && s[i] <= z ) cout <<... |
#include <bits/stdc++.h> using namespace std; int a[51]; long long c[51][51]; double dp[51][51][51]; bool state[51][51][51]; double cal(int stu, int room, int mval) { if (state[stu][room][mval]) return dp[stu][room][mval]; state[stu][room][mval] = true; double &ret = dp[stu][room][mval]; if ... |
#include <bits/stdc++.h> using namespace std; long long n, m; long long q_pow(long long a, long long b, long long c) { if (b == 0) return 1; long long ret = q_pow(a, b / 2, c); ret = (ret * ret) % c; if (b & 1) ret = (ret * a) % c; return ret; } int main() { scanf( %d%d , &n, &m); ... |
#include <bits/stdc++.h> void parse(int size, std::string& input, int& pos, int depth, int& max_depth, std::vector<std::vector<std::string> >& comments) { if (size <= pos) { return; } if (depth > max_depth) { max_depth = depth; comments.push_back(std::vector<std::string>());... |
#include <bits/stdc++.h> using namespace std; int main() { string a, s; int c(0); cin >> a >> s; sort(s.begin(), s.end()), reverse(s.begin(), s.end()); for (int i = 0; i < a.size(); i++) { if (a[i] < s[c]) a[i] = s[c++]; } cout << a << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, i, y, ans = 0, q; scanf( %d%d , &n, &x); y = int(sqrt(x)); if (n < y) y = n; for (i = 1; i <= y; i++) { if (x % i == 0) { q = x / i; if (q <= n) { if (i == q) ans++; else ... |
#include <bits/stdc++.h> using namespace std; long long rr[] = {0, 1, 1, 1, 0, -1, -1, -1}; long long cc[] = {1, 1, 0, -1, -1, -1, 0, 1}; const long long mod = 1e9 + 7; const long long N = 300050; long long m, fact[N]; void pre() { fact[0] = 1; for (long long i = 1; i < N; i++) { fact[i] = (... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 0, a[100001]; long long sum = 0, x = 0, ans = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i], sum += a[i]; sum = sum / n; for (int i = 0; i < n; i++) x += a[i] - sum, ans += abs(x); cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; namespace MincostMaxFlow { const int maxn(2e5 + 5); struct Edge { int to, next, w, f; }; int first[maxn], cnt, vis[maxn], dis[maxn], S, T, pe[maxn], pv[maxn], maxflow, mincost; Edge edge[maxn * 20]; queue<int> Q; inline void Init(int _S, int _T) ... |
//////////////////////////////////////////////////////////////////////
//// ////
//// uart_tfifo.v ////
//// ////
//// ... |
module opicorv32_rv32_wrap (
irq,
pcpi_ready,
pcpi_wait,
pcpi_rd,
pcpi_wr,
mem_rdata,
mem_ready,
resetn,
clk,
trap,
mem_valid,
mem_instr,
mem_addr,
mem_wdata,
mem_wstrb,
mem_la_read,
mem_la_write,
mem_la_addr,
mem_la_wdata,
mem_la_wstrb,
... |
#include <bits/stdc++.h> using namespace std; long long int n, I; vector<long long int> vec; vector<long long int> comp; long long int K; int main() { scanf( %lld %lld , &n, &I); for (int i = 1; i <= n; i++) { long long int a; scanf( %lld , &a); vec.push_back(a); } K = 1 <<... |
/**
* 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 uni... |
/*
* 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.