text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; vector<long long int> g[100005]; vector<pair<long long int, long long int> > ed; vector<long long int> w; vector<long long int> eff; long long int vis[100005]; long long int val[100005]; long long int rec(long long int i) { if (vis[i] != 1) { vis[i... |
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved.
////////////////////////////////////////////////////////////////////////////////
// ____ ____
// / /\/ /
// /___/ \ / Vendor: Xilinx
// \ \ \/ Vers... |
#include <bits/stdc++.h> using namespace std; int n, m, a[101], b[101], z[101], x, s, k, i, j; int main() { cin >> n >> m; for (i = 1; i <= n; i++) cin >> a[i]; for (i = 1; i <= m; i++) { cin >> b[i]; s += b[i]; } for (i = 1; i <= n - s + 1; i++) { for (k = i; k <= i + s - 1;... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v; long long int n, s, x, countt = 0; cin >> n >> s; for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); } sort(v.begin(), v.end()); int mid = n / 2; int m = v[mid]; if (m <= s) { for (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 la... |
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2017.2 (win64) Build Thu Jun 15 18:39:09 MDT 2017
// Date : Tue Sep 19 09:39:36 2017
// Host : DarkCube running 64-bit major release ... |
// (c) Copyright 2011-2013 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyright and other intellectual property
// laws.
//
// DISCLAIMER
// This disclaimer is not a license and does not g... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2011(c) Analog Devices, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are... |
/*------------------------------------------------------------------------------
* 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... |
// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2017.2
// Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved.
//
// ==============================================================
`timescale 1 ... |
#include <bits/stdc++.h> using namespace std; int cnt[2000006]; int main() { int n, i, w; long long ans; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &w), cnt[w]++; for (i = 0; i < 2000005; i++) { cnt[i + 1] += cnt[i] / 2; cnt[i] %= 2; } ans = 0; for (i = 0; i ... |
#include <bits/stdc++.h> using namespace std; long long pw(long long x, long long p) { if (p == 0) return 1; long long t = pw(x, p / 2); if (p % 2 == 0) return (t * t) % 1000000007; else return (((t * t) % 1000000007) * x) % 1000000007; } const long long NN = 500007; long long pare... |
#include <bits/stdc++.h> using namespace std; const int N = 100009; const long long MOD = 1e9 + 7; int dX[] = {0, 0, 1, -1}; int dY[] = {1, -1, 0, 0}; long long GCD(long long num, long long ones) { return !ones ? num : GCD(ones, num % ones); } string s; map<int, int> mp; long long ans, sum; 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 la... |
/*
Copyright (c) 2014 Alex Forencich
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, modify, merge, publish, distribute,... |
(*
~~~~~~~~~~~
BSD LICENSE
~~~~~~~~~~~
Copyright (c) 2006-2013, Adam Chlipala
All rights reserved.
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 retain the above copyright notice,
... |
#include <bits/stdc++.h> using namespace std; int f3(int n) { return n * (n - 1) * (n - 2) / 6; } int main() { int K; cin >> K; int N = 3; while (f3(N + 1) <= K) N++; int MN = N * (N - 1) / 2; int TN = 100; vector<string> E(TN, string(TN, 0 )); for (int i = 0; i < N; i++) { ... |
#include <bits/stdc++.h> using namespace std; struct camel { int x, y; }; int main() { int n; bool r = false; cin >> n; camel arr[n]; for (int i = 0; i < n; i++) cin >> arr[i].x >> arr[i].y; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (arr[i].x + arr[i]... |
#include <bits/stdc++.h> using namespace std; long long fac(long long n) { long long m = 1; for (long long i = 1; i <= n; i++) { m = m * i; } return m; } long long gcd(long long x, long long y) { if (x > y) swap(x, y); long long md; while (1) { md = y % x; if (md ==... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2016 by Andrew Bardsley.
// SPDX-License-Identifier: CC0-1.0
// bug1071
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
reg [3:0] array_1 [2:0];
reg [3:0] array_... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int d4x[4] = {1, 0, -1, 0}; int d4y[4] = {0, 1, 0, -1}; int d8x[8] = {0, 1, 1, 1, 0, -1, -1, -1}; int d8y[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const long long oo = 1e18; const long long maxN =... |
/*
* 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: 21.06.2017 16:47:20
// Design Name:
// Module Name: parte_7_2_lab
// 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 law... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2014 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
`define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", ... |
module sockit_top (
input OSC_50_B8A,
input RESET_n,
input [3:0] KEY,
input [3:0] SW,
output [3:0] LED,
output [14:0] hps_memory_mem_a,
output [2:0] hps_memory_mem_ba,
output hps_memory_mem_ck,
output hps_memory_mem_ck_n,
output hps_memory_mem_cke,
... |
#include <bits/stdc++.h> using namespace std; long long power(long long base, long long pow, long long mo) { long long res = 1; while (pow) { if (pow % 2 != 0) res = (res * base) % mo; base = (base * base) % mo; pow /= 2; } return res; } long long inv(long long i) { return powe... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int s, f, t; for (int i = 0; i < n; i++) { cin >> s >> f >> t; int flag = t / (m - 1); int yushu = t % (m - 1); int floor; if (flag & 1) { floor = m - yushu; } else ... |
/**
* 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 int32_t M = 1e9 + 7; int32_t mod_inv(int32_t a, int32_t m) { int32_t g = m, r = a, x = 0, y = 1; while (r != 0) { int32_t q = g / r; g %= r; swap(g, r); x -= q * y; swap(x, y); } return x < 0 ? x + m : x; } int g... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t, c; cin >> n >> t >> c; int ls = 0; int ans = 0; for (int i = 1; i <= n; i++) { int a; cin >> a; if (a > t) ls = i; else if (i - ls >= c) ans++; } cout << ans << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<long long int, long long int> a[100005]; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i + 1; } sort(a, a + n); if (n % 2 == 0) { cout << n / 2 << endl; } else { ... |
#include <bits/stdc++.h> using namespace std; map<long long, long long> dist; int main() { long long n, m; cin >> n >> m; long long x; queue<long long> q; for (long long i = 0; i < n; i++) { cin >> x; dist[x] = 0; q.push(x); } long long total = 0; vector<long long... |
#include <bits/stdc++.h> long long int trie[10000007][2] = {0}; long long int bin[40] = {0}, x = 0; long long int a[100005] = {0}, prefix[100005] = {0}, suffix[100005] = {0}; void tobinary(long long int x) { int cnt = 0; memset(bin, 0, sizeof(bin)); while (x > 0) { bin[cnt++] = (x % 2); ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11/07/2015 06:36:58 PM
// Design Name:
// Module Name: m_port_ultra_top
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
... |
`include "timescale.v"
module fb_slave_statem (MRxClk, Reset, MRxDV, MRxDEq5, MRxDEqDataSoC, MRxDEqNumbSoC, MRxDEqDistSoC, MRxDEqDelaySoC, MRxDEqDelayDistSoC, SlaveIDStart, DelayMeasStart,
DistStateEnd, DelayDistStateEnd, SlaveDataStart, SlaveDataEnd, SlaveCrcEnd, IsLastSlave, DataFrameEnd, F... |
`timescale 1ns/10ps
module biglcd_tb();
reg clk_sdram;
reg clk_lcd;
reg clk_cam;
reg reset_n = 0;
//lcd
wire [7:0] R;
wire [7:0] G;
wire [7:0] B;
wire HSYNC;
wire VSYNC;
wire LCD_CLK;
wire DE;
//camera
wire cam_ref_clk;
wire pixclk;
wire vsync;
wire hsync;
wire [7:0] data;
camera u1
(
.refclk(cam_ref_clk),
... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2006 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer j;
integer hit_count;
reg... |
#include <bits/stdc++.h> using namespace std; char a[51][51], b[51][51]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int ax, ay, bx, by, xx, yy, s = 0, ans = 0; cin >> ax >> ay; for (int i = 1; i <= ax; i++) { for (int j = 1; j <= ay; j++) cin >> a[i... |
module MemMux
(
input MEM_MUX_CLK,
inout wire [ 7:0] PORTA_DATA ,
input wire [18:0] PORTA_ADDR ,
input wire PORTA_WE ,
input wire PORTA_OE ,
input wire PORTA_CE ,
output wire [ 7:0] PORTB_DATA ,
input wire [18:0] PORTB_ADDR ,
input ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long maxn = 1e5 + 7; const long long maxe = 1e6 + 7; const long long INF = 1e9 + 7; const double PI = acos(-1); int dx[4] = {0, 0, 1, -1}; int dy[4] = {-1, 1, 0, 0}; inline void Max(int &a, int b) { if (b > a) ... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: dcfifo
// ============================================================
// File Name: fifo.v
// Megafunction Name(s):
// dcfifo
//
// Simulation Library Files(s):
// altera_mf
// ==================================================... |
module spi_slave(input clk, input rst, input ss, input mosi, output miso, input sck, output done, input [bc-1:0] din, output [bc-1:0] dout);
parameter bc=8; // bit count
parameter counter_bits = 6;
reg mosi_d, mosi_q;
reg ss_d, ss_q;
reg sck_d, sck_q;
reg sck_old_d, sck_old_q;
reg [bc-1:0] data_d, data_q;
reg done_d,... |
//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 associated do... |
#include <bits/stdc++.h> using namespace std; const int mxn = 2 * 100000 + 6; int n, root; int a[mxn]; int c[mxn]; int s[mxn]; int base; int ans = 0x3f3f3f3f; int main() { cin >> n >> root; for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); if (i == root && a[i] != 0) { ++b... |
// -------------------------------------------------------------
//
// Generated Architecture Declaration for rtl of inst_ea_e
//
// Generated
// by: wig
// on: Wed Aug 18 12:44:01 2004
// cmd: H:/work/mix_new/MIX/mix_0.pl -strip -nodelta ../../constant.xls
//
// !!! Do not edit this file! Autogenerated by MIX !!!... |
/*
* 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... |
//-----------------------------------------------------------------------------
// Title : ALU Control Unit
// Project : ECE 313 - Computer Organization
//-----------------------------------------------------------------------------
// File : alu_control.v
// Author : John Nestor <>
// Or... |
#include <bits/stdc++.h> using namespace std; void ng() { cout << -1 << n ; } void solve() { int N; cin >> N; map<int, int> M; vector<int> A(N); for (auto &x: A) { cin >> x; M[x]++; } for (auto &[key, val]: M) { if (val > (N + 1) / 2) return ng(); ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, a, b, c, ret = 0, t; scanf( %d %d %d %d , &n, &a, &b, &c); n *= 10; for (i = 0; i <= a; i++) for (j = 0; j <= b; j++) { t = (i * 5); t += (j * 10); if (n - t < 0) continue; if ((n - t) % 20 ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RIT
// Engineer: Cody Cziesler and Nick Desaulniers
//
// Create Date: 11:47:57 04/07/2011
// Design Name: memory
// Module Name: memory
// Project Name: omicron
// Target Devices:... |
#include <bits/stdc++.h> using namespace std; void solve(void); int main() { { ios_base::sync_with_stdio(false); cin.tie(NULL); { solve(); } } return 0; } void solve() { long long int n, i; cin >> n; vector<long long int> v; for (i = 1; i * i <= n; i++) { if... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; pair<long long, long long> a[N]; long long top, k, n, avr, mx; int main() { scanf( %d %d %d , &n, &mx, &avr); for (int i = 1; i <= n; i++) { int b, r; scanf( %d %d , &b, &r); a[i] = make_pair(r, b); top += b; ... |
#include <bits/stdc++.h> using namespace std; long long int arr[105][105]; int main() { long long int n, m; cin >> n >> m; long long int r[n], c[m], tr1 = 0, tr2 = 0; for (long long int i = 0; i < n; i++) { cin >> r[i]; tr1 ^= r[i]; } for (long long int i = 0; i < m; i++) { ... |
module Output_LiquidCyrstalDisplay_TestModule ( // Host Side
iCLK,iRST_N,
d0,d1,d2,d3,d4,d5,
// LCD Side
LCD_DATA,LCD_RW,LCD_EN,LCD_RS );
// Host Side
input iCLK,iRST_N;
// Data test
input [15:0] d0,d1,d2,d3,d4,d5;
// LCD Side
output [7:0] LCD_DATA;
output LCD_RW,LCD_EN,LCD_RS;
// I... |
#include <bits/stdc++.h> using namespace std; int gems[30050], maxi = INT_MIN; int dp[30005][600], kood; int solve(int i, int d) { int change = 300 + (d - kood); if (i > maxi) return 0; if (dp[i][change] != -1) return dp[i][change]; if (d == 1) { return dp[i][change] = gem... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int p = 0; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; x--; if (x % 2) p++; if (p % 2) cout << 1 << endl; else cout << 2 << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int N, M; int A[104][104], B[104][104]; int main() { scanf( %d %d , &N, &M); for (int i = 1; i <= N; ++i) for (int j = 1; j <= M; ++j) { char c; scanf( %c , &c); if (c == * ) A[i][j] = 1; } int cnt = 0; for (int ... |
#include <bits/stdc++.h> int a[] = {0, 2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ul = unsigned long long; using ld = long double; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; vector<ll> a(n); vector<pair<ll, ll>> b; for (int i = 0; i < (n); i++) { cin >> a[... |
module recv_bus(
input clk_sys,
input send_req,
input send_resp,
input tx_ena_bus,
output reg tx_trig_bus,
input rqb,
input rpn,
input [0:3] rnb,
input [0:15] rad,
input [0:15] rdt,
input [0:7] enc_cmd,
output [0:7] tx_bus_cmd,
output [0:7] tx_bus_a1,
output [0:15] tx_bus_a2,
output [0:15] tx_bus_a3
);
... |
// ZX-Evo Base Configuration (c) NedoPC 2008,2009,2010,2011,2012,2013,2014
//
// decoding mode setup: which border, which modes in one-hot style coding
/*
This file is part of ZX-Evo Base Configuration firmware.
ZX-Evo Base Configuration firmware is free software:
you can redistribute it and/or modify it ... |
// Copyright 2020-2022 F4PGA 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<vector<int> > G(n + 5, vector<int>(0)); int c[m + 5][2]; memset(c, (0), sizeof(c)); for (int i = 1; i <= m; i++) { ... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved.
//
// In this HDL repository, there are many different and unique modules, consisting
// of... |
// synthesis translate_off
`timescale 1us/100ns
// synthesis translate_on
module testbench ();
initial begin
$dumpfile("testbench.vcd");
$dumpvars(0, testbench);
end
reg [0:0] clk_12mhz = 0;
reg [0:0] resetn = 0;
initial begin
// pull reset if available
resetn =... |
`timescale 1ns / 1ps
`default_nettype none
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 04:39:25 07/25/2015
// Design Name:
// Module Name: tld_sam
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
... |
/*
* 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() { long long t, n, m, k, rem, each, x, y, i, j, ans; cin >> t; while (t--) { cin >> n >> m >> x >> y; string s[n]; long long one = 0, two = 0; for (i = 0; i < n; i++) { cin >> s[i]; } for (i = 0; i < n; 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... |
#include <bits/stdc++.h> const int Max_N = 100005, Mod = 1000000007; int Fact[Max_N], Inv_Fact[Max_N]; long long Inv(const int x) { return x == 1 ? 1 : (Mod - Mod / x) * Inv(Mod % x) % Mod; } long long Binomial(const int x1, const int x2) { return x1 == -1 && x2 == -1 ? 1 ... |
module alu8b (input wire [7:0] A_in,
input wire [7:0] B_in,
input wire C_in,
input wire [2:0] Opcode_in,
output wire [7:0] Result_out,
output wire C_out);
reg [7:0] reg_result;
reg reg_cout;
wire [7:0] temp_sum;
wire te... |
#include <bits/stdc++.h> using namespace std; void _print(int t) { cerr << t; } void _print(string t) { cerr << t; } void _print(char t) { cerr << t; } void _print(long double t) { cerr << t; } void _print(double t) { cerr << t; } void _print(unsigned long long t) { cerr << t; } template <class T, class... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; vector<long long> a; vector<long long> b; long long sum; if (k + 1 < n) { sum = k + 1; b.push_back(sum); } else { for (long long i = 0; i < n; i++) { cout << n << ; ... |
// Author: Hugues CREUSY
// February 2004
// Verilog model
// project: M25P40 25 MHz,
// release: 1.1
// These Verilog HDL models are provided "as is" without warranty
// of any kind, included but not limited to, implied warranty
// of merchantability and fitness for a particular purpose.
`times... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1000010; int T, n, m, flag, cnt; vector<int> e[N], E[N]; int dfn[N], idx = 0, low[N], bl[N], lb, sta[N], top; template <typename T> void gi(T &x) { x = 0; register char c = getchar(), pre = 0; for (; c < 0 ... |
#include <bits/stdc++.h> using namespace std; long long n, a[300005], b1[500005], b2[500005], cnt = 0, pl[300005], c[300005], ans = 0, plc[300005], m, d, can[300005], r, ne[300005]; pair<int, int> p; pair<int, int> p1; pair<int, int> p2; map<pair<int, int>, int> m1; string s; int main() { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long mod = 1e9 + 7; const int N = 100005; int a[N * 2], ans[N]; stack<int> s; int main() { int n; scanf( %d , &n); for (int i = 1; i <= 2 * n; i++) { char op; scanf( %c , &op); if (op == + ... |
#include <bits/stdc++.h> int main() { int a, b, h = 0, r = 0; scanf( %d %d , &a, &b); while (a > 0) { h += a; r += a % b; a = a / b; while (r >= b) { a++; r -= b; } } printf( %d n , h); } |
/**
* 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; inline long long getint() { long long ssum = 0, ff = 1; char ch; for (ch = getchar(); !isdigit(ch) && ch != - ; ch = getchar()) ; if (ch == - ) ff = -1, ch = getchar(); for (; isdigit(ch); ch = getchar()) ssum = ssum * 10 + ch - 0 ; retu... |
`include "defines.v"
/**
* crossbar.v
*
* @author Kevin Woo <>
*
* @brief Creates a 5x5 crossbar. Takes in two parts of data, a control line
* and a data line for each input/output. Connects each one based on
* the route_config input, a bus of 5 x 3bit control signals to select
* which inp... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; pair<int, int> a[N]; int main() { int n; cin >> n; int mn = 1e9, mx = -1e9; for (int i = 0; i < n; ++i) { cin >> a[i].first >> a[i].second; mn = min(mn, a[i].first); mx = max(mx, a[i].second); } int a... |
////////////////////////////////////////////////////////////////////////////////
//
// Filename: prefetch.v
//
// Project: Zip CPU -- a small, lightweight, RISC CPU soft core
//
// Purpose: This is a very simple instruction fetch approach. It gets
// one instruction at a time. Future versions should pipeline
// fet... |
#include <bits/stdc++.h> using namespace std; const int MX = 25; int main(int argc, char *argv[]) { ios ::sync_with_stdio(false); cin.tie(NULL); int n, k; string s; cin >> n >> k; cin >> s; if (k > (n + 1) / 2) { --k; while (k < n - 1) { cout << RIGHT << n ; ... |
#include <bits/stdc++.h> using namespace std; unsigned long long min(unsigned long long x, unsigned long long y) { if (x < y) return x; return y; } unsigned long long max(unsigned long long x, unsigned long long y) { if (x < y) return y; return x; } long long min(long long x, long long y) { ... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: bw_io_ddr_6sig_x2.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... |
//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... |
/*
Copyright 2015, Google 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
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in wr... |
#include <bits/stdc++.h> using namespace std; int n, k, l, r, sum, sk; int a[1010]; int main() { while (scanf( %d%d%d%d%d%d , &n, &k, &l, &r, &sum, &sk) != EOF) { if (n != k) { int s1, s2; s1 = sum - sk; s2 = sk; int tmp1, tmp2; tmp1 = s1 / (n - k); tmp2... |
#include <bits/stdc++.h> using namespace std; const int N = 1505; const int mo = 998244353; int n, m, a[N][N]; int fa[N], sz[N], S[N]; int f[N][N], tmp[N]; pair<int, int> e[N * N]; int get(int x) { return x == fa[x] ? x : fa[x] = get(fa[x]); } void merge(int x, int y) { memset(tmp, 0, sizeof(tmp))... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007, ans = 1, n, ert, dp[1000002]; int main() { ios_base::sync_with_stdio(false); cin >> n, ert = n; dp[0] = 1, dp[1] = 1; for (int i = 2; i <= n; i++) { dp[i] = ((i - 1) * dp[i - 2] + dp[i - 1]) % mod; } for (int i... |
//START_MODULE_NAME------------------------------------------------------------
//
// Module Name : LPM_HINT_EVALUATION
//
// Description : Common function to grep the value of altera specific parameters
// within the lpm_hint parameter.
//
// Limitation : No error checking to check w... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; const int z = N * 32; int n, a[N], f[N], rt; int pool[z], tp, cnt, ch[z][2]; long long ans; int fa(int x) { if (x == f[x]) return x; return f[x] = fa(f[x]); } void uni(int x, int y) { x = fa(x), y = fa(y); if (x == y) ... |
//
// xc3s250e_godil.v - SPI loader for GODIL with XC3S250E
//
// Copied from bscan_s3e_starter.v.
// Then the starter specific signals removed.
// Top level module renamed from top to xc3s500e_godil.
// Use with a .ucf file with the right PIN assignments.
//
module xc3s250e_godil
(
output wire MOSI,
output wi... |
#include <bits/stdc++.h> using namespace std; const int N = 1E6 + 5, INF = 1E9 + 7; int m, n, ans = INF; mt19937 mt(133769420); int ask(int u, int v) { cout << ? << u << << v << endl; int ret; cin >> ret; return ret; } int rand(int l, int r) { uniform_int_distribution<int> uni(l... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int sign = 1, tmp = 0, ans = 0; for (int i = 0; i < s.size(); i++) { if (!(s[i] >= 0 && s[i] <= 9 )) { ans += tmp * sign; if (s[i] == - ) sign = -1; else sign = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int m, r; scanf( %d %d , &m, &r); int i; double sum = 0.0; if (m == 1) printf( %f , 2.0 * r); else if (m == 2) printf( %f , (2.0 + sqrt(2.0) / 2) * r); else { for (i = 2; i <= m - 1; i++) { sum += (i - 1... |
/*
* 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; void islam() { ios::sync_with_stdio(false); cin.tie(NULL); } void get(long long &x) { cin >> x; } class ghost { public: ghost() { get(n); for (int i = 0; i < n; i++) { get(arr[i]); s += arr[i]; } s /= n; }... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.