text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int father[18000010], nRow, nCol; bool col[3010][3010 * 2]; int movex[] = {1, 1, 1, 0, 0, -1, -1, -1}; int movey[] = {-1, 0, 1, 1, -1, -1, 0, 1}; int Find(int p, int *father) { if (father[p] != p) father[p] = Find(father[p], father); return father[p]; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long INF = 1e12; vector<long long> ans[200010]; signed main() { ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; vector<long long> a(n); for (long long i = 0; i < n; i++) cin >> a[... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 23:45:15 04/19/2015
// Design Name:
// Module Name: exponent_finder
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, sum; while (~scanf( %lld , &x)) { if (x < 0) x = -x; if (x == 2) printf( 3 n ); else if (x == 0) printf( 0 n ); else { for (long long i = 1; i <= x; i++) { sum = i * (i + 1) / 2;... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int n; cin >> n; int A[12]; int B[12]; for (int i = 0; i < 10; i++) A[i] = true; for (int i = 0; i < 10; i++) B[i] = false; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1010, M = 200200; int i, j, k, n, m, ch, now, q; int a[N][N], ans[M]; struct cc { int x, y; } A[M]; struct dd { int l, r, s, t, q; } Q[M]; void R(int &x) { x = 0; ch = getchar(); while (ch < 0 || 9 < ch) ch = getchar()... |
`timescale 1ns / 1ps
// @input
// clk_src: clock source
// switch_power: electric power
// switch_en: pause switch
// sum_count: time limit
// count_start_flag: start signal
// @output
// count_end_flag: end signal
// count: counting of timer
module timer
#(parameter WIDTH = 32, CLK_CH = 25, TIME_SCORE = 2)
( input ... |
#include <bits/stdc++.h> const int N = 50005; char s[N]; int main() { scanf( %s , s); int i, j, n = strlen(s); for (j = 1; j <= n / 2; j++) { int t = 0, cnt = 0; for (i = 0; i + j < n; i++) { s[t++] = s[i]; if (s[i] == s[i + j]) cnt++; else cnt =... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2011(c) Analog Devices, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// a... |
// -------------------------------------------------------------
//
// File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\velocityControlHdl\velocityControlHdl_Convert_Data_Type1_block1.v
// Created: 2014-08-25 21:11:09
//
// Generated by MATLAB 8.2 and HDL Coder 3.3
//
// -----------------------------------------... |
#include <bits/stdc++.h> using namespace std; long long q, x, y; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> q; while (q--) { cin >> x >> y; if (x - y > 1) cout << YES << n ; else cout << NO << n ; } return 0;... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; struct compare { bool operator()(const pair<int, int>& a, const pair<int, int>& b) { return true; } }; int main() { cin.tie(0); ios_base::sync_with_stdio(0); int t; cin >> t; while (t--) { int n, x, y; cin >> n >> x >> y... |
/**
* 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; typedef long long ll; ll a[200009],n,p; bool vis[200009][2]; pair <ll,ll> g[200009]; int main() { ios::sync_with_stdio(0); int t; cin>>t; while(t--) { cin>>n>>p; ll ans=0; for(int i=1;i<=n;i++) ... |
/*
* yosys -- Yosys Open SYnthesis Suite
*
* Copyright (C) 2012 Clifford Wolf <>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* T... |
`timescale 1ns / 1ps
/**
* ------------------------------------------------------------
* Copyright (c) All rights reserved
* SiLab, Institute of Physics, University of Bonn
* ------------------------------------------------------------
*/
module mmc3_eth_core(
input wire RESET_N,
// clocks from PLL c... |
//*****************************************************************************
// (c) Copyright 2009 - 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
/... |
#include <bits/stdc++.h> using namespace std; struct keycompare { bool operator()(const pair<long long, long long>& v, const long long& k) { return (v.first < k); } bool operator()(const long long& k, const pair<long long, long long>& v) { return (k < v.first); } }; long long mod1 = ... |
/*
* 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... |
// file: design_1_clk_wiz_1_0.v
//
// (c) Copyright 2008 - 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 disclaime... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; if (t % 2 == 0) { cout << Mahmoud << endl; } else { cout << Ehab << endl; } return 0; } |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > al, dist; int n, m; bool done[5000]; vector<int> bfs(const vector<vector<int> >& al, int s) { queue<int> q; vector<int> dist(al.size(), INT_MAX); dist[s] = 0; q.push(s); while (!q.empty()) { int i = q.front(); q... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll M = 1000000007; const ll M1 = 998244353; using vl = vector<ll>; using pll = pair<ll, ll>; ll power(ll x, ll y) { if (y == 0) return 1; ll res = power(x, y / 2); res = (res * res); if (y & 1) res = (res * x); r... |
`include "constants.vh"
module ram_sync_2r1w(
input clk,
input [BRAM_ADDR_WIDTH-1:0] raddr1,
input [BRAM_ADDR_WIDTH-1:0] raddr2,
output reg [BRAM_DATA_WIDTH-1:0] rdata1,
output reg [BRAM_DATA_WIDTH-1:0] rdata2,
input [BRAM_ADDR_WIDTH-1:0] waddr,
... |
//Jan.7.2005 Register File on Xilinx
// using two dual port ram
module ram32x32_xilinx (
data,
wraddress,
rdaddress_a,
rdaddress_b,
wren,
clock,
qa,
qb);
input [31:0] data;
input [4:0] wraddress;
input [4:0] rdaddress_a;
input [4:0] rdaddress_b;
input wren;
input clock;
output [31:0] qa;
outp... |
/**
* 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 test();
// function with no lifetime, return-type, or port-list
function f0;
blah0;
endfunction
// empty port-list
function f1();
blah1;
endfunction
// non-empty portlist
function f2(stuff2);
blah2;
endfunction
// test that ": function_identifier" remains unscathed
function ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1 << 20; int pos[maxn]; int n, m; long long k, ans[maxn]; int val[maxn]; struct query { int l, r, id; } Q[maxn]; long long now = 0; long long M[maxn]; bool cmp(query a, query b) { if (pos[a.l] == pos[b.l]) return a.r < b.r; ... |
module tenv_usb_decoder #(parameter PACKET_MAXSIZE=64);
//IFACE
wire dplus;
wire dminus;
reg start=0;
integer mode=0;
localparam MODE_PACKET=0,
... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long long maxn = 3e6; const long long mod = 1e9 + 7; const long double PI = acos((long double)-1); long long pw(long long a, long long b, long long md = mod) { long long res = 1; ... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-10; const long long MOD = 1000000007ll; const long long mod1 = 1000000009ll; const long long mod2 = 1100000009ll; int INF = (int)1e9 + 5; long long INFINF = (long long)1e18; int main() { int n; scanf( %d , &n); int a, 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... |
module add_5stage (
input ck,
input [63:0] i_a, i_b,
input [6:0] i_htId,
input i_vld,
output [63:0] o_res,
output [6:0] o_htId,
output o_vld
);
// Wires & Registers
wire [63:0] c_t1_res;
wire [6:0] c_t1_htId;
wire c_t1_vld;
reg [63:0] r_t2_res, r_t3_res, r_t4_res, r_t5_res... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int add(int a, int b) { return (a + b) % MOD; } int sub(int a, int b) { return add(a, MOD - b); } int mul(int a, int b) { return ((long long)a * b) % MOD; } int inv(int a) { int b = 1; for (int i = 0; (1 << i) <= MOD - 2; i++) { ... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: bw_io_dtl_drv.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... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2011(c) Analog Devices, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// a... |
/*
* 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 fast_expo(long long int x, long long int p) { if (p == 0) return 1; else if (p % 2 == 0) { long long int t = fast_expo(x, p / 2) % 1000000007; return (t * t) % 1000000007; } else return (x * (fast_expo(x, p - 1)) % 10000... |
#include <bits/stdc++.h> using namespace std; int z[100005], cnt[100005]; char s[100005]; void solve() { int n, t, L, R; n = strlen(s), L = R = 0; z[0] = n; for (int i = 1; i < n; i++) { if (R < i) { L = R = i; while (R < n && s[R - L] == s[R]) R++; z[i] = R - L, R-... |
// -------------------------------------------------------------
//
// Generated Architecture Declaration for rtl of IO60DRV1
//
// Generated
// by: wig
// on: Wed Mar 7 06:35:27 2007
// cmd: /cygdrive/c/Documents and Settings/wig/My Documents/work/MIX/mix_0.pl ../../bugver2006.xls
//
// !!! Do not edit this file... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int MOD = 1e9 + 7; const long long INF64 = 1e18; const long double EPS = 1e-7; mt19937 myrand(time(NULL)); const int N = 100 * 1000 + 13; int n, ac, d; pair<int, int> a[N]; long double t[N]; bool read() { if (scanf( %d%d%... |
//
// Copyright (c) 2015 Jan Adelsbach <>.
// 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 Foundation, either version 3 of the License, or
// (at your optio... |
/**
* 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: 00:45:59 02/22/2015
// Design Name:
// Module Name: Allign
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependen... |
#include <bits/stdc++.h> using namespace std; template <class T> bool uin(T &a, T b) { return (a > b ? a = b, true : false); } template <class T> bool uax(T &a, T b) { return (a < b ? a = b, true : false); } int const X = 8; int const L = 26; int const N = 41; long long const INF = 3e18 + ... |
module spi_engine_execution (
input clk,
input resetn,
output reg active,
output cmd_ready,
input cmd_valid,
input [15:0] cmd,
input sdo_data_valid,
output reg sdo_data_ready,
input [7:0] sdo_data,
input sdi_data_ready,
output reg sdi_data_valid,
output [7:0] sdi_data,
input sync_ready,
output reg s... |
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995/2004 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
//
//... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int a[maxn], vis[maxn]; int main() { int n, p, flag = 0, mark = 0, tot = 0, Min = 1e9 + 7, cur, Max = -1e9 - 7, Maxcur; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); if (a[i] == 0... |
// 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 : Mon Feb 27 15:47:02 2017
// Host : GILAMONSTER running 64-bit major release (... |
#include <bits/stdc++.h> using namespace std; int T[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int W[24]; bool ok(int n) { bool l = false; for (int i = 0; i < 12; i++) { ... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 23:41:30 06/09/2015
// Design Name: game_text_top
// Module Name: D:/OnGoingProject/Curriculum/ISE/Proj_x/proj_test/test_game_text_top.v
// Project Name: proj_test
/... |
#include <bits/stdc++.h> using namespace std; using lint = long long; using ulint = unsigned long long; const int N = 1500 + 1; int a[N]; int bit[N]; int back[N]; int lsb(int x) { return x & -x; } int query(int r) { int res = 0; for (; r > 0; r -= lsb(r)) { res = max(res, bit[r]); } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long a; cin >> a; vector<long long> x; for (long long i = 0; i < a; i++) { long long b; cin >> b; x.push_back(b); } bool done[101] = ... |
/**
* 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) 2014 Takashi Toyoshima <>.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
`timescale 100ps/100ps
module InterruptLogicTest;
reg clk;
reg rst_x;
reg r_irq_x;
reg r_nmi_x;
wire [ 7:... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } int main() { int k; cin >> k; long long a; while (k--) { cin >> a; long long g = gcd(a + 1, a * 4); long long l = (a + 1) * a * 4 / g; ... |
/**
# Rx8b10b Receiver/Decoder #
Takes in an unaligned serial bit stream, aligns to comma symbols in the data,
and decodes the 8b10b encoded data.
## Bit Alignment ##
Bit alignment here is extremely naive: it aligns to the latest detected bit edge
in the bitstream.
## Word Alignment ##
Word alignment is done by ali... |
#include <bits/stdc++.h> using namespace std; char BUF[500010]; int n, m; int up[500010], down[500010], L[500010], R[500010]; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) { scanf( %s , &BUF); for (int j = 0; j < m; ++j) switch (BUF[j]) { case 1 : i... |
module top;
reg passed;
reg signed[95:0] m_one, m_two, zero, one, two;
// Both argument positive.
reg signed[95:0] rem;
wire signed[95:0] wrem = one % two;
// First argument negative.
reg signed[95:0] rem1n;
wire signed[95:0] wrem1n = m_one % two;
// Second argument negative.
reg signed[95:0] re... |
#include <bits/stdc++.h> #pragma GCC optimize( unroll-loops ) using namespace std; const long long N = 2e5 + 36; const long long M = 1e3 + 36; const long long INF = 2e9 + 7; const long long MOD = 987654323; const int X[8] = {1, 1, -1, -1, 2, 2, -2, -2}; const int Y[8] = {2, -2, 2, -2, 1, -1, 1, -1}; s... |
`timescale 1ns/1ns
module usb_ctrl // usb control endpoint transfer
(input c, // bus clock
input rst,
output token_start,
output ack_start,
input tx_sie_done,
input [ 6:0] addr,
input [63:0] d,
output [18:0] token,
output [7:0] txd,
output txdv,
input ... |
//
// Author: Pawel Szostek ()
// Date: 01.08.2011
`timescale 1ns/1ps
module dummy_v( input [7:0] in, output reg [7:0] out);
assign out = {in[7], 7'b1111111}; //there is no equivalent to vhdl's `others'
endmodule
module stimulus (output reg [7:0] a);
parameter S = 20000;
int unsigned j,i;
initial beg... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; const int maxn = 1e5 + 10; const int mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ll pwr(ll a, ll pw) { ll ret = 1; while (pw > 0) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( inline ) #pragma GCC optimize( omit-frame-pointer ) #pragma GCC optimize( unroll-loops ) using namespace std; template <class T> void debug(vector<T> vec) { for (int i = 0; i < vec.size(); i++) cerr << vec[i] << ; cerr... |
/**
* This is written by Zhiyang Ong
* and Andrew Mattheisen
* for EE577b Troy WideWord Processor Project
*/
// IMPORTANT: This requires an input text file named "rf1.fill"
// Include definition of the control signals
`include "control.h"
// Non-synthesizable behavioral RTL model for the instruction memory
mod... |
module SmallBsf_tb ();
parameter K0_SHIFT = 6; ///< K0 filter term = 2^-K0_SHIFT
parameter K1_SHIFT = 6; ///< K1 filter term = 2^-K1_SHIFT
parameter WIDTH = 16; ///< Width of data path
parameter CLAMP = 1; ///< Set to 1 to clamp the accumulators
parameter FREQ_RATE = ;
reg clk;
reg rst;
reg en;
reg signed [WIDT... |
#include <bits/stdc++.h> using ll = long long; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::string s; std::cin >> s; int n = s.length(); std::vector<std::set<int>> adj(26); for (int i = 0; i < n; ++i) { int d = s[i] - a ; adj[d].insert(i); } ... |
#include <bits/stdc++.h> struct oficinas { int valor; int sig; }; int v[200002], vaux[200002]; int buscar(int buscado); int main() { int n, q, type, x, y, i, A, B, aux; scanf( %d %d , &n, &q); for (i = 1; i <= n; i++) { v[i] = i; vaux[i] = i + 1; } for (i = 0; i < q; i+... |
// (C) 1992-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 simulati... |
//Copyright 1986-2014 Xilinx, Inc. All Rights Reserved.
//--------------------------------------------------------------------------------
//Tool Version: Vivado v.2014.4 (lin64) Build Tue Nov 18 16:47:07 MST 2014
//Date : Thu Mar 31 18:01:07 2016
//Host : lubuntu running 64-bit Ubuntu 15.04
//Command ... |
module DCM_BUFG (input I, input RST_N, output O);
wire CLKFB_IN;
wire GND_BIT;
wire [6:0] GND_BUS_7;
wire [15:0] GND_BUS_16;
wire RST_P;
assign GND_BIT = 0;
assign GND_BUS_7 = 7'b0000000;
assign GND_BUS_16 = 16'b0000000000000000;
assign RST_P = !RST_N;
assign O = CLKFB_IN;
BUFG C... |
#include <iostream> #include <algorithm> #include <vector> #include <utility> using namespace std; int main() { int task; cin>>task; while(task--) { int n; cin>>n; int a[n]; int ans=n+n-1; for(int i=0;i<n;i++) { ... |
#include <bits/stdc++.h> using namespace std; int n, i, ans, a[1001]; int main() { cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; for (i = 2; i < n; i++) if ((a[i] > a[i - 1] && a[i] > a[i + 1]) || (a[i] < a[i - 1] && a[i] < a[i + 1])) ans++; cout << ans; return 0; }... |
#include <bits/stdc++.h> using namespace std; int cnt[5]; int main() { int n, t; cin >> n; memset(cnt, 0, sizeof(0)); for (int i = 0; i < n; i++) { cin >> t; cnt[t]++; } bool flag = true; int ret = 0; int minN = min(cnt[1], cnt[2]); cnt[3] += minN; cnt[1] -= min... |
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b; cin >> a >> b; if (b / 2 >= a) cout << (b % (b / 2 + 1)); else cout << b % a; cout << n ; return; } signed main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); srand(time(NUL... |
#include <bits/stdc++.h> using namespace std; int n, m, k, i, j, v, bor[100005][27], a[100005], b[100005]; string s; void dfs(int v) { int q = 0; int u = 0; int t = 0; for (int i = 1; i < 27; i++) { if (bor[v][i] > 0) { q = 1; dfs(bor[v][i]); if (a[bor[v][i]] == 0) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d %d , &n, &m); vector<int> vec(n + 1, 0); vector<pair<int, pair<int, int>>> arr; for (int i = 0; i < m; i++) { int si, di, ci; scanf( %d %d %d , &si, &di, &ci); arr.push_back(make_pair(di, make_pair(s... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int a, b, c, d; cin >> a >> b >> c >> d; if (a * d < c * b) { int g = gcd(b * c - a *... |
(* CHAPTER VI: SIMILARITY OF RELATIONS *)
Require Export Chap5.
Definition heterogeneous_relation {X} {Y} := X -> Y -> Prop.
(* The relation in stdlib is what we called 'homogeneous relation',
because the domain and the converse domain has the same logic type. *)
Definition homogenenous_relation {X} := X -> X -... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; vector<vector<int>> v; vector<int> cur; if ((n * m) % k == 0) { int div = (n * m) / k; for (int i = 0; i < n; i++) { if (!(i & 1)) { for (int j = 0; j < m; j++) { ... |
// Register File module
`timescale 1ns / 1ps
module regfile (
clk,
rst,
wen,
//lhb_llb_sec_control,
//jr_rf,
//jr_raddr,
//jal_write_reg,
//jal_pc_val,
raddr1,
raddr2,
waddr,
wdata,
rdata1,
rdata2
);
parameter DSIZE=16;
parameter NREG=16;
localparam RSIZE=4;
in... |
module mojo_top(
input clk,
input rst_n,
input cclk,
output[7:0]led,
output spi_miso,
input spi_ss,
input spi_mosi,
input spi_sck,
output [3:0] spi_channel,
input avr_tx,
output avr_rx,
input avr_rx_busy,
output sdra... |
#include <bits/stdc++.h> using namespace std; int n; int dat[100000 + 10]; int vis[100000 + 10]; int dfs(int x) { vis[x] = 1; if (vis[dat[x]] == 0) return dfs(dat[x]) + 1; return 1; } int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { cin >> dat... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18, N = 1e6, mod = 1e9 + 7; const long double PI = acos(-1), eps = -1e9; inline void read(long long &a) { char c; bool neg = 0; c = getchar(); a = 0; if (c == - ) { neg = 1; c = getchar(); } while (c >... |
/**
* 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; void er() { cout << NO << endl; exit(0); } int main() { int n; cin >> n; int a[n + 1]; int o = 0; int um = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] != 0) o++; um = um + a[i]; } if (o < 1) er(... |
/**
* 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> void dfs(int64_t node, int64_t from, const std::vector<std::vector<int64_t> > &g, std::vector<bool> &visited, int64_t &count, bool &cycle, bool &self) { if (visited[node]) { return; } visited[node] = 1; ++count; for (int64_t p = 0; p < g[node].s... |
/**
* 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 = int(500 * 1000 + 7); long long n, k; vector<pair<long long, long long> > adj[N]; long long dp[N][2]; void dfs(int v, int p = -1) { vector<long long> x; long long curr = 0; for (auto it : adj[v]) { long long to = it.first; lo... |
#include <bits/stdc++.h> using namespace std; long long a[51][51]; long long combinatorics(long long n, long long k) { double res = 1; for (long long i = 1; i <= k; ++i) res = res * (n - k + i) / i; return (long long)(res + 0.01); } int main() { long long n, m, i, j, numOneRow[51] = {0}, numZe... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; inline void rd(int &x) { int k; int m = 0; x = 0; for (;;) { k = getchar(); if (k == - ) { m = 1; break; } if ( 0 <= k && k <= 9 ) { x = k - 0 ; break; } ... |
#include <bits/stdc++.h> using namespace std; vector<int> di[100003]; struct trie { trie *zero, *one; int val; trie() { zero = one = NULL; val = 100003; } } * root[100003]; void add(trie *cur, int a) { int i, ck; for (i = 20; i >= 0; i--) { ck = (1 << i & a); if... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[101]; bool f = 1; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1) f = 0; } if (f) puts( EASY ); else puts( HARD ); } |
/*
* 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.