text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int N, F, M; cin >> N >> F >> M; int FR[200], MO[200]; vector<int> V; int mi = 10000; for (int i = 0; i < F; ++i) cin >> FR[i]; for (int j = 0; j < M; ++j) cin >> MO[j]; for (int i = 0; i < F; ++i) { int cnt = 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... |
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool umax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } int main() { int t; cin >> t; ... |
//////////////////////////////////////////////////////////////////////////////////
// SCFIFO_80x64_withCount for Cosmos OpenSSD
// Copyright (c) 2015 Hanyang University ENC Lab.
// Contributed by Kibin Park <>
// Yong Ho Song <>
//
// This file is part of Cosmos OpenSSD.
//
// Cosmos OpenSSD is free soft... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long cdiff, d, diff, rem, c, n, m, i, k = 0, j, flag = 0, x, minstep = 10000000000; cin >> n; long long b[n]; for (i... |
#include <bits/stdc++.h> using namespace std; long long n, root, val, rem; int main() { cin >> n; root = floor((sqrt(1.0 + 8.0 * n) - 1.0) / 2.0); val = root * (root + 1) / 2; if (n == val) --root; val = root * (root + 1) / 2; rem = n - val; cout << rem << endl; return 0; } |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 04/14/2016 06:25:09 AM
// Design Name:
// Module Name: Exp_operation_m
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
/... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; }... |
#include <iostream> #include <cstdio> #define mod 998244353 #define int long long using namespace std; int n,k,sa[200005],rk[200005]; int num; inline int Qpow(register int a,register int p){ if (p==0)return 1; register int t=Qpow(a,p/2); t=t*t%mod; if (p%2==1)t=t*a%mod; return t; } inli... |
/*
* 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; inline int in() { int x; scanf( %d , &x); return x; } template <typename T> inline istream& operator>>(istream& i, vector<T>& v) { for (int j = 0; j < ((int)(v).size()); ++j) i >> v[j]; return i; } template <typename T> string join(const ... |
module ArithAlu(
/* verilator lint_off UNUSED */
clk,
opMode,
srca,
srcb,
dst,
sri,
sro
);
input clk;
input[4:0] opMode;
input[31:0] srca;
input[31:0] srcb;
output[31:0] dst;
input[3:0] sri;
output[3:0] sro;
parameter[4:0] UOP_NONE = 5'h00;
parameter[4:0] UOP_ADD = 5'h01;
parameter[4:0] UOP_SUB =... |
// Released under GPL2.0
// (c) 2002 Tom Verbeure
module main;
integer myInt;
reg [39:0] myReg40;
reg [0:39] myReg40r;
reg [0:38] myReg39r;
reg [13:0] myReg14;
reg [7:0] myReg8;
reg [31:0] myReg32;
initial begin
$display("============================ myReg14 = -10");
myReg14 = -10;
$display(">|16374|"... |
#include <bits/stdc++.h> using namespace std; template <class T, class U> struct SegmentTree { struct Node { bool hasCarry = 0; int b = 0, e = 0; U carry = U(); T val = T(); Node() {} void join(const Node &l, const Node &r) { val = l.val + r.val; b = l.b; ... |
#include <bits/stdc++.h> using namespace std; map<long long int, long long int> mp; int main() { int n, c = 0, x = 0, a[200], i, j; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; c += a[i]; } if (n == 1) x = 1; if (n == 2 && a[0] == a[1]) x = 1; if (x == 1) cout << ... |
// ============================================================================
// Copyright (c) 2010
// ============================================================================
//
// Permission:
//
//
//
// Disclaimer:
//
// This VHDL/Verilog or C/C++ source code is intended as a design reference
... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2016/06/03 11:30:00
// Design Name:
// Module Name: lab3_tb
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revis... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0; bool flg = false; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) flg = true; for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48); return flg ? -x : x; } int n; stru... |
//
// $ ../nli handshake.n
// $ iverilog tb_handshake.v handshake.v
//
`timescale 1ns/1ns
module tb_handshake;
reg clk, rst;
wire [31:0] channel_out_data;
wire channel_out_en;
reg channel_out_ack;
reg [31:0] channel_in_data;
reg channel_in_en;
wire channel_in_ack;
... |
#include <bits/stdc++.h> using namespace std; const int N = 502; int n, m, l = -1, ok = 1, r; string s[N]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> s[i]; for (int j = 0; j < n; j++) { l = r = -1; for (int i = 0; i < s[j].length(); i++) { if (l == -1 && s[j... |
#include <bits/stdc++.h> using namespace std; void setup() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(15); } int dx[] = {1, -1, 0, 0, 0, 0}; int dy[] = {0, 0, 1, -1, 0, 0}; int dz[] = {0, 0, 0, 0, 1, -1}; int k, n, m; int ANS = 0; string x[10][10]; in... |
//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... |
//----------------------------------------------------------------------------
// Copyright (C) 2009 , Olivier Girard
//
// 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 must re... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, ans1 = 0, ans2 = 0; cin >> n; vector<int> c(n); for (int i = 0; i < n; i++) cin >> c[i]; cin >> a >> b; if (a > b) swap(a, b); a--; b--; for (int i = a; i < b; i++) { ans1 += c[i]; } for (int i ... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 20:32:04 03/31/2015
// Design Name: zlozony
// Module Name: C:/Users/omicronns/Workspaces/webpack-ise/sr/lab4/zlozony/src/tb_zlozony.v
// Project Name: zloz... |
/**
* 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 MOD = 1e9 + 7; const long long inf = 10000000; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } inline bool isLeapYear(long long year) { return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0); } inline void normal(l... |
#include <bits/stdc++.h> using namespace std; int xx[8] = {0, 0, 1, -1, 1, -1, 1, -1}; int yy[8] = {-1, 1, 0, 0, 1, -1, -1, 1}; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long int n; cin >> n; bool flag = true; vector<long long int> v(n); for (long ... |
`timescale 1ns / 1ps
module dff_async_rst_tb;
// Inputs
reg clk;
reg rst;
reg d;
// Outputs
wire q;
// Instantiate the Unit Under Test (UUT)
dff_async_rst uut (
.clk(clk),
.rst(rst),
.d(d),
.q(q)
);
task expect;
input exp_out;
if (q !== exp_out) begin
... |
#include <bits/stdc++.h> #include <climits> #define F first #define S second #define all(v) v.begin(),v.end() #define li long int #define lli long long int #define pb push_back #define loop(a,b,i) for(lli i=a ; i<b ; i++) #define rev_loop(a,b,i) for(lli i=a ; i>=b ; i--) #define MAX(a,b) (a>b)?a:b ... |
#include <bits/stdc++.h> int main() { int dem = 1, i, n, c; scanf( %d %d , &n, &c); int a[n]; for (i = 0; i < n; i++) { scanf( %d , &a[i]); } for (i = 1; i < n; i++) { if (a[i] - a[i - 1] <= c) { dem++; } if (a[i] - a[i - 1] > c) { dem = 1; } }... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 4e5 + 1; int a[MAXN], b[MAXN]; const int MOD = 1e9 + 7; int bit[MAXN]; void add(int pos, int val) { while (pos < MAXN) { (bit[pos] += val) %= MOD; pos += pos & -pos; } } int query(int pos) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000 + 10; const int mod = 1e9 + 7; int n, k, a[maxn], f[maxn], g[maxn]; int fast_pow(int a, int b) { int ret = 1; for (; b; b >>= 1, a = 1ll * a * a % mod) if (b & 1) ret = 1ll * ret * a % mod; return ret; } int main() { ... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(0); int cases, caseno = 0, n, i, j, k, cnt, sum; cin >> n >> j >> k; for (i = 1; i <= 10000; i++) { if (n == 2) { cout << Final! ; return 0; } if ((j + 1) / 2 == (k + 1) / 2) ... |
////////////////////////////////////////////////////////////////////////////////////
//
// pGB, yet another FPGA fully functional and super fun GB classic clone!
// Copyright (C) 2015-2016 Diego Valverde ()
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Gene... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long N = 1e5 + 1; const long long INF = -1e17; long long n; long long ans, cnt, mx = 0; string s; int main() { ios_base::sync_with_stdio(false); cin >> n; getline(cin, s); getline(cin, s); for (lo... |
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2014 Francis Bruno, All Rights Reserved
//
// 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 ... |
//////////////////////////////////////////////////////////////////////
//// ////
//// OR1200's register file read operands mux ////
//// ////
//// This file is part of the OpenR... |
#include <bits/stdc++.h> using namespace std; signed main() { long long int n, i, j, k, t; scanf( %lld , &n); long long int prev = 0, ans = 0, count = 0, diff = 0, sum = 0, powe = 0; long long int a[n]; for (i = 0; i < n; i++) scanf( %lld , &a[i]); sort(a, a + n); if (n == 1) { cou... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; int main() { int k, w; long long n; cin >> k >> n >> w; int l{}; for (int i = 1; i <= w; i++) { l = l + i; } int s = (l * k) - n; if (s > 0) cout << s; else cout << 0; return 0; } |
`timescale 1 ps / 1 ps
module mult_add_fix8bx4 (
input clock,
input resetn,
input ivalid,
input iready,
output ovalid,
output oready,
input wire [7:0] dataa_0, // dataa_0.dataa_0
input wire [7:0] datab_0, // datab_0.datab_0
input wire [7:0] dataa_1, // dataa_1.dataa_1
input ... |
#include <bits/stdc++.h> using namespace std; long long n, k; int32_t main() { cin >> n >> k; if ((n / k) & 1) cout << YES ; else cout << NO ; } |
#include <bits/stdc++.h> using namespace std; int main() { int tux; cin >> tux; int foo, bar, baz, quz, pur, oo; foo = bar = baz = 0; quz = 1; while (tux) { cin >> pur; foo += pur; bar++; if (foo * quz > bar * baz) { baz = foo; quz = bar; } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a; cin >> a; if (a % 2 == 0) { cout << NO ; return 0; } if ((a - 3) / 2 < 1) { cout << NO ; return 0; } cout << 1 << << (a - 3) / 2; } |
#include <bits/stdc++.h> using namespace std; int n, k, a, ans; set<pair<int, int> > s; int x, m; bool used[1000000]; int solve(int x) { return (x + 1) / (a + 1); } void go(int x) { set<pair<int, int> >::iterator it = s.upper_bound(make_pair(x, 1000000000)); --it; pair<int, int> cur = *it; ... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 13:56:01 10/14/2015
// Design Name: gray_couter
// Module Name: C:/Users/djnakka/Downloads/hw1/gray_counter/gray_counter_tb.v
// Project Name: gray_counter
// Target... |
module display_logic( input pxl_clk,
input [9:0] hcount,
input [9:0] vcount,
input [9:0] ball_y,
input [9:0] ball_x,
input [5:0] player_position,
input [3:0] block_num,
... |
/*
* 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... |
/**
* 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, a, b, c, d, s = 0, i; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> a >> b >> c >> d; s = s + (c - a + 1) * (d - b + 1); } cout << s; } |
/*------------------------------------------------------------------------------
* This code was generated by Spiral Multiplier Block Generator, www.spiral.net
* Copyright (c) 2006, Carnegie Mellon University
* All rights reserved.
* The code is distributed under a BSD style license
* (see http://www.opensource.or... |
`include "defines.v"
`include "HRnode.v"
`timescale 1ns/1ps
/*module HRnode
#(parameter addr = 4'b0010)
(
input `control_w port0_i,
input `control_w port1_i,
input `control_w port0_local_i,
input `control_w port1_local_i,
output portl0_ack,
out... |
#include <bits/stdc++.h> using namespace std; const double Pi = acos((double)-1); const double Eps = 1E-6; int read() { int $x; scanf( %d , &$x); return $x; } long long sqr(long long $x) { return $x * $x; } int x[100000], N, A, B; int main() { A = read(), B = read(); N = A + B + 1; ... |
#include <bits/stdc++.h> using namespace std; bool cur1; int n, m, K; int L[100005 * 120], R[100005 * 120], res[100005 * 120], tt, rt[100005 * 3]; int update(int p, int l, int r, int x, int v) { int c = ++tt; L[c] = L[p], R[c] = R[p]; if (l == r) { res[c] = min((p ? res[p] : 0x3f3f3f3f), v);... |
/////////////////////////////////////////////////////////////////////
//// ////
//// WISHBONE DMA Priority Encoder Sub-Module ////
//// ////
//// ... |
/**
* 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 const oo = 1e9, bound = 1e6, mod = oo + 7; long long const OO = 1e18; int n, m, k, aa[20]; int cc[20][20]; long long dp[18][1 << 18]; long long rec(int idx, int msk) { long long &ret = dp[idx][msk]; if (ret != -1) return ret; int cop = msk, e =... |
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2014.2 (win64) Build 932637 Wed Jun 11 13:33:10 MDT 2014
// Date : Mon Nov 03 20:58:05 2014
// Host : ECE-411-6 running 64-bit Service Pack... |
#include <bits/stdc++.h> using namespace std; int v[100]; bool cmp(int a, int b) { return a > b; } int highest(int n) { int i = 1, fact = 0; while (2 * i <= n) { i *= 2; fact++; } return fact; } void permute(int left, int right, int pos, int last) { if (!pos || (!last && pos ... |
//==================================================================================================
// Filename : uart_min.v
// Created On : 2015-01-10 15:58:09
// Last Modified : 2015-05-24 21:21:39
// Revision : 1.0
// Author : Angel Terrones
// Company : Universidad Simón Bolívar
// ... |
`define PERIOD 10
module main;
reg CLK;
integer counter;
initial begin // reset and clock generator
counter = 0;
CLK = 0;
#2; // wait 2, and then...
repeat(10) // generate 5 clock cycles
#(`PERIOD/2) CLK = !CLK;
$display("time %0t; the counter is %0d", $time, counter);
... |
// Copyright (c) 2012, 2013 Rich Porter - see LICENSE for further details
`include "example.h"
module sim_ctrl (
output reg sim_ctrl_clk_op `EXM_VLTOR_PUBLIC_RW,
output sim_ctrl_rst_op `EXM_VLTOR_PUBLIC_RW
); // sim_ctrl
`ifdef EXM_USE_DPI
import "DPI-C" context task sim_ctrl_scope_t ();
`ifdef verilator
... |
/*
* 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... |
module priority_encoder_40to6 (
binary_out,
valid,
encoder_in,
enable
);
output[5:0] binary_out;
output valid;
input[39:0] encoder_in;
input enable;
assign valid = (|encoder_in) & enable;
assign binary_out = (!enable) ? 6'd0 : (
(encoder_in[0]) ? 6'd0 :
(encoder_in[1]) ? 6'd1 :
(encode... |
#include <bits/stdc++.h> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { template <class c... |
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; const long long INF = LLONG_MAX / 2; const long long N = 2e5 + 1; struct event { long long sa; long long ea; long long sb; long long eb; }; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.... |
#include <bits/stdc++.h> using namespace std; long long mp[2010][2010]; long long sum1[2010][2010], sum2[2010][2010]; int n; int check(int x, int y, int xx, int yy) { int remy = abs(yy - y); int remx = abs(xx - x); if (remy == remx) return 0; return 1; } long long getsum(int i, int j) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 10; long long gi() { long long x = 0, o = 1; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) o = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getc... |
#include <bits/stdc++.h> using namespace std; const int inf = ~0ull / 2; const int maxn = 100100; int seen[maxn]; int ind[maxn]; int par[maxn][22]; int bd[maxn]; int h[maxn]; vector<int> adj[maxn]; vector<int> adlist[maxn]; vector<int> tree[maxn]; vector<pair<int, int> > edges; void dfs1(int r... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; constexpr int MAXN = 100005; int n; string type[MAXN], word[MAXN]; bitset<30> to_bs(const string& s) { bitset<30> res; for (char c : s) { res[c - a ] = true; } r... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 10; const int INF = 1e9 + 9; const int B = 1e9 + 7; long long p[N], s[N]; int fp(int first) { return first == p[first] ? first : p[first] = fp(p[first]); } void u(int a, int b, int d) { s[fp(a)] += 4 * d; if (fp(a) == fp(b)) r... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, o; string s; cin >> n >> s; o = s[n - 1] - 0 ; for (int i = 0; i < n - 1; i++) o += (s[i] == 0 ? 0 : s[i] - 47); cout << o << endl; } return 0; } |
module mrfm_compensator (input clock, input reset, input strobe_in,
input serial_strobe, input [6:0] serial_addr, input [31:0] serial_data,
input [15:0] i_in, input [15:0] q_in, output reg [15:0] i_out, output reg [15:0] q_out);
wire [15:0] a11,a12,a21,a22;
reg [15:0] i_in_reg, q_in_r... |
#include <algorithm> #include <array> #include <cassert> #include <chrono> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> using namespace ... |
//==================================================================================================
// Filename : musb_branch_unit.v
// Created On : 2014-09-27 20:14:58
// Last Modified : 2015-05-24 21:00:28
// Revision : 1.0
// Author : Angel Terrones
// Company : Universidad Simón Bol... |
#include <bits/stdc++.h> using namespace std; const int mara = (int)(1e6) + 5; vector<long long> a(mara), prime(mara), v(mara), luck; map<long long, bool> flag; long long bigmod(long long a, long long b, long long m) { long long res = 1; while (b) { if (b & 1) { res = (res * a) % m; ... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: dffsle_ns.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
... |
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
//
// Revision Control Information
//
// $RCSfile: altera_tse_pcs.v,v $
// $Source: /ipbu/cvs/sio/projects/TriSpeedEthernet/src/RTL/Top_level_modules/altera_tse... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f;... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; set<int> st; int x; int sz = 0; for (int i = 0; i < n; i++) { cin >> x; if (sz > 3) continue; if (st.find(x) == st.end()) { sz++; st.insert(x); } } if (sz > 3) co... |
#include <bits/stdc++.h> using namespace std; const int N = 410000; char ch[N]; int a[N]; int n, t; int main() { scanf( %d%d , &n, &t); scanf( %s , ch + 1); if (t == 0) { printf( %s , ch + 1); return 0; } int s = 0; for (int i = 1; i <= n; i++) { if (ch[i] == . ) ... |
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; int m, n; pii a[100001]; vector<int> adj[100001]; bool is_chosen[100001]; bool is_visited[100001]; int cnt = 0; template <typename T> inline T read() { T x = 0; T multiplier = 1; char ch = getchar(); while (ch ... |
// megafunction wizard: %RAM: 1-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: cyclone2_dmem.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// ==========================... |
// -*- verilog -*-
//
// USRP - Universal Software Radio Peripheral
//
// Copyright (C) 2003, 2007 Matt Ettus
//
// 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 L... |
#include <bits/stdc++.h> using namespace std; int main() { int n; double x, r1 = 0, p1 = 0, p2 = 999999999999, a, b; cin >> n; while (n--) { cin >> x; r1 = max(r1, x); } cin >> n; while (n--) { cin >> x; p1 = max(p1, x); } cin >> n; while (n--) { ... |
/******************************************************************************
* License Agreement *
* *
* Copyright (c) 1991-2013 Altera Corporation, San Jose, California, USA. *
... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, ans[4010]; scanf( %d %d %d %d , &n, &a, &b, &c); memset(ans, -1, sizeof(ans)); ans[0] = 0; for (int i = 0; i <= n; i++) { if (i >= a && ans[i - a] != -1) ans[i] = ans[i - a] + 1; if (i >= b && ans[i - b] != -1... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 22:33:51 11/06/2015
// Design Name: Booth_Multiplier_II
// Module Name: /home/sidharth/Documents/Xilinx Projects/NEW2/Booth_Tester_2.v
// Project Name: NEW2
// Targe... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y) { if (y == 0) return 1; long long int d = power(x, y / 2) % 1000000007; if (y % 2 == 0) return (d * d) % 1000000007; else return (((x * d) % 1000000007) * d) % 1000000007; } long long ... |
#include <bits/stdc++.h> inline int in() { int x = 0; char c = getchar(); bool f = false; while (c < 0 || c > 9 ) f |= c == - , c = getchar(); while (c >= 0 && c <= 9 ) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); return f ? -x : x; } const int N = 105; int t[N], f[N *... |
`timescale 1ns/1ns
module usb_tx_data
(input c,
input [7:0] d,
input dv,
output [7:0] sie_d,
output sie_dv);
// no need for FIFO: just delay it one clock (after SYNC) and compute CRC16
// on the fly
localparam ST_IDLE = 4'd0;
localparam ST_SYNC = 4'd1;
localparam ST_DATA = 4'd2;
localparam ST_CRC_HI = 4'd3;... |
`timescale 1ns/10ps
/*
功能:读写请求控制,写优先级高于读
输入:nrst-0复位
clk-时钟
wr_req-写请求
rd_req-读请求
输出:wr_sta-写状态,1可写
rd_sta-读状态,1可读
修改:eleqian 2016-01-22
*/
module rw_ctrl(nrst, clk, wr_req, rd_req, wr_sta, rd_sta);
input nrst;
input clk;
input wr_req;
input rd_req;
output wr_sta; // 处于写状态
... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000007; const long long MOD = 1000000007; void solve_test() { int n; cin >> n; vector<int> arr(n); vector<int> ct(101); for (int i = 0; i < n; i++) { cin >> arr[i]; ct[arr[i]]++; } int max_val = -1; int... |
//-----------------------------------------------------
// Design Name : uart
// File Name : uart.v
// Function : Simple UART
// Coder : Deepak Kumar Tala
//-----------------------------------------------------
module uart (
reset ,
txclk ,
ld_tx_data ,
tx_data ,
tx_enable ... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, x[N], y[N], xs[N], ys[N], cnt[2][2]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d%d , &x[i], &y[i]); xs[i] = x[i], ys[i] = y[i]; } sort(xs + 1, xs + n + 1); sort(ys + 1, ys + n + ... |
/**
* 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() { string s; cin >> s; int n = s.size(); queue<int> pos; int arr[n]; arr[0] = 0; int lastb = -1; for (int i = 0; i < n; i++) { if (s[i] == b ) { if (i + 3 < n) { if (s.substr(i, 4) == bear ) { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.