text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; map<char, long long> mp; long long arr[2][1234]; int main() { string s; long long idx1, idx2; char repeating; cin >> s; long long i; for (i = 0; i < s.size(); i++) mp[s[i]]++; for (auto it : mp) if (it.second == 2) repeating = it.fi... |
//
// 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)
// ... |
/*
* Copyright (c) 2013, Quan Nguyen
* 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, this
* list of condit... |
/*
* Copyright (C) 2017 Systems Group, ETHZ
* 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 t... |
// megafunction wizard: %Shift register (RAM-based)%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altshift_taps
// ============================================================
// File Name: Line_Buffer.v
// Megafunction Name(s):
// altshift_taps
// ==========================================================... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 100005; const int Maxm = 500; int T; int n, m, k; vector<int> un; int my[Maxn]; bool has[Maxm][Maxm]; set<int> neigh[Maxn]; void Solve(priority_queue<pair<int, int> > &Q) { bool assigned = false; int inside = n; while (!Q.emp... |
#include <bits/stdc++.h> using namespace std; int n, k, i, a[1000021], j; int main() { scanf( %d%d , &n, &k); if (n / k <= 2) { cout << -1; exit(0); } for (i = 1; i <= k * ((n / k) - 1); i++) a[i] = (i - 1) / ((n / k) - 1) + 1; j = ((n / k) - 1) * k; while (j <= n) for (i... |
#include <bits/stdc++.h> using namespace std; signed main() { long long int n, m; cin >> n >> m; if (m == 0) { cout << 0; return 0; } vector<vector<long long int>> v[n + 1]; long long int in[n + 1]; memset(in, 0, sizeof(in)); for (long long int i = 0; i < m; i++) { ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return x * f; } int n, a[300100], q; struct no... |
// 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 : Sun Jun 04 00:42:44 2017
// Host : GILAMONSTER running 64-bit major release (... |
/*
:Project
FPGA-Imaging-Library
:Design
FixedRoundSigned
:Function
Round for signed fixed number.
Give the first output after 3 cycles.
:Module
Main module
:Version
1.0
:Modified
2015-05-16
Copyright (C) 2015 Tianyu Dai (dtysky) <>
This library is free software; you can redistribute it and/or
modify it under ... |
#include <bits/stdc++.h> using namespace std; const int mn = 410, mm = 101000, inf = 1 << 30; bool vis[mn]; int X[mm], Y[mm], du[mn]; int n, m, K, t, S, T, ans[mm], answer; int dis[mm], pre[mm], Q[mm]; struct network { int tt, la[mn], next[mm], y[mm], f[mm], co[mm]; void clear() { tt = 1; ... |
/* ********************************************************************************************* */
/* * Top Module * */
/* * Authors: * */
/* * André Bannw... |
`timescale 1 ps / 1 ps
module onetswitch_top(
inout [14:0] DDR_addr,
inout [2:0] DDR_ba,
inout DDR_cas_n,
inout DDR_ck_n,
inout DDR_ck_p,
inout DDR_cke,
inout DDR_cs_n,
inout [3:0] DDR_dm,
in... |
//-------------------------------------------------------------------
//-- inv_tb.v Banco de pruebas para el inversor
//-------------------------------------------------------------------
//-- (c) BQ August 2015. Written by Juan Gonzalez
//-------------------------------------------------------------------
//-- GPL LI... |
/*
* 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... |
// (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... |
#include <bits/stdc++.h> using namespace std; int Min = -10000000; int Max = -Min; int A[8] = {1, 1, 0, 0, 1, 1, 1, 1}; int B[8] = {0, 0, 1, 1, 1, 1, -1, -1}; int C[8]; struct Nodes { int x, y; } p[100010]; bool operator<(Nodes &p1, Nodes p2) { if (p1.x == p2.x) return p1.y < p2.y; return ... |
module top();
reg p_clk, rst_in, reg_req_t;
wire out;
weird_ff uut(p_clk, rst_in, reg_req_t, out);
initial begin
p_clk = 0;
rst_in = 1;
reg_req_t = 0;
#1;
rst_in = 0;
#1;
p_clk = 1;
#2;
p_clk = 0;
$display("%d", out);
if (out != 1'bx) begin
$display("FAILED 1 ... |
// (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... |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
module lba
(/*AUTOnotARG*/
// Outputs
);
/* autoinst_bits_lba_gi AUTO_TEMPLATE (
.WWCmdI (WWCmdI[]));
*/
autoinst_bits_lba_gi gi (/*AUTOINST*/
// Outputs
.WWCmdI (WWCmdI[8:0]), // Temp... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int left[n], right[n]; int leftOpen = 0, leftClose = 0, rightOpen = 0, rightClose = 0; for (int i = 0; i < n; i++) { cin >> left[i]; cin >> right[i]; if (left[i]) leftOpen += 1; else ... |
#include <bits/stdc++.h> using namespace std; int n; pair<long long, long long> x[4000]; long long d[4000]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) cin >> x[i].first >> x[i].second; sort(x + 1, x + n + 1); d[n] = x[n].second; for (int i = n - 1; i >= 1; i--) { d[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> using namespace std; int x[1010], y[1010]; int lef(int x1, int y1, int x2, int y2) { if (x1) x1 = (x1 > 0 ? 1 : -1); if (y1) y1 = (y1 > 0 ? 1 : -1); if (x2) x2 = (x2 > 0 ? 1 : -1); if (y2) y2 = (y2 > 0 ? 1 : -1); if (x1 == 0 && y1 == 1) { if (x2 == 1) ret... |
#include <bits/stdc++.h> int main() { char n[10005]; scanf( %[^ n] , n); int len = strlen(n); char temp[len + 1]; int j = 0; for (int i = 0; i < len; i++) { if (n[i] >= a && n[i] <= z ) { temp[j] = n[i]; j++; } else if (n[i] == ) { if (n[i - 1] == )... |
#include <bits/stdc++.h> using namespace std; int main() { int a = 0, b = 0, x = 0, y = 0; cin >> a >> b; x = min(a, b); y = max(a, b); cout << x << << (y - x) / 2 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; long long int check(long long int a) { if (a >= 1000000000 + 7) a %= 1000000000 + 7; return a; } long long int check2(long long int a) { if (a > 0) return a; long long int b = a / 1000000000 + 7; a -= b * 1000000000 + 7; if (a < 0) a += 10000... |
#include <bits/stdc++.h> using namespace std; int pr[2 * 100 * 1000 + 10]; int a[2 * 100 * 1000 + 10]; int main() { int max_n = 0; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > max_n) max_n = a[i]; } for (int i = 0; i <= max_n; i++) pr[i] = 1; for... |
#include <bits/stdc++.h> using namespace std; const int N = 3e3 + 5, mod = 1e9 + 7; struct p { int x, y; } c[N]; int n, D, num; int h[N], w[N]; int f[N][N]; int read() { int x(0); char ch = getchar(); for (; !isdigit(ch); ch = getchar()) ; for (; isdigit(ch); x = x * 10 + ch - ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); int main() { double d, h, v, e; while (scanf( %lf%lf%lf%lf , &d, &h, &v, &e) != EOF) { double t = v / (PI * (d / 2) * (d / 2)); if (t > e) { printf( YES n ); double ti = h / (t - e); printf( %lf 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 law... |
// megafunction wizard: %ROM: 1-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: cx4_datrom.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// =============================... |
/*
* 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 i; double a, b, c, d, base, top, mid, x11, x22, y11, y22, minim1, minim2, maxim1, maxim2; int main() { scanf( %lf%lf%lf%lf , &a, &b, &c, &d); base = 0.0; top = 1000000000.0; for (i = 1; i <= 100; i++) { mid = (base + top) / 2.0; ... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2008 by Wilson Snyder.
module t (
input wire CLK,
output reg RESET
);
neg neg (.clk(CLK));
little little (.clk(CLK));
glbl glbl ();
// A vector
logic [2:... |
#include <bits/stdc++.h> using namespace std; long long nxt(long long x) { long long mn = 10; long long mx = 0; long long xx = x; while (x > 0) { mn = min(mn, x % 10); mx = max(mx, x % 10); x /= 10; } return xx + mn * mx; } signed main() { long long t; cin >> t;... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; vector<int> p; int a[27] = {0}; for (int i = 0; i < s.size(); i++) { if (s[i] == ? ) { p.push_back(i); } else { a[int(s[i]) - 96]++; } } if (p.size() == 0) { co... |
`include "commands.vh"
module communication(
input wire clk,
output reg transmit=0,
output reg [7:0] tx_byte=0,
input wire received,
input wire [7:0] rx_byte,
output reg en=0,
output wire [39:0] m,
output reg set=0,
output reg error=0
);
reg [7:0] state=0;
reg [7:0] command=0;
reg [7:0] m0=0, m1=0, m2=0, m3... |
#include <bits/stdc++.h> using namespace std; int n; vector<vector<pair<int, int>>> g; vector<int> p; vector<bool> was; vector<int> sz; long long res; void calcSz(int v, int par = -1) { sz[v] = 1; for (int i = 0; i < (int)g[v].size(); ++i) { int to = g[v][i].first; if (to != par && !... |
#include <bits/stdc++.h> using namespace std; int dp[128][128][15]; int board[128][128]; int dy[] = {-1, 1}; int N, M, K; int solve(int x, int y, int k) { if (dp[x][y][k] != -2) return dp[x][y][k]; if (x == 0) { if (board[x][y] % K == k) return dp[x][y][k] = board[x][y]; else ... |
#include <bits/stdc++.h> using namespace std; int main() { int a[1000]; int n, k; scanf( %d , &n); scanf( %d , &k); for (int i = 0; i < 2 * n + 1; i++) { scanf( %d , &a[i]); } for (int i = 1; i < 2 * n + 1; i += 2) { if (a[i] - 1 > a[i + 1] && a[i] - 1 > a[i - 1]) { a... |
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& os, vector<T> V) { for (auto v : V) os << v << ; return cout << ; } template <class T> ostream& operator<<(ostream& os, set<T> S) { for (auto s : S) os << s << ; return cout << ; } tem... |
#include <bits/stdc++.h> int r, g, b; int mins; int total; int tour; int cycles; int main() { scanf( %d %d %d , &r, &g, &b); if (r >= 2) { r -= 2; } else if (r == 1) { r -= 1; } mins = 30; tour = 1; total = r + g + b; while (total > 0) { if (tour == 1) { ... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 19:40:21 09/19/2015
// Design Name: figuras_Gato
// Module Name: /home/manzumbado/Development/HDL/Xilinx/GatoTDD/trunk/figuras_test.v
// Project Name: GatoTDD
// Tar... |
// (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 ... |
#include <bits/stdc++.h> using namespace std; int safeop(int n, int mod) { return (n + mod) % mod; } int main() { int n; cin >> n; vector<int> v(n, 0); vector<pair<int, int>> ans(n); for (int i = 0; i < n; i++) { cin >> v[i]; } int vn = n; int v1 = -1; stack<int> bal1; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, l, m, n; cin >> n; if (n & 1) cout << 1 << endl; else cout << 2 << endl; } |
#include <bits/stdc++.h> using namespace std; int n, k, A[2005], DP[2005]; inline int ok(int X) { memset(DP, 0, sizeof(DP)); int i, j; long long l1, r1, l2, r2; for (i = 1; i <= n; i++) DP[i] = i - 1; for (i = 2; i <= n; i++) if (abs(A[i] - A[i - 1]) <= X) DP[i] = 0; else ... |
#include <bits/stdc++.h> using namespace std; long long n, mod; pair<long long, long long> a[200100]; long long d[200100]; long long first(int t, int k) { long long res = 1; for (int i = 1; i <= k; i++) d[i] = i; for (int j = 2; t;) if (d[j] % 2) j += 2; else while (d[j... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } bo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; while (scanf( %d%d , &n, &m) != EOF) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (i % 2 == 0) { printf( # ); } else { if (i / 2 % 2 == 0 && j == m - 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 la... |
// (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; set<string> f; int main() { int n; cin >> n; int ans = 0; for (int i = 0; i < n; ++i) { string s = ; while (1) { char c; cin >> c; if (isdigit(c)) s += c; if (((int)(s).size()) == 4) break; } sw... |
// (C) 2001-2013 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... |
/**
* 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> const int INF = 0x3f3f3f3f; const int maxn = 1e5 + 5; const int mod = 1e9 + 7; const double eps = 1e-7; using namespace std; long long ans, n, s, a[maxn], b[maxn], num1, num2; priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, k; pair<int, int> a[N]; long long b, s; int main() { cin >> n >> k; cin >> b; for (int i = 1; i <= n; i++) { scanf( %d , &a[i].first); a[i].second = i; } sort(a + 1, a + n, greater<pair<int, int> >());... |
#include <bits/stdc++.h> using namespace std; int main() { long int t; cin >> t; while (t--) { long long int a, b, c, d; cin >> a >> b; if (a % b == 0) cout << 0 << endl; else if (b > a) cout << (b - a) << endl; else { c = a / b; c++; ... |
//
// Copyright 2011, Kevin Lindsey
// See LICENSE file for licensing information
//
// Based on code from Richard Haskell and Darrin Hanna's,
// "Learning by Example Using Verilog: Basic Digital Design", 2008
// Chapter 5, Example 15, 7-Segment Displays
//
module hex_7_segment(
input wire [15:0] x,
input wire clk,
... |
/**
* 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> int main() { int tc; std::cin >> tc; while (tc--) { int64_t a, b, c; std::cin >> a >> b >> c; std::cout << a + b + c - 1 << std::endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int S; cin >> S; if (S == 1) { cout << 1 << << 1 << n ; cout << 1 << n ; return 0; } cout << (S - 1) * 2 << << 2 << n ; cout << 1 << << 2; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i]; int maxCap = b[0], curCap = b[0]; for (int i = 1; i < n; ++i) { curCap = curCap ... |
module memory_tb;
// Constants
parameter data_width = 32;
parameter address_width = 32;
parameter depth = ;
parameter bytes_in_word = 4-1; // -1 for 0 based indexed
parameter bits_in_bytes = 8-1; // -1 for 0 based indexed
parameter BYTE = 8;
parameter start_addr = 32'h80020000;
// Input Ports
reg clock;
reg [address_... |
#include <bits/stdc++.h> using namespace std; template <typename T> using V = vector<T>; const long long mod = 1000000007; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string s; V<V<size_t> > p[2]; p[0].resize(8); p[1].resize(8); for (__typeof(8) i = (0) - ((0) ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 22:18:04 03/09/2015
// Design Name:
// Module Name: Instruction_Memory
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependenc... |
#include <bits/stdc++.h> using namespace std; const long long SIZE = (long long)1e6 + 50; const long long NUM = 15; const long long TOT = 5; const long long SUM = (long long)1e2 + 50; const long long inf = (long long)1e18 + 50; inline long long read() { long long x = 0, f = 1; char ch = getchar();... |
#include <bits/stdc++.h> using namespace std; const long double epsilon = 1e-9; int main() { int n; cin >> n; vector<int> a(n), b(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; vector<pair<int, int> > moves; for (int i = 0; i < n; i++) { if ... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: dcfifo
// ============================================================
// File Name: IPfifo.v
// Megafunction Name(s):
// dcfifo
//
// Simulation Library Files(s):
// altera_mf
// ================================================... |
#include <bits/stdc++.h> using namespace std; int a[100000]; bool b[100000]; int c[3][100000 / 3]; int main() { int n; while (cin >> n) { memset(a, 0, sizeof(a)); memset(b, true, sizeof(b)); bool flag = true; int sum1 = 0; int sum2, sum3; sum2 = sum3 = 0; for ... |
#include <bits/stdc++.h> int m, n, W, i, j, k, a[555555], b[555555], c[555555]; long long w[555555], rs; double rq; void solve(int l, int r, long long x) { if (l == r) { rs += (x * c[b[l]]) / w[b[l]]; rq += double((x * c[b[l]]) % w[b[l]]) / w[b[l]]; return; } int i = l, j = r, k, 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... |
/*
* Copyright (c) Atomic Rules LLC, Auburn NH., 2009-2010
*
* Atomic Rules LLC
* 287 Chester Road
* Auburn, NH 03032
* United States of America
* Telephone
*
* This file is part of OpenCPI (www.opencpi.org).
* ____ __________ ____
* / __ \____ ___ ____ / ____... |
#include <bits/stdc++.h> using namespace std; long long n, a[100005], b[100005], fa[100005], s[100005], q[100005], l, p = -2147483647; inline long long find(long long x) { if (x == fa[x]) return x; return fa[x] = find(fa[x]); } inline long long M(long long u, long long v) { return u > v ? u : v;... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 1e5 + 5; int main() { int n, f[MaxN], cnt[MaxN], mm = 0, ans = 0; scanf( %d , &n); memset(f, 0, sizeof(f)); memset(cnt, 0, sizeof(cnt)); for (int i = 1; i <= n; i++) { int a; scanf( %d , &a); cnt[f[a]]--; f[... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 17:42:36 12/10/2012
// Design Name: top
// Module Name: C:/Documents and Settings/SPItoUART_Loopback/tb.v
// Project Name: SPItoUART_Loopback
// Target Device:
// ... |
#include <bits/stdc++.h> using namespace std; const long long infll = powl(2, 62) - 1; const long long mod = pow(10, 9) + 7; int64_t extGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) { if (!a) { x = 0; y = 1; return b; } int64_t x1, y1; int64_t d = extGcd(b % a, a, x1, y1); ... |
#include <bits/stdc++.h> const long long LLINF = 0x3f3f3f3f3f3f3f3f; using namespace std; class otr { public: long long len = 0; long long* D = nullptr; otr(long long alen) { len = alen; D = new long long[alen]; } ~otr() { delete[] D; } }; void Flip(long long* left, long lon... |
//
// Copyright 2011 Ettus Research LLC
//
// 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 option) any later version.
//
// This program is dis... |
#include <bits/stdc++.h> using namespace std; int n, m; long long a[200000], b[200000]; bool ok(long long x) { int p(1); long long q(0); for (int i = 1; i <= (m); ++i) if (b[i] > q) { while (p <= n && a[p] + x < b[i]) ++p; if (a[p] - x > b[i] || p > n) return false; if ... |
#include <bits/stdc++.h> using namespace std; int main() { bool flag = false; int n, boro; cin >> n; int a[n], b[n]; for (int i = 0; i < n; i++) cin >> a[i] >> b[i]; for (int i = 0; i < 1; i++) { boro = max(a[i], b[i]); } for (int i = 1; i < n; i++) { if (max(a[i], b[i]) ... |
//
// Copyright 2011 Ettus Research LLC
//
// 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 option) any later version.
//
// This program is dis... |
#include <bits/stdc++.h> using namespace std; int main() { long long int s, x; cin >> s >> x; long long int i, c = 1, f = 0; long long int a = (s - x) / 2; if ((s - x) % 2 != 0) cout << 0; else { for (i = 0; i < 64; i++) { long long int x1 = ((x >> i) & 1); long l... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, , ); ... |
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void solve() { int n, m; cin >> n >> m; map<vector<int>, int> tiles; for (int i = 0; i < n; i++) { vector<int> temp; for (int j = 0; j < 4; 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 la... |
//Legal Notice: (C)2016 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; int main(int argc, char** argv) { long long r, x1, y1, x2, y2; while (cin >> r >> x1 >> y1 >> x2 >> y2) { double dis = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + 0.0); cout << ceil(dis / 2 / r) << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; namespace io { const int SI = 1 << 21 | 1; char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100]; int f, t; inline void flush() { fwrite(OB, 1, OS - OB, stdout), OS = OB; } inline void pc(char x) { *OS++ = x; if (OS == OT) flush(); }... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int n, x, y; cin >> n >> x >> y; long long int maxi = x + y - 2 + 1; maxi = min(maxi, n); long long int mini = x + y - n; if (mini <= 0) mini = 1; else ... |
module adv3224 (
// avalon-bus
input clk,
input reset,
input avs_slave_write,
input avs_slave_read,
input [7:0]avs_slave_writedata,
output [7:0]avs_slave_readdata,
input [2:0]avs_slave_address,
// adv3224
output cps_reset_n,
output cps_ce_n,
outp... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) { cout << 1 1 << endl << 1 ; return 0; } cout << 5 * (n - 1) << << 2 << endl << 1 5 ; } |
/*
* NAME
* ----
*
* main.v - SPI slave, switch input, LED display
*
* DESCRIPTION
* -----------
*
* This module takes input from input switches (in_sw) and
* outputs them over the SPI (MISO pin).
* And the input it receives over the SPI is written to the
* external LEDs (led_ext).
*
* The following SPI... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int a, b, c, d, e; cin >> a >> b >> c >> d >> e; int f[5] = {a, b, c, d, e}, mn = a + b + c + d + e, ans = a + b + c + d + e; sort(f, f + 5); map<int, int> mp; fo... |
/**
* 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.