text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { long long int res = 1; while (b) { if (b % 2 == 1) res = (res * a) % 1000000007; a = (a * a) % 1000000007; b /= 2; } return res; } bool comp(long long int a, long long int b) {... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000007; const int N = 2020; struct trie { trie *c[26]; int cnt; } * root, *nil; string s1, s2, s3; int n, l, r, f[N][N], ans; trie *new_node() { trie *node = new (trie); for (int i = 0; i < 26; i++) node->c[i] = nil; 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... |
module convolution_core (
input clk,
input reset,
input [31:0] value0,
input [31:0] value1,
input [31:0] value2,
input [31:0] value3,
input [31:0] value4,
input [31:0] value5,
input [31:0] value6,
input [31:0] value7,
input [31:0] value8,
input caculating_start,
output caculating_done,
input res_done,
output [31:0] ret... |
module BarrelShifterTestBench;
parameter sim_time = 750*2; // Num of Cycles * 2
reg [31:0] Rs,Rm,IR;
reg SR29_IN;
wire SR29_OUT;
wire [31:0] Out;
//BarrelShifter(input [31] Rs,Rm,IR,input SR29_IN,output SR29_OUT,output [31:0] Out);
BarrelShifter bs(Rs,Rm,IR,SR29_IN,SR29_OUT,Out);
initial fork
Rs=0;Rm=0;IR=0;SR29_I... |
// 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 : Mon May 26 17:17:23 2014
// Host : macbook running 64-bit Arch Linux
// ... |
#include <bits/stdc++.h> int c[100]; int main() { int n, s, max = 0, i, j; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &s); c[s] += 1; if (s > max) max = s; } for (i = 0; i <= max; i++) for (j = 0; j < c[i]; j++) printf( %d , i); return 0; } |
#include <bits/stdc++.h> using namespace std; const int oo = (int)1e9; const double PI = 2 * acos(0.0); const double eps = 1e-9; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int foo = max(3 * a / 10, a - a / 250 * c); int bar = max(3 * b / 10, b - b / 250 * d); if (foo == bar) ... |
// Full Adder rtl
module full_adder (a0, b0, c0, a1, b1, c_out, s_out, s2, s3);
// Inputs_top
input a0;
input b0;
input c0;
// End of inputs_top
// Outputs_top
output s1;
output c_out;
output s_out;
// End of outputs_top
// Wires
wire c1;
wire c2;
wire s1;
wire d1;
wire c3;
// Some ... |
#include <bits/stdc++.h> using namespace std; int main() { char c; int n, b = 0, a = 0; cin >> n; while (n > 0) { cin >> c; if (c == A ) a++; else b++; n--; } if (a > b) cout << Anton ; else if (a < b) cout << Danik ; else ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int ans[6]; cout << ? 1 2 << n ; cout.flush(); double a; cin >> a; cout << ? 2 3 << n ; cout.flush(); double b; cin >> b; map<double, bool... |
#include <bits/stdc++.h> using namespace std; string s; int main() { long long n, x, y, br = 0, k = 0; cin >> n >> x >> y; cin >> s; for (long i = 0; i < n; i++) { if (s[i] == 0 ) { if (i == 0) { br++; } else if (s[i - 1] != 0 ) { br++; } }... |
#include <bits/stdc++.h> using namespace std; char str[100010]; int f[100010][26 + 2], pre[100010][26], suf[100010][26], g[100010], n; int ans[26 + 2]; int dfs(int l, int r, int c, int fl) { if (l > r) return 0; if (ans[c] != -1) return ans[c]; int u = 0; for (int i = 0; i < 26; i++) { i... |
// ----------------------------
// This module contains the evenzeroes design
// that will output a 1 when the design receives an
// even number of 0 input bits. Otherwise, a 0 is
// outputted from the design.
//
// Note:
// - Syntax works and compiles with Verilog2LPN compiler
// - async. design follows dual rail enco... |
#include <bits/stdc++.h> using namespace std; struct LCT { int ch[555555][2], f[555555], tag[555555], key[555555], sum[555555], st[555555], ls[555555], rs[555555]; LCT() { for (int i = 1; i <= 550000; i++) { sum[i] = ch[i][0] = ch[i][1] = f[i] = tag[i] = key[i] = 0; } } b... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
module peripheral_pwm (
input clk,
input rst,
input [15:0] d_in,
input cs,
input [3:0]addr, // 4 LSB from j1_io_addr
input rd,
input wr,
output [2:0] pwm ,
output reg [2:0] d_out
);
//------------------------------------ regs and wires-------------------------------
reg [5:0] s; //selector mux_4 and ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 405; double f[maxn], g[maxn], ans; int n, m, dis[maxn][maxn], q[maxn]; int main() { scanf( %d%d , &n, &m); memset(dis, 127 / 3, sizeof(dis)); for (int i = 1; i <= n; i++) { dis[i][i] = 0; } for (int i = 1; i <= m; i++) { ... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( O3 ) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long n, x; cin >> n ... |
//-----------------------------------------------------------------------------
//
// (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... |
#include <bits/stdc++.h> using namespace std; const int MAXN = (int)3e3 + 5; const int INF = (int)1e9; const string T = aeiou ; int dp[MAXN], par[MAXN]; bool space[MAXN]; bool vowel[256]; string s; int n; bool bad(char a, char b, char c) { if (a == b && b == c) { return 0; } if (!... |
// date:2016/3/15
//engineer: zhaishaomin
// module function: output inst_word according to coming pc ,
// if missed , it will stall the pipeline and gen a msg to find the requested cache block
// including the origal inst_word
module inst_cache (//input
clk,
rst,
... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200009; const int MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0); int n, k, tot; cin >> n >> k; tot = n; vector<int> sta, vis(n + 2); vis[n + 1] = 1; int cur = 1; vector<int> ans... |
module tb_fpga();
// Test ports
reg A, B;
wire out;
// Configuration ports
reg [899:0] brbselect;
reg [29:0] leftioselect;
/*reg [29:0] rightioselect;
reg [29:0] topioselect;*/
reg [29:0] bottomioselect;
wire [4:0] left, right, top, bottom;
wire [2:0] ibl1w, ibr1w;
wire [14:0] ibbw, r_1;
// assign ibbw[... |
#include <bits/stdc++.h> using ll = long long; using namespace std; int n, m; int const N = 3e5 + 2; int const M = (1 << 21); struct Triple { int fi; int se; int th; Triple(int f, int s, int t) : fi(f), se(s), th(t) {} }; struct Compare { bool operator()(const Triple& f, const Triple... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: TEC
// Engineer: Jorge Carvajal Araya - Kenneth Morales Madriz
//
// Create Date: 09:22:59 08/13/2013
// Design Name:
// Module Name: PruebaSeleccion
// Project Name:
// Target Devices:
//... |
#include <bits/stdc++.h> using namespace std; const int N = 200100; int t, n; int MOD; vector<pair<long long int, long long int> > v[N]; long long int kol[N]; long long int gotov[N], sad, a, b; long long int c; long long int sol; vector<long long int> p; long long int FI; long long int inv[N], i... |
//======================================================================
//
// cmac.v
// ------
// Top level wrapper for the CMAC core.
//
//
// Author: Joachim Strombergson
// Copyright (c) 2016, Secworks Sweden AB
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or
// without modi... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; pair<long long, long long> a[n]; for (long long i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a, a + n); queue<long long> q; set<long long> s; bool turn = true;... |
/**
* 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, m; vector<int> a1, a2; vector<int> b1, b2; int subsolve(vector<int>& box, vector<int>& spec) { int N = (int) box.size(); int M = (int) spec.size(); vector<int> good (M+5, 0); int cumulate = 0; for (int i=M-1; i>=0; ... |
//deps: register_unit.v
`timescale 1ns/1ps
module register_unit_tb;
/*AUTOWIRE*/
// Beginning of automatic wires (for undeclared instantiated-module outputs)
wire [15:0] rD_data_out; // From ru of register_unit.v
wire [15:0] rS_data_out; // From ru of register_unit.v
// End... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const int mod = 1000000007; const int inf = 2012345678; const long long infl = 9012345678901234567; const double pi = 3.1415926535897932384626433832795; const int N = 20; const int M = 100010; char buf[M]; int a[M]; int ... |
#include <bits/stdc++.h> #define mset(arr, val) memset(arr, val, sizeof(arr)) #define all(v) v.begin(), v.end() #define F first #define S second #define endl n using namespace std; // const double PI = acos(-1.0); // const double E = exp(1.0); // const double EPS = 1e-9; const int MOD = (int)1e9 ... |
`timescale 1 ns / 1 ps
module sfa_5to1_mux
(
output reg s1_tready ,
input wire s1_tvalid ,
input wire [31 : 0] s1_tdata ,
output reg s2_tready ,
input wire s2_tvalid ,
input wire [31 : 0] s2_tdata ,
output reg s3_t... |
#include <bits/stdc++.h> int main() { const int maxN = 3002; bool tests[maxN] = {0}; int n(0); scanf( %d , &n); for (int k = 0; k < n; k++) { int temp; scanf( %d , &temp); tests[temp] = 1; } for (int index = 1; index < maxN; index++) { if (!tests[index]) { p... |
#include <bits/stdc++.h> using namespace std; priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, less<pair<long long, long long>>> q; priority_queue<long long, vector<long long>, greater<long long>> p; long long n, k, t, b, temp, res; int main() { cin >> ... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n, m; cin >> n; vector<string> a(n); for (int i = 0; i < n; i++) cin >> a[i]; cin >> m; vector<v... |
/*
* 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... |
/*
* File: demo_top.v
* Project: pippo
* Designer: kiss@pwrsemi
* Mainteiner: kiss@pwrsemi
* Checker:
* Assigner:
* Description:
* top module for FPGA demo on XUP board
*
*/
// synopsys translate_off
`include "timescale.v"
// synopsys translate_on
`include "def_pippo.v"
mo... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t; cin >> t; while (t--) { long long n, x; cin >> n; string s = ; if (n % 2 == 0) { s += 1 ; } else s += 7 ; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; int n, nn, m; int a[N], b[N], c[N]; int f[N]; inline void add(int i, int v) { for (; i <= n; i += i & -i) f[i] += v; } inline int find(int v) { int i = 0; for (int k = 20; k >= 0; k--) { if (i + (1 << k) <= n && f[i +... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: dcfifo_mixed_widths
// ============================================================
// File Name: rxfifo_8kx9_to_36.v
// Megafunction Name(s):
// dcfifo_mixed_widths
//
// Simulation Library Files(s):
// altera_mf
//... |
//----------------------------------------------------------------------------
// 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 where[26][26]; int n, dp[(1 << 23) + 5], d[35]; bool fdp[(1 << 23) + 5]; int rec(int mask) { if (fdp[mask]) return dp[mask]; int next = 0; for (int i = n - 1; i >= 0; --i) { if (mask & (1 << i)) { next = i; break; } ... |
#include <bits/stdc++.h> using namespace std; int n, m; struct edge { int from; int to; int next; long long flow; } E[10005 << 1]; int sz = 1; int head[10005]; void add_edge(int u, int v, long long w) { sz++; E[sz].from = u; E[sz].to = v; E[sz].next = head[u]; E[sz].flo... |
#include <bits/stdc++.h> using namespace std; int n, m, qu; int a[100011]; int st[100011], en[100011]; int pos[100011]; int rt[100011], nxt[100011]; int step[100011]; bool vis[100011]; vector<int> v[100011], vv; queue<int> q; void bunhae_interval() { int r = n % m, mm = n / m; st[0] = 1; ... |
// DATA derived from module add1 !!!!!!!!!!!!!!!!
// code used to capture inputs change to ref_dut
// converting them to vcd format fed to turbosim in_fifo
reg null_bit;
always @(ref_dut.a[0])
begin
dt = $time - start_time;
null_bit = push_input({encode_bit_value(ref_dut.a[0]), 14'd0, dt});
end
always @(... |
// (c) Copyright 1995-2017 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyright and other intellectual property
// laws.
//
// DISCLAIMER
// This disclaimer is not a license and does not grant ... |
/**
* 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() { double a, b, c; while (cin >> a >> b >> c) { double m = a * c; cout << ceil(m / b) - c << endl; } } |
#include <bits/stdc++.h> using namespace std; const int MX = 300000; const long long mod = 1e9 + 7; const long long inf = 1e18; long long a[MX + 5]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long tc, cs = 1, i, j, k, x, y, z, n, m; cin >> n; for (i = 1;... |
#include <bits/stdc++.h> using namespace std; using Long = long long; vector<vector<int>> G(100010); int D[100010]; int dist[100010]; int P[100010]; int ep1 = -1, ep1lvl = -1, ep2 = -1, ep2lvl = -1; void dfs(int u, int p, int lvl) { if (lvl > ep1lvl) { ep1lvl = lvl; ep1 = u; } fo... |
/*
* SBN machine with hardwired FSM control
* (c) Volker Strumpen
*
* modified to halt execution
* if result address is C all fff's
* i.e. ff for fwidth=8
* by Martin Polak
*/
module sbn (clk, state, PC, a, b);
parameter fwidth = 8; // field width of sbn operand
parameter dwidth = 32;
input ... |
#include <bits/stdc++.h> using namespace std; long long a[212345], sumi, wow, i; int main() { std::ios::sync_with_stdio(false); int n; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; sumi += a[i]; } wow = 0; for (i = 0; i < n; i++) { wow += a[i]; if (2 * wow >=... |
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995/2009 Xilinx, Inc.
//
// 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
//
//... |
// Copyright (C) 2020-2021 The SymbiFlow Authors.
//
// Use of this source code is governed by a ISC-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/ISC
//
// SPDX-License-Identifier:ISC
// ============================================================================
// ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 10:29:57 03/24/2014
// Design Name:
// Module Name: gpr
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Rev... |
/**
* 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) 1999 Steven Wilson ()
//
// This source code is free software; you can redistribute it
// and/or modify it in source code form under the terms of the GNU
// General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option)
// ... |
#include <bits/stdc++.h> using namespace std; struct Poi { int x, y; Poi() { x = y = 0; } Poi(int _x, int _y) : x(_x), y(_y) {} } q[200000], po[500]; int n, vX, vY, sX, sY, cX, cY, minX, minY, maxX, maxY, up, dw, lf, rt; int pre[500][500], li[200000], len, qi[200000]; bool tree[500][500]; int ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int n, m; int popCount(int x) { int count = 0; while (x) { ++count; x &= x - 1; } return count; } inline bool Okay(int x) { return (((1 << m) - 1) & x) == ((1 << m) - 1); } int main() { ios::syn... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 00:21:12 05/09/2015
// Design Name:
// Module Name: interrupt
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; int gi() { int x = 0, o = 1; char ch = getchar(); while (!isdigit(ch) && ch != - ) ch = getchar(); if (ch == - ) o = -1, ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return x * o; } in... |
/*
* 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; long long int M = 1e9 + 7; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; vector<long long int> v; for (long long int i = 1; i <= 100000; ++i) { long long int x = (i * (3 *... |
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } const int INF = 1 << 29; inline int two(int n) { return 1 << n; } inline int test(int n, int b) { return n & two(b); } inline void set_bit(int& n, int b) { n |= two(b); } inline void unset_bit(i... |
#include <bits/stdc++.h> using namespace std; int w, h; char g[100][100], d[100][100]; bool use[100][100]; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; bool is_valid(int y, int x) { return 0 <= y && y < h && 0 <= x && x < w; } bool check() { for (int i = 0; i < h; i++) { for (int j = 0;... |
#include <bits/stdc++.h> using namespace std; struct guy { int x; int y; int t; }; int r, n; vector<guy> arr; vector<int> dp; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> r >> n; arr = vector<guy>(n); dp = vector<int>(n, 0); for (int i = 0; i <... |
//Legal Notice: (C)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 associate... |
`include "../network_params.h"module window_selector(
input clock,
input reset,
input [`BUFFER_OUT_VECTOR_BITWIDTH:0] buffer_vector,
input [`X_COORD_BITWIDTH:0] x,
input [`Y_COORD_BITWIDTH:0] y,
output reg[`CAMERA_PIXEL_BITWIDTH:0] value_out
);
// wire declarations
wire [`CAMERA_PIXEL_BITWIDTH:0] buffer_wi... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int MOD2 = (int)1e8 + 7; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long a, long long b) { lo... |
/**
* 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... |
/*
Distributed under the MIT license.
Copyright (c) 2015 Dave McCoy ()
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, mo... |
#include <bits/stdc++.h> using namespace std; inline void prin(int n) { printf( %d n , n); } int main() { int n; cin >> n; long long cur = 3, mi = 7; for (int i = 1; i < 3 * n; i++) { cur *= 3; cur %= (int)1e9 + 7; } for (int i = 1; i < n; i++) { mi *= 7; mi %= (int... |
// (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... |
module mera400f(
input clk_ext,
// iobus
input rxd,
output txd,
// ram
output ram_ce, ram_oe, ram_we,
output [17:0] ram_a,
inout [15:0] ram_d,
// display
output [0:15] w,
output [10:0] rotary_bus,
output [0:9] indicators
);
parameter CLK_EXT_HZ;
// --------------------------------------------------------... |
#include <bits/stdc++.h> using namespace std; int n; int main() { scanf( %d , &n); if (n % 5 == 0) { cout << n / 5; } else cout << n / 5 + 1; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, val; int arr[3] = {0}, count = 0; cin >> n; for (int i = 0; i < n; ++i) { cin >> val; arr[val]++; } if (arr[2] <= arr[1]) { count += arr[2]; arr[1] -= arr[2]; count += (arr[1] / 3); } else { ... |
#include <bits/stdc++.h> using namespace std; long long a, b, c, ans; int main() { cin >> a >> b >> c; long long pom = min(a, b); a -= pom; b -= pom; ans = c + pom; ans <<= 1; if (a or b) ans++; cout << ans; } |
`include "assert.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_bound = ~0;
wire [2... |
/*
* Copyright 2013-2021 Robert Newgard
*
* This file is part of fcs.
*
* fcs 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.
... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 28.04.2016 02:45:18
// Design Name:
// Module Name: pll_lock_lookup
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200010; int n, m; int a[105][105]; int ans, row[105], col[105]; void caluRow() { for (int i = 1; i <= n; i++) { int mi = 501; for (int j = 1; j <= m; j++) mi = min(mi, a[i][j]); if (mi > 0) { ans += mi; row[... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; int fa[maxn][20], d[maxn], n, p, q, ans, b, c; int dist(int x, int y) { int res = d[x] + d[y]; if (d[x] < d[y]) swap(x, y); for (int j = 18; j >= 0; j--) if (d[fa[x][j]] >= d[y]) x = fa[x][j]; if (x == y) return res - 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; int main() { int n; cin >> n; cout << --n / 2 << endl; return 0; } |
#include <bits/stdc++.h> int n, m; char a[10000]; char b[10000]; int main() { scanf( %s %s , a, b); n = strlen(a); m = strlen(b); int minn = 10000000; for (int i = -m + 1; i < n; i++) { int count = 0; for (int j = 0; j < m; j++) { if (i + j < 0 || i + j >= n) { ... |
// MBT 11/9/2014
//
// Synchronous 1-port ram.
// Only one read or one write may be done per cycle.
//
`define bsg_mem_1rw_sync_macro(bits,words) \
if (els_p == words && width_p == bits) \
begin: macro \
saed90_``bits``x``words``_1P mem \
(.CE1 (clk_lo) ... |
#include <bits/stdc++.h> using namespace std; long long a, b, i, c, x, y, z, k, h; int main() { cin >> x >> y; for (a = 0; a <= 1000; a++) { for (b = 0; b <= 1000; b++) if (a * a + b == x && a + b * b == y) h++; } cout << h; } |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; char ch = getcha... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; int a[n + 2]; int pos[n + 2]; for (int i = 1; i <= n; i++) { cin >> a[i]; pos[a[i]] = i; } int swap = 0; for (int i = 1; i <=... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; char buf[100000]; vector<pair<int, string> > vp; int b[maxn], n, m; pair<int, string> me; int getL() { int tx = 0, ret = 1; if (m == n) { me.first -= b[0]; tx = 1; } for (int i = 0; i < (int)vp.size(); 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 law... |
//decoder module
module decoder(instruction, nsel, opcode, readnum, writenum, ALUop, op, shift, sximm5, sximm8);
//inputs and outputs
input[15:0] instruction;
input [1:0] nsel;
output [2:0] opcode, readnum, writenum;
output [1:0] ALUop, op, shift;
output [15:0] sximm5, sx... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; const int maxN = 80; long long f[maxN]; int d[maxN]; const int maxD = 1000; const int K = 13; int dp[maxD][maxD]; bool filled = false; pair<int, int> get(int order, long long x) { if (order == K && filled) ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 7; const int mxn = 3e5 + 9; inline long long in() { long long _; scanf( %lld , &_); return _; } int n, m, k; struct node { int len; int link; int firstpos; map<char, int> nxt; void ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.