text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long long n, k, q, a[200005], f[200005]; int main() { cin >> n >> k >> q; for (int i = 1; i <= n; i++) { long long l, r; cin >> l >> r; a[l]++; a[r + 1]--; } for (int i = 1; i <= 200000; i++) a[i] += a[i - 1]; for (int i = 1... |
#include <bits/stdc++.h> using namespace std; int a, b, c; int sisa(int x, int n) { if (x >= 0) return x % n; else if (abs(x) % n == 0) return 0; else return ((abs(x) / n) + 1) * n + x; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> 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; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; template <class T> inline bool Min(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> inline bool Max(T &a, T b) { re... |
/*
* 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... |
#include <bits/stdc++.h> template <class T> T abs(T x) { return x > 0 ? x : -x; } const int MAXINT = 1111 * 1111 * 1111; const long long MAXLINT = MAXINT * 1ll * MAXINT; const long double EPS = 1e-10; using namespace std; int n, m, x, y, z, p; int a, b; void reverse_left() { int aa = a, bb =... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const double eps = 1e-9; vector<long long> prnum; void sieve() { bool prime[1000001]; memset(prime, true, sizeof(prime)); for (int i = 2; i * i <= 1000000; i++) { if (prime[i] == true) { for (int j = 2 * i; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { if (a == 0) return b; return gcd(b % a, a); } template <typename T> T pow(T a, T b, long long m) { T ans = 1; while (b > 0) { if (b % 2 == 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b; cin >> a >> b; if (a == 0 || b == 0) { cout << 0 << endl; return; } cout << min((a + b) / 3, min(a, b)) << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); int tc = 1; cin >>... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int mid = 0; int num = 0; int e[21][21]; int flag[21]; void dfs(int x, int sum) { if (x > n) { num = num + 1; return; } dfs(x + 1, sum); for (int y = 1; y <= n; y++) { if (num > k) { break; } i... |
#include <bits/stdc++.h> using namespace std; int M = 998244353; int pow(int a, int b) { if (b == 0) { return 1; } if (b % 2) { return ((long long)a * pow(a, b - 1)) % M; } else { int temp = pow(a, b / 2); return ((long long)temp * temp) % M; } } int inv[3010]; in... |
module jbasicgatestb;
wire yOR,yAND,yXOR,yNOR,yNAND,yXNOR;
reg a,b;
jbasicgates jbgs(yOR,yAND,yXOR,yNOR,yNAND,yXNOR,a,b);
initial
begin
$display("RSLT\ta\tb\tOR\tAND\tXOR\tNOR\tNAND\tXNOR");
a = 0; b = 0; #50; // Assign values and some delay
if ( (yOR == 0) && (yAND == 0) && (yXOR == 0) && (... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x = 4, y = 5; scanf( %d , &n); if (n == 1 || n == 2) { cout << 1; return 0; } while (y < n) { if (x & 1) x = 2 * y, y = x + 1; else x = 2 * y - 1, y = x + 1; } printf( %d , (x == n |... |
`timescale 1ns/1ns
module testbench;
parameter t_c = 10;
reg clk;
reg rst;
reg pro_done=0;
wire done;
//wire start_ok;
initial begin
$fsdbDumpfile("wave_test.fsdb");
$fsdbDumpvars;
end
always begin //clk gen
clk = 1'b1; #(t_c/2);
clk = 1'b0; #(t_c/2);
end
initial begin //reset gen
rst = 1'b1;
#(2.5*... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200007; const int mod = 998244353; long long fast_pow(long long b, int k) { long long s = 1; while (k) { if (k & 1) (s *= b) %= mod; (b *= b) %= mod; k >>= 1; } return s; } long long fact[maxn]; int N; int A... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; inline int read() { int x = 0, w = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) w = -1; c = getchar(); } while (c <= 9 && c >= 0 ) { x = (x << 1) + (x << 3) + c - 0 ; c = getc... |
#include <bits/stdc++.h> using namespace std; long long dp[10000006]; int main() { long long n, x, y; scanf( %lld%lld%lld , &n, &x, &y); for (int i = 0; i <= n; ++i) dp[i] = 1e18 + 100; dp[1] = x; for (int i = 2; i <= n; ++i) { if (i % 2 == 1) dp[i] = min(dp[i - 1] + x, min(dp[i ... |
#include <bits/stdc++.h> int v[1000005]; int main() { int i, j, k; int n, m, a, b; int f[1010]; while (~scanf( %d , &n)) { memset(v, 0, sizeof(v)); a = b = 0; for (i = 0; i < n; i++) { scanf( %d , &f[i]); v[f[i]]++; if (v[f[i]] > b) { a = f[i]; ... |
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016
// Date : Thu Sep 21 11:24:56 2017
// Host : vldmr-PC running 64-bit Service Pack 1 ... |
#include <bits/stdc++.h> using namespace std; long long modinverse(long long a, long long m) { long long m0 = m; long long y = 0, x = 1; if (m == 1) return 0; while (a > 1) { long long q = a / m, t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } if (x < 0)... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: iobdg_1r1w_rf4.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 an... |
/**
* Used by the SD card reader to receive data responses from the
* SPI flash interface and store them in RAM.
*
* @author Robert Fotino, 2016
*/
`include "../definitions.vh"
module spi_data_reader
(
input clk,
input calib_done,
input sclk_posedge,
input ... |
//`#start header` -- edit after this line, do not edit this line
// ========================================
//
// Copyright YOUR COMPANY, THE YEAR
// All Rights Reserved
// UNPUBLISHED, LICENSED SOFTWARE.
//
// CONFIDENTIAL AND PROPRIETARY INFORMATION
// WHICH IS THE PROPERTY OF your company.
//
// =======... |
/**
* 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... |
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016
// Date : Tue Sep 19 16:48:52 2017
// Host : vldmr-PC running 64-bit Service Pack 1 ... |
module lab5(CLK, RESET, IOA, IOB, IOC, EN_L, PC, NextPC, Iin, DataA, DataB, DataC, DataD, Din, MW, IOD, IOE, IOF, IOG);
input CLK;
input RESET;
input [7:0] IOA;
input [7:0] IOB;
input [7:0] IOC;
input EN_L;
output [7:0] PC;
output [7:0] NextPC;
output [15:0] Iin;
ou... |
// AJ, Beck, and Ray
// ALUnit testbench
// 5/4/15
`include "adder_subtractor.v"
`include "flag.v"
`include "mux2_1.sv"
`include "adder16b.v"
`include "adder4b.v"
`include "fullAdder1b.v"
`include "lookAhead4b.v"
`include "ALUnit.sv"
`include "addition.v"
`include "subtract.v"
`include "andGate.v"
`include "orGate.v"
`... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int ans = 1e9; for (int i = 0; i < n - 1; i++) if (s[i] == R && s[i + 1] == L ) ans = min(ans, (a[i + 1] - a[i]) / 2); if (a... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); vector<vector<long long>> a(n); for (int i = 0; i < n; i++) { int m; long long p; scanf( %d , &m); scanf( %lld , &p); a... |
// $Revision: $ $Date: $
//-----------------------------------------------------------------------------
// (c) Copyright 2011 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyright and other ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; template <typename T, typename TT> inline ostream &operator<<(ostream &os, const pair<T, TT> &t) { return os << t.first << << t.second; } template <typename T> inline ostream &operator<<(ostream &os, const vector<T> &t) { ... |
#include <bits/stdc++.h> using namespace std; int n; struct node { int x, index; } a[1010]; bool cmp(node x, node y) { if (x.x != y.x) return x.x > y.x; else return x.index > y.index; } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i].x);... |
#include <bits/stdc++.h> using namespace std; int n; int v[2][1000000 + 10]; void solve(int n, int p) { if (n == 0) { v[p][0] = 0; return; } if (!(n & (n + 1))) { for (int i = 0; i <= n; ++i) { v[p][i] = n - i; } } else { int two = 1; while (two * 2 < ... |
// wasca_nios2_gen2_0.v
// This file was auto-generated from altera_nios2_hw.tcl. If you edit it your changes
// will probably be lost.
//
// Generated using ACDS version 15.1 193
`timescale 1 ps / 1 ps
module wasca_nios2_gen2_0 (
input wire clk, // cl... |
#include <bits/stdc++.h> using namespace std; int n, sum, m[17], r[17]; double ans; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> m[i]; for (int i = 1; i <= n; i++) cin >> r[i]; for (int i = 1; i <= 999999; i++) for (int j = 1; j <= n; j++) if (i % m[j] == r[j]) { ... |
/*
* 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; char s[111111]; int m, l, r, n, pos[111111], nxt[111111][28], pre[111111][28], pr[111111][28], nx[111111][28], cur[28], a[111111]; int prefix[111111]; int solve(int l, int r); int getsuf(int pos, int k) { if (~nx[pos][k]) return nx[pos][k]; return ... |
//////////////////////////////////////////////////////////////////////
//// ////
//// serialInterface.v ////
//// ////
//// This file is part of the ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000005; int n, q[N], top1, top2; struct ky { int x, y; long long w, val; bool operator<(const ky& p) const { return x < p.x; } } a[N]; long long f[N], ans; inline double slope(const int x, const int y) { return a[x].x == a[y].x ?... |
#include <bits/stdc++.h> bool u[1000001]; int pr[500001]; int l; int n; long long a[8]; int f[7000]; int thr[10]; int b[8]; int inf = 10000; int g[8]; int cal(long long x) { int i; int ret = 0; for (i = 1; i <= l && pr[i] <= x / pr[i]; i++) { while (x % pr[i] == 0) { x = ... |
`default_nettype none
module pulse_gen(
input clk, // 12 MHz base clock
input clk_pll,
input RS232_Rx, // Receive pin for the FTDI chip
input resetn, // Reset the cycle
output RS232_Tx, // Transmit pin for the FTDI chip
output Pulse, // Output pin for the switch
output Sync, // Output pin for the SYNC pulse
/... |
#include <bits/stdc++.h> using namespace std; const int kMaxN = 100010; const int kMaxA = 1000000010; int a[kMaxN]; signed main() { cin.tie(0); ios::sync_with_stdio(false); long long n; cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); long long... |
`default_nettype none
`timescale 1ns / 1ps
module interrupt_controller (
input wire clock,
input wire reset,
input wire m1_n,
input wire iorq_n,
output wire int_n,
input wire [4:0] int_req,
output reg [4:0] int_ack,
output wire [7:0] jump_addr,
input wire ... |
/*
* 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 agr... |
// megafunction wizard: %RAM: 2-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: feature_map_ram_1024w.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// ==================... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read(T& x) { x = 0; int f = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) f |= (ch == - ), ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); return x = f ? -x : x; } ... |
/*
* Milkymist SoC
* Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is dis... |
#include <bits/stdc++.h> using namespace std; int di[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dj[] = {1, -1, 0, 0, 1, -1, 1, -1}; inline int calcMedian(vector<int> &vec) { if (((int)vec.size()) % 2 == 1) { return vec[((int)vec.size()) / 2]; } return (vec[((int)vec.size()) / 2 - 1] + vec[((int)vec.... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:66777216 ) using namespace std; struct node { int num, cnt; node *l, *r, *p, *path; }; typedef node *pnode; const int N = 100003; node tr[N + 1]; pnode tmp[100002]; const pnode pNull = tr + N; inline void upd(pnode v) { if (v == pN... |
`include "constants.vh"
`include "rv32_opcodes.vh"
module singlecycproc
(
output wire [`ADDR_LEN-1:0] iraddr1,
output wire [`ADDR_LEN-1:0] iraddr2,
output wire [`ADDR_LEN-1:0] draddr1,
output wire [`ADDR_LEN-1:0] draddr2,
input wire [`DATA_LEN-1:0] irdata1,
input wire [`DATA_LEN-1:0] irdata2,
... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while(t--){ int n; cin >> n; vector<int> arr(n,0); for(int i = 0; i < n; i++){ cin >> arr[i]; } vector<int> str; str.push_back(arr[0]); ... |
#include <bits/stdc++.h> using namespace std; long long a1, a2, b1, b2, c1, c2, d1, d2; int main() { cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2; for (int q = 0; q < 4; q++) { if (q == 0) { d1 = b1 - (a1); d2 = b2 - (a2); } if (q == 1) { d1 = b1 - (-a1); d2 = ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: Jafet Chaves Barrantes
//
// Create Date: 15:45:17 04/03/2016
// Design Name:
// Module Name: contador_AD_SS_2dig
// Project Name:
// Target Devices:
// Tool versions:
// Descri... |
// (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 law... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pint = pair<int, int>; using pll = pair<ll, ll>; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, m; cin >> n >> m; vector<ll> a(n); for (ll i = 0; i < (ll)n; i++) cin >> a[i]... |
#include <bits/stdc++.h> using namespace std; int a[11000][4]; int ans[110][110]; int main() { cin.sync_with_stdio(false); cin.tie(0); int n, m, q; cin >> n >> m >> q; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) ans[i][j] = 0; for (int i = 0; i < q; i++) { int x1;... |
#include <bits/stdc++.h> using namespace std; const int M = 100000 + 10; struct NODE { long long int index; long long int a; bool operator<(const NODE& x) const { return a < x.a; } } node[M]; struct SUR { long long int index; long long int a; bool operator<(const SUR& x) const { return... |
/*
* 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 h, n; long long ret = 0LL; int a[60]; long long two(int x) { if (x == 0) return 1LL; long long half = two(x / 2); half *= half; return x % 2 ? half * 2 : half; } void solve() { int c = 0; --n; while (n) { a[c++] = n ... |
#include <bits/stdc++.h> using namespace std; const int X[4] = {0, 0, -1, 1}; const int Y[4] = {-1, 1, 0, 0}; int dp[1001][1001], Vis[1001][1001]; char c[1001][1001]; int vis[1001][1001], i, j, m, n, p, k, ans; bool check(int x, int y, int xx, int yy) { if (x < 0 || y < 0 || x > n || y >= m) return fa... |
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; const int inf = 0x3f3f3f3f; const ll linf = 0x3f3f3f3f3f3f3f3f; const ll mod = 1e9 + 7; //const ll mod = 998244353; ll ksm(ll x,ll k) { ll r... |
#include <bits/stdc++.h> using namespace std; int i; long n, m; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; map<string, int> mp; string s; while (n--) { cin >> s; mp[s]++; if (mp[s] > 1) { cout << YES << endl; } 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 law... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); vector<int> segs; int numNeg = 0; int curLen = 0; for (int i = 0; i < n; i++) { int a; scanf( %d , &a); if (a < 0) { if (numNeg == 2) { segs.push_back(curLen); cur... |
#include <bits/stdc++.h> using namespace std; int a[100100]; int num[100100]; int main() { set<int> s; int n; cin >> n; for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = n; i >= 1; i--) { s.insert(a[i]); num[i] = s.size(); } s.clear(); long long sum = 0; ... |
// Driver for an LCD TFT display. Specifically, this was written to drive
// the AdaFruit YX700WV03, which is an 800x480 7" display. It's driven
// like a VGA monitor, but with digital color values, a data enable signal,
// and a clock.
module LCD_control(
input wire clock, // System clock.
inpu... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 1005; const int oo = 1000000000; const long long Base = 1000000007; typedef int Tarr[MaxN]; long long x, y, a, b, n, m, xx, yy, r1, r2, r3, r4; void Ok(int Val) { int xx = Val * a, yy = Val * b; if (xx % 2 == 0) { r1 = max((long ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 12:09:46 04/21/2015
// Design Name:
// Module Name: clockdivider
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// De... |
/**
* 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... |
//#############################################################################
//# Function: Low power clock gate circuit #
//#############################################################################
//# Author: Andreas Olofsson #
... |
`include "../../elink/hdl/elink_constants.v"
module fifo_async
(/*AUTOARG*/
// Outputs
full, prog_full, dout, empty, valid,
// Inputs
wr_rst, rd_rst, wr_clk, rd_clk, wr_en, din, rd_en
);
parameter DW = 104; //FIFO width
parameter DEPTH = 16; //FIFO depth
//######... |
// Copyright (c) 2015 Kareem Matariyeh
//
// 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> #define llong long long #define mkpr make_pair #define x first #define y second #define iter iterator #define riter reverse_iterator #define y1 Lorem_ipsum_ #define tm dolor_sit_amet_ using namespace std; inline int read() { int x = 0,f = 1; char ch = getchar(); fo... |
#include <bits/stdc++.h> using namespace std; int main() { long long kkk, kk, otv = 0; string ss; long long i, a; cin >> a; for (i = 0; i < a; i++) { long long s1, s2, s3; cin >> s1 >> s2 >> s3; if ((s1 > s2 + s3 + 1) || (s2 > s1 + s3 + 1) || (s3 > s1 + s2 + 1)) cout <<... |
#include <bits/stdc++.h> using namespace std; int expo(int x, int y) { int res = 1; while (y) { if (y % 2) res = (res * x % 1000000007) % 1000000007; x = (x * x) % 1000000007; y /= 2; } return res; } bool isPrime(long long n) { if (n <= 1) return false; if (n <= 3) retu... |
//--------------------------------------------------------------------------
// --
// OneWireMaster --
// A synthesizable 1-wire master peripheral --
// Copyrig... |
/* -------------------------------------------------------------------------------
* (C)2007 Robert Mullins
* Computer Architecture Group, Computer Laboratory
* University of Cambridge, UK.
* -------------------------------------------------------------------------------
*
* FIFO
* ====
*
* Implementation not... |
#include <bits/stdc++.h> using namespace std; int n; int vis[601], co[601], fa[601], d[601]; int zb(int o, int l, int r) { int ans1 = 0, ans2 = 0; int sz = 0; for (int i = l; i <= r; i++) if (!vis[i]) sz++; if (sz > 0) { printf( ? %d n , sz + 1); for (int i = l; i <= r; i++) ... |
// file: clk_wiz_v3_6_tb.v
//
// (c) Copyright 2008 - 2011 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyright and other intellectual property
// laws.
//
// DISCLAIMER
// This disclaimer is ... |
#include<iostream> #include<cstdlib> #include<cstdio> #include<cmath> #include<iomanip> #include<cstring> #include<algorithm> #include<ctime> using namespace std; const int MAXN=2010; int read() { int kkk=0,x=1; char c=getchar(); while((c< 0 || c> 9 ) && c!= - ) c=getchar(); if(c== - ... |
#include <bits/stdc++.h> using namespace std; long long n, a[200009], ans = 1, b[200009], sum = 1; bool vis[200009]; void dfs(long long x) { if (vis[x]) return; vis[x] = 1; dfs(a[x]); } int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin ... |
/**
* 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 2014 - 2017 (c) Analog Devices, Inc. All rights reserved.
//
// In this HDL repository, there are many different and unique modules, consisting
// of... |
#include <bits/stdc++.h> using namespace std; const long double pi = 3.14159265358979323846; long long MOD = 1e9 + 7; const char nl = n ; const long long inf = 1e15; long long power(long long x, long long y) { long long z = 1; while (y > 0) { if (y % 2) z = z * x; x = x * x; y /=... |
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T x, T y) { if (x < y) swap(x, y); while (y > 0) { T f = x % y; x = y; y = f; } return x; } const int maxn = 200005; int n; int a[maxn]; int dp[maxn]; vector<int> adj[maxn]; void dfs(int u, in... |
#include <bits/stdc++.h> using namespace std; const int o_9357fc8171180e5951f52ff0433bc1c2 = 2e5 + 5; int o_c6e13f5716dd4a7981ad58d262f52b74[o_9357fc8171180e5951f52ff0433bc1c2]; int o_9c41a6fd007fd994071a60164bbac5df[o_9357fc8171180e5951f52ff0433bc1c2]; int o_0f2474e49c5126ff73eea4a0af8b5e21[o_9357fc8171180e5... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2007 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
reg toggle;
integer cyc; initial cy... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k, p; cin >> n >> k; int l = log2(n) + 1; for (long int i = 1; i <= 30; i++) { if (n - i * k > 0) { p = n - i * k; bitset<30> b(p); if (i > b.count() && p != 1 && p >= i) { cout << i; ... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); return x * f; } int n, 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 la... |
#include <bits/stdc++.h> long long mod = 1000000007; long long mod2 = 998244353; long long OO = 1e18; long long david_villa_pow(long long x, long long n) { if (n == 0) return 1; long long u = david_villa_pow(x, n / 2); u = ((u) * (u)); if (n % 2 == 1) u = ((u) * (x)); return u; } long lo... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int Gcd(int x, int y) { if (y == 0) return x; return Gcd(y, x % y); } int main(void) { int n, i, ans; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); ans = 0; for (i = 1; i <= n; ... |
#include <bits/stdc++.h> using namespace std; void debug(int n) { printf( %d n ); } bool cmp(pair<int, pair<int, int> > &a, pair<int, pair<int, int> > &b) { if (a.second.first == b.second.first) { return a.first < b.first; } return a.second.first < b.second.first; } int main() { int n, u... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; vector<long long int> v; unordered_map<long long int, long long int> mapy; v.push_back(0); v.push_back(2); mapy[2] = 1; for (long long int i = 2; i <= 100000; i++) { v.push_back(((3 * (i * (i + 1))) / 2... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = s.length(); int open = 0; int closed = 0; int hash = 0; for (__typeof((l)) i = 0; i < (l); i++) { if (s[i] == ( ) open++; if (s[i] == ) ) closed++; if (s[i] == # ) hash++; if... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.