text stringlengths 59 71.4k |
|---|
/**
* 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 long long mod = 1000000000 + 9; long long pow(long long a, int n, long long mod) { long long res = 1; while (n) { if (n % 2) { res *= a; res %= mod; --n; } else { a *= a; a %= mod; n /= 2; ... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
#include <bits/stdc++.h> using namespace std; inline int read() { int f = 1, r = 0; char ch = getchar(); while (!isdigit(ch)) f ^= ch == - , ch = getchar(); while (isdigit(ch)) r = (r << 1) + (r << 3) + (ch ^ 48), ch = getchar(); return f ? r : -r; } const int N = 3005, M = 305; int n, m,... |
`timescale 1ns / 1ps
/*
* Copyright 2015 Forest Crossman
*
* 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 appl... |
//==================================================================================================
// Filename : subRecursiveKOA.v
// Created On : 2016-10-27 23:29:14
// Last Modified : 2016-10-28 00:15:22
// Revision :
// Author : Jorge Esteban Sequeira Rojas
// Company : Instituto T... |
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2015.4 (win64) Build Wed Nov 18 09:43:45 MST 2015
// Date : Fri Mar 04 11:10:30 2016
// Host : Dries007Laptop running 64-bit major release... |
// 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 Apr 09 08:26:59 2017
// Host : GILAMONSTER running 64-bit major release (... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) scanf( %d , &a[i]); string s; cin >> s; int c1[n], c2[n]; c2[0] = a[0]; if (s[0] == 1 ) c1[0] = a[0]; else c1[0] = 0; for (int i = 1; i < n; i++)... |
// megafunction wizard: %altdll%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: ALTDLL
// ============================================================
// File Name: ddr3_s4_uniphy_example_sim_ddr3_s4_uniphy_example_sim_e0_if0_p0_dll_memphy.v
// Megafunction Name(s):
// ALTDLL
//
// Simulation Library Files(s... |
#include <bits/stdc++.h> using namespace std; const int N = int(2e6); int n; bool used[N + 7]; int main() { cin >> n; for (int i = 2; i * i <= N; ++i) { if (!used[i]) { for (int z = i * i; z <= N; z = z + i) used[z] = true; } } int cnt = 0; for (int i = 2; i <= N; ++i) ... |
/*******************************************************************************
* This file is owned and controlled by Xilinx and must be used solely *
* for design, simulation, implementation and creation of design files *
* limited to Xilinx devices or technologies. Use with non-Xilinx ... |
//-----------------------------------------------------------------------------
//
// (c) Copyright 2010-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
... |
//altpll bandwidth_type="AUTO" CBX_DECLARE_ALL_CONNECTED_PORTS="OFF" clk0_divide_by=25 clk0_duty_cycle=50 clk0_multiply_by=1 clk0_phase_shift="0" compensate_clock="CLK0" device_family="Cyclone IV E" inclk0_input_frequency=20000 intended_device_family="Cyclone IV E" lpm_hint="CBX_MODULE_PREFIX=ADC_PLL" operation_mode="n... |
module wiggle (osc, rstn, led, gpio, perstn, refclkp, refclkn, hdinp0, hdinn0, hdoutp0, hdoutn0);
input osc, rstn;
output [7:0] led;
output [23:0] gpio;
input perstn, refclkp, refclkn, hdinp0, hdinn0;
output hdoutp0, hdoutn0;
reg [23:0] count;
reg [7:0] sreg;
reg shift;
wire rstn;
wire clk;
wire [7:0] led;
wire [23:... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200100; int main() { int n = 0, u = 0, v = 0; int d[MAXN] = {0}; scanf( %d , &n); for (int i = 0; i < n - 1; i++) { scanf( %d %d , &u, &v); d[u] += 1; d[v] += 1; } for (int i = 1; i <= n; i++) { if (d[i]... |
#include <bits/stdc++.h> #pragma GCC target( avx ) #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) using namespace std; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { long long A, B, C, D, E, F, N, K, M, Z, sum = 0, num = 0, flag = 0; string S, T; cin >> Z; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n; cin >> m; cin >> k; bool done = false; int num = 0; int lanes = 0; int desks = 0; int d = 0; while (num < k) { desks = 0; done = false; num += 2 * m; lanes++; while... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) const int N = 2e5 + 3; const int MOD = 998244353; int max1 = 0, max2 = 0; void solve() { long long int a[3]; cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); cout << (a[0] + a[1] + mi... |
//**************************************************************************
// ph_reg3.v - 2 byte FIFO for 16b transfers in parasite to host direction
//
// COPYRIGHT 2019 David Banks, Richard Evans, Ed Spittles
//
// This file is part of tube - an Acorn Tube ULA compatible system.
//
// tube is free softw... |
#include <bits/stdc++.h> using namespace std; int N, dp[100005][3], MOD = 1000000007; char s[2][100005]; long long ans = 1; int main() { scanf( %d%s%s , &N, s[0], s[1]); for (int i = 0; i < N; ++i) { if (s[0][i] == ? ) ans = (((ans * 10) % (MOD) + (MOD)) % (MOD)); if (s[1][i] == ? ) ans ... |
#include <bits/stdc++.h> using namespace std; const long long I1 = 1e9; const long long I2 = 1e18; const int32_t M1 = 1e9 + 7; const int32_t M2 = 998244353; template <typename T, typename T1> T maxn(T &a, T1 b) { if (b > a) a = b; return a; } template <typename T, typename T1> T minn(T &a, T... |
#include <bits/stdc++.h> using namespace std; int T; priority_queue<int, vector<int>, greater<int> > q; vector<int> g[1000005]; int main() { scanf( %d , &T); int n; long long int ans; while (T--) { ans = 0; scanf( %d , &n); int x, y; for (int i = 1; i <= n; i++) { ... |
//-----------------------------------------------------------------------------
//
// (c) Copyright 2010-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
... |
/*
* 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; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } template <class T> o... |
#include <bits/stdc++.h> using namespace std; vector<int> A[7], B[100005]; int n, a[5005], f[5005][5005], ans; int main() { int i, j, u, v, w, p, q, r; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &a[i]); for (i = n; i >= 1; i--) { A[a[i] % 7].push_back(i); B[a[i]].push_back... |
#include <bits/stdc++.h> double ans, f[10][1000]; int n, k, a, v[10], p[10], g[10], ki[10], l[10]; void calc() { int b = a; for (int i = 1; i <= n; ++i) { l[i] = p[i] + g[i]; if (l[i] > 100) l[i] = 100; } f[0][0] = 1; for (int i = 1; i <= n; ++i) for (int j = 0; j <= (1 << i ... |
/*
File: ewrapper_io_rx_slow.v
This file is part of the Parallella Project .
Copyright (C) 2013 Adapteva, Inc.
Contributed by Roman Trogan <>
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 Foun... |
// 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 13 12:44:11 2017
// Host : WK117 running 64-bit major release (build ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int res = -1; for (int i = 1; i < s.size(); i++) { for (int j = 1; i + j < s.size(); j++) { int p1; string P1 = s.substr(0, i); if (P1.size() > 1 && P1[0] == 0 ) p1 = -1; e... |
// (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 2011(c) Analog Devices, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// a... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 10:09:45 05/22/2014
// Design Name:
// Module Name: pipeemreg
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
... |
#include <bits/stdc++.h> using namespace std; string a, b; int rs, p; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> a >> b; if (a.size() != b.size()) return cout << NO , 0; for (int i = 0; i < a.size(); i++) if (a[i] != b[i]) rs++, p = i; if (rs !=... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 12, INF = 1e9 + 7; int a[N]; int main() { int n, m, i, j, k; scanf( %d , &(n)); ; vector<int> dp; dp.push_back(-100001); for (i = 0; i < (n); ++i) { dp.push_back(100001); scanf( %d , &(a[i])); ; } ... |
#include <bits/stdc++.h> using namespace std; int N, Q; vector<vector<int> > ad; vector<int> val, par; void fun(int c, int p) { par[c] = p; int i; for (i = 0; i < ad[c].size(); i++) { if (ad[c][i] != p) fun(ad[c][i], c); } } int gcd(int a, int b) { if (b == 0) return a; retur... |
module emesh_mux (/*AUTOARG*/
// Outputs
ready_out, access_out, packet_out,
// Inputs
access_in, packet_in, ready_in
);
//#####################################################################
//# PARAMETERS
//#####################################################################
parameter ... |
#include<bits/stdc++.h> using namespace std; #define show(x) cout<< #x << = << x << n ; #define mod 998244353 #define INF 1000000000000000000 #define pie 3.14159265358979323846 #define ll long long int #define pb push_back #define popcnt __builtin_popcount #define mp make_pair #define pii ... |
#include <bits/stdc++.h> using namespace std; int INF = 1000 * 1000 * 1000; vector<vector<pair<int, int>>> adj; int mem[80][80][80][80]; int dp(int cur, int closestLeft, int closestRight, int remainingMoves) { if (remainingMoves == 0) return 0; if (mem[cur][closestLeft][closestRight][remainingMoves] !... |
// -------------------------------------------------------------
//
// Generated Architecture Declaration for rtl of ent_a
//
// Generated
// by: wig
// on: Thu Oct 13 08:24:14 2005
// cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl -nodelta ../../intra.xls
//
// !!! Do not edit this file! Autogenerated by MIX !!!
// $... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2016/06/30 16:32:25
// Design Name:
// Module Name: uart_rx
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revis... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int inf = 0x3f3f3f3f; int b[maxn]; int a[maxn]; int ma[maxn]; int pre[maxn * 10]; int _find(int x) { return x == pre[x] ? x : pre[x] = _find(pre[x]); } void _union(int x, int y) { x = _find(x), y = _find(y); if (x < ... |
#include <bits/stdc++.h> using namespace std; template <class T, size_t... Is> struct arr_helper; template <class T, size_t... Is> using arr = typename arr_helper<T, Is...>::type; template <class T> struct arr_helper<T> { using type = T; }; template <class T, size_t I, size_t... Is> struct arr_h... |
/*******************************************************************************
* This file is owned and controlled by Xilinx and must be used solely *
* for design, simulation, implementation and creation of design files *
* limited to Xilinx devices or technologies. Use with non-Xilinx ... |
#include <bits/stdc++.h> int main() { int t; scanf( %d , &t); int a, b, c, d, k, x, y; while (t--) { scanf( %d %d %d %d %d , &a, &b, &c, &d, &k); if (a % c == 0) { x = a / c; } else { x = a / c + 1; } if (b % d == 0) { y = b / d; } 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> const int mod = 1000000007; const int gmod = 3; const int inf = 1039074182; const double eps = 1e-9; const long long llinf = 2LL * inf * inf; template <typename T1, typename T2> inline void chmin(T1 &x, T2 b) { if (b < x) x = b; } template <typename T1, typename T2> inli... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long int ans = 1000000000000, n, m, i, d, j, a, fo = 0; vector<long long int> v; set<long long int> mset; cin >> n >> m >> d; for (i = 0; i < n; i++) { fo... |
#include <bits/stdc++.h> using namespace std; int matrix[101][101]; struct HATE { int t, r, c, x; HATE(int t, int r, int c, int x) { this->t = t; this->r = r; this->c = c; this->x = x; } }; HATE* hates[10001]; int main() { int n, m, q; cin >> n >> m >> q; for ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; const int mod = 1e9 + 7; vector<int> G[maxn]; char s[maxn]; int vis[maxn]; map<string, int> mp; long long a[maxn], n, L, R, t; void solve1() { L = 0, R = n; for (int i = 0; i <= n - 2; i++) { if (s[i] == < ) ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 300000; long long n, x[Maxn], w[Maxn], Index[Maxn], nx[Maxn]; set<pair<long long, long long> > poi, xx; set<pair<long long, long long> > u; void input() { cin >> n; for (int i = 0; i < n; i++) { cin >> x[i] >> w[i]; xx.insert... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[105]; for (int i = 0; i < n; i++) { cin >> a[i]; } a[n] = a[0]; int k; int minn = 10005; for (int i = 1; i <= n; i++) { if (abs(a[i] - a[i - 1]) < minn) { minn = abs(a[i] - a[i -... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) using namespace std; using ll = long long; using vll = int64_t; const int N = 1e6 + 1; vector<int> adj[N]; vector<bool> vis(N, false); vector<short> col(N, -1); inline bool b... |
#include <bits/stdc++.h> using namespace std; int x[1005], y[1005], r[1005], level[1005]; long long sum[1005]; vector<pair<int, int> > X[1005]; void dfs(int node, int l) { level[node] = l; int i; for (i = 0; i < X[node].size(); i++) { if (level[X[node][i].second] <= level[node]) dfs(X[node][... |
#include <bits/stdc++.h> using namespace std; template <class T> long long ToInt(const T &x) { stringstream s; s << x; long long r; s >> r; return r; } template <class T> string ToString(const T &x) { stringstream s; s << x; return s.str(); } int main() { string str, ... |
module RAMB16_S1_S1(
input WEA,
input ENA,
input SSRA,
input CLKA,
input [13:0] ADDRA,
input [0:0] DIA,
// input DIPA,
// output [3:0] DOPA,
output [0:0] DOA,
input WEB,
input ENB,
input SSRB,
input CLKB,
input [13:0] ADDRB,
input [0:0] DIB,
// input DIPB,
// output [3:0] DOPB,
output [0... |
#include <bits/stdc++.h> using namespace std; int n, dir[200005]; long long cnt, le; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &dir[i]); if (dir[i] == 0) le++; } for (int i = 0; i < n; i++) { if (dir[i] == 1) cnt += le; else l... |
#include <bits/stdc++.h> const int mod = 998244353; using namespace std; int a[200010], b[200010]; void solve() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int x; for (int i = 1; i <= n; i++) cin >> x, b[i] = a[i] - x; sort(b + 1, b + n + 1); long long ans = 0; f... |
/**
* 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... |
/*******************************************************************************
* This file is owned and controlled by Xilinx and must be used solely *
* for design, simulation, implementation and creation of design files *
* limited to Xilinx devices or technologies. Use with non-Xilinx ... |
/**
* 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 2018 Nuclei System Technology, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except 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 N_MAX = 600007; std::map<std::pair<int, int>, int> ext; long long ans[N_MAX], now; int fa[N_MAX], siz[N_MAX][2], top; std::pair<int, int> stk[N_MAX]; int find(int x) { while (fa[x] != x) x = fa[x]; return x; } void merge(std::pair<int, int> v) { int x = fin... |
#include <bits/stdc++.h> using namespace std; template <class T, class L> bool smax(T& x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> bool smin(T& x, L y) { return x > y ? (x = y, 1) : 0; } const int maxn = 2e5 + 17; int n, m, gp[maxn], rate[maxn], cnt, sz[maxn]; unor... |
#include <bits/stdc++.h> using namespace std; const int mn = 200005; const int mod = 1e9 + 7; int n, m; unordered_set<int> h[mn]; priority_queue<pair<int, int> > q; int sum = 0; int maxi, mini; vector<tuple<int, int, int> > ans; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, z; cin >> x >> y >> z; if (abs(x - y) > z) { if (x > y) { cout << + n ; } else { cout << - n ; } } else { if (abs(x - y) == 0 && z == 0) { cout << 0 n ; } else { cout... |
/*
Copyright (c) 2015-2018 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, distri... |
/*
* 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; inline int sn() { int n = 0; int ch = getchar(); while (ch < 48) ch = getchar(); while (ch > 47) n = (n << 3) + (n << 1) + ch - 0 , ch = getchar(); return n; } double dp[2005][2005]; int main() { int i, j, n, t; double p; scanf( %d... |
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = RDLU ; long long ln, lk, lm; void etp(bool f = 0) { puts(f ? YES : NO ); exit(0); } void addmod(int& x, int y, int mod = 1000000007) { x += y; ... |
// megafunction wizard: %ROM: 1-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: CHARMAP.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; const int N = 5005; int a[N]; int main() { int n, m; scanf( %d%d , &n, &m); int tot = 0; for (int i = 1; i <= n; i++) { if (m < (i - 1) / 2) break; a[++tot] = i; m -= (i - 1) / 2; } if (!m) { int cnt = 1e8; for (... |
#include <bits/stdc++.h> using namespace std; bool F = true; long long sum = 0; void DFS(int v, int par, vector<vector<int>> &g, vector<long long> &s, vector<long long> &a) { if (s[v] == -1) { if (g[v].size() == 0) return; long long m = 2e9; for (int u : g[v]) m = min(s[u], m); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long b, d, s, res = 0; cin >> b; cin >> d; cin >> s; long long val = max(b, max(d, s)) - 1; if (val > b) res += val - b; if (val > d) res += val - d; if (val > s) res += val - s; cout << res; } |
#include <bits/stdc++.h> using namespace std; pair<int, int> s[100010]; int a[100010], b[100010]; int main() { int N, P, i, x; scanf( %d n , &N); for (i = 0; i < N; i++) { scanf( %d , &x); s[i] = make_pair(x, i); } sort(s, s + N); P = N / 3; for (i = 0; i < P; 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 la... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 55; int n, m, dp[MAX_N][MAX_N][MAX_N][MAX_N]; char a[MAX_N][MAX_N]; int dfs(int x1, int y1, int x2, int y2) { if (dp[x1][y1][x2][y2] >= 0) { return dp[x1][y1][x2][y2]; } if (x1 == x2 && y1 == y2) { return dp[x1][y1][x2][y2... |
/**
* 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 1 ps / 1 ps
//-----------------------------------------------------------------------------
// Title : PCI Express LTSSM monitor
// Project : PCI Express MegaCore function
//-----------------------------------------------------------------------------
// File : altpcietb_pipe_phy.v
// ... |
/******************************************************************************
* License Agreement *
* *
* Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. *
... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; long long int sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += 1ll * a[i]; } long long int m = ceil(sum / 2); long long... |
#include <bits/stdc++.h> using namespace std; long long num[30], pre[100010], cnt; int main() { int n, l, lr, ll; char s[100010]; cin >> n; for (int i = 0; i < n; i++) { cin >> s + 1; l = strlen(s + 1); for (int j = 0; j < 26; j++) if (num[j] && j + a != s[1] && j + a ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int n, h; cin >> n >> h; bool flag; for (int k = 0; k < n; k++) { flag = false; for (int j = 0; j < n; j++) { if (flag) cout << ; flag = true; if (j == k) cout << h; ... |
module CPU(reset, clk);
input reset, clk;
// PC.
reg [31:0] PC;
wire [31:0] PC_next;
always @(posedge reset or posedge clk)
if (reset)
PC <= 32'h00000000;
else
PC <= PC_next;
wire [31:0] PC_plus_4;
assign PC_plus_4 = PC + 32'd4;
// Read instruction.
wire [31:0] Instruction;
InstructionMemory i... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, t; cin >> n >> k >> t; if (t <= k) cout << t << endl; else if (t > k && t <= n) cout << k << endl; else cout << k - (t - n) << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n = 0, cc = 0, cn = 0, ic = 0, in1 = 0; int pr; cin >> n; for (int i = 1; i <= n; i++) { cin >> pr; if (pr % 2 == 1) { cn++; in1 = i; } else { cc++; ic = i; } } int answer =... |
/* This file is part of JT12.
JT12 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.
JT12 program is distribut... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000005; int T, n, m, las = 1, ndnum = 1, ans; char s[maxn]; struct node { int ch[26], len, fa; } d[maxn << 1]; int siz[maxn << 1], vis[maxn << 1], timer; int head[maxn << 1], tot; struct edge { int nxt, to; } e[maxn << 1]; voi... |
#include <bits/stdc++.h> using namespace std; int main(void) { double d, l, v1, v2; cin >> d >> l >> v1 >> v2; printf( %.10lf , double((l - d) / (v1 + v2))); return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m, c, l, r, cp, cm; string s; int main() { cin >> n >> s; for (int i = 0; i < n; i++) { l = i - 1; r = i; cp = 1; cm = 1; while (l >= 0 && s[l] != L ) { cp += (s[l] == R ); l--; } while (r < ... |
#include <bits/stdc++.h> using namespace std; #define inf 1e15 #define mod 1000000007 #define N 100001 #define ll long long int #define vint vector<int> #define vll vector<ll> #define vstr vector<string> #define vvint vector<... |
#include <bits/stdc++.h> int main() { int n, i, a = 0; scanf( %d , &n); for (i = n; i > a; i--) { if (n % i == 0) { printf( %d , i); n = i; } } return 0; } |
// nios_tester_jtagdebug.v
// This file was auto-generated from altera_msgdma_hw.tcl. If you edit it your changes
// will probably be lost.
//
// Generated using ACDS version 18.1 625
`timescale 1 ps / 1 ps
module nios_tester_jtagdebug (
output wire [25:0] mm_write_address, // mm_write.addres... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2011 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
// bug420
typedef logic [7-1:0] wb_ind_t;
typedef logic [7-1:0] id_t;
module t (/*AUTOARG*/
// Inputs
... |
/*
* 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.