text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7, abc = 864197532, N = 1000001, logN = 17; vector<int> a; vector<int> d, lp; struct Seg { int l, r, m; long long int val = 0; Seg* ch[2]; Seg(int _l, int _r) : l(_l), r(_r), m(l + r >> 1) { if (r - l > 1) { ch[0...
module autoinst_vertrees_slv (/*AUTOARG*/ // Outputs i2c_mst_data, i2c_read, i2c_slv_scl_out, i2c_slv_sda_out, i2c_spc_scl_state, i2c_start, i2c_strobe, slv_bit_st, slv_put, i2c_spc_scl_fall, i2c_spc_sda_state, i2c_spc_start, i2c_spc_stop, // Inputs ck_ref, i2c_slv_data, i2c_slv_scl_in, i2c_slv_sda...
// (C) 2001-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 doc...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000000 + 7; const long long int N = 1000000 + 6; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int tc; tc = 1; while (tc--) { long long int n, m; cin >> n >> m; st...
#include <bits/stdc++.h> using namespace std; priority_queue<pair<int, char> > pr; bool is_prime(int n) { if (n == 1) return 0; for (int i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; } vector<int> prime, pos[1004]; map<int, int> mark, mark2; map<int, int>::iterator it; bo...
/** * 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...
/* * 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; vector<long long> v[100001]; int main() { int n; cin >> n; for (long long i = 1; i < n; i++) { long long a, b; cin >> a >> b; v[a].push_back(b); v[b].push_back(a); } for (long long i = 1; i <= n; i++) { if (v[i].size()...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_io_cmos_pad.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...
/* * 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; string LexicographicallyMaximumSubsequence(string text) { string localMax = ; char current = text.at(text.length() - 1); localMax += current; unsigned int size = text.length() - 2; for (int i = size; i >= 0; i--) { if (text.at(i) >= current) ...
#include <bits/stdc++.h> using namespace std; template <typename X> inline X abs(const X& a) { return a < 0 ? -a : a; } template <typename X> inline X sqr(const X& a) { return a * a; } long long combine(long long n, int k) { long long ans = 1; for (int i = 0; i < k; i++) ans = (ans * (n ...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; const long long SZ = 1010, SSZ = 100010, APB = 26, one = 93, INF = 0x3f3f3f3f3f3f3f3f, mod = 1000000007; long long n, m, bg, fn, cnt; long long to[SSZ], wt[SSZ], head[SZ]; long long nex[SSZ], mk[SSZ]; long long dfn[SZ...
#include <bits/stdc++.h> const int G[8][2] = {{0, 4}, {1, 5}, {2, 6}, {3, 7}, {0, 2}, {1, 6}, {3, 4}, {5, 7}}; int f[(1 << 8)], g[1111]; int max(int a, int b) { return a > b ? a : b; } int min(int a, int b) { return a < b ? a : b; } int main() { int n; int i, j, k, _; f[0] =...
////////////////////////////////////////////////////////////////// //// //// //// CRCAHB CORE BLOCK //// //// //// //// This file is part of the APB to I2C project //// //// http://www.opencores.org/cores/apbi2c/ //// //// //// //// Description //// //// Implementation of APB IP core according to //// ...
/* ########################################################################### # **EMMU** # # This block uses the upper 12 bits [31:20] of a memory address as an index # to read an entry from a table. # # The table is written from the mi_* configuration interface. # # The table can be configured as 12 bits wi...
#include <bits/stdc++.h> using namespace std; int r1, c1, r2, c2; int rook(int r1, int c1, int r2, int c2) { if (r1 == r2 || c1 == c2) { return 1; } else { return 2; } } int bishop(int r1, int c1, int r2, int c2) { if ((r1 + c1) % 2 == 0 && (r2 + c2) % 2 != 0) return 0; if ((r1...
#include <bits/stdc++.h> using namespace std; bool vis[12][12][12]; int ans2(int x, int y, int z, char a[12][12][12], int k, int n, int m) { int cnt = 0; if (a[x][y][z] == # || vis[x][y][z]) return 0; cnt++; vis[x][y][z] = true; if (x > 1) cnt += ans2(x - 1, y, z, a, k, n, m); if (x < k)...
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n >> a >> b; int cnt = 0; for (int i = 1; i < n + 1; i++) { if (i <= b + 1 && (n - i) >= a) cnt++; } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; mt19937 rnd(51); signed main() { ios::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; vector<long long> a(n); for (long long i = 0; i < n; i++) { cin >> a[i]; } deque<pair<long long, long long>> q; for (long long i = 0;...
// (C) 2001-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 doc...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; const int Z = int(1e5 + 1); const int inf = int(2e9 + 1); const ll llinf = ll(2e18 + 1); const ll mod = ll(1e9 + 7); int main() { ios_base::sync_with_st...
#include <bits/stdc++.h> using namespace std; int n, Max, reg; int TIME = 0; vector<int> T, W; bool used[1010]; int p[1010], dmg[1010]; int main() { int i, j, k, l, x, y; cin >> n >> Max >> reg; for (i = 0; i < n; ++i) cin >> p[i] >> dmg[i]; int ch = Max, cd = 0; while (1) { ch -...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
#include <bits/stdc++.h> using namespace std; bool check(vector<long long> a, long long m, long long n) { vector<long long> v(n + 1, 0); for (long long i = 0; i < n; i++) { v[a[i]] += 1; } set<pair<long long, long long>, greater<pair<long long, long long>>> s; for (long long i = 1; i < n +...
`begin_keywords "1364-2005" `timescale 1ns/100ps module top; parameter pdly = 1.2; real rdly = 1.3; integer idly = 1; reg in = 1'b0; wire gi, gf, gs, gt; wire #idly int = in; wire #1.1 first = in; wire #pdly second = in; wire #rdly third = in; buf #idly (gi, in); buf #1.1 (gf, in); buf #pdly ...
#include <bits/stdc++.h> using namespace std; template <typename T> T nextInt() { T x = 0, p = 1; char ch; do { ch = getchar(); } while (ch <= ); if (ch == - ) { p = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + (ch - 0 ); ch = g...
/* * 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 n; long long a[305], Lcm; long long sol(long long x) { long long cnt = 0; for (long long i = 2; i * i <= x; i++) { if (x % i == 0) { cnt += 2; if (i * i == x) cnt--; } } return cnt; } int main() { int T; ci...
/** * 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 = 100010; string nick[MAX]; int ara[MAX], ord[MAX], b[MAX]; int save[MAX]; bool cmp(int a, int b) { if (ara[a] == ara[b]) return nick[a] < nick[b]; return ara[a] > ara[b]; } deque<int> D; int main() { ios_base::sync_with_stdio(fal...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const double PI = 3.14159265359; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> facts; for (int i = 1; i * i <= n; i++) { if (!(n % i)) { facts.push_back(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 inf = 2000000000; const long long infLL = 9000000000000000000; template <typename first, typename second> ostream& operator<<(ostream& os, const pair<first, second>& p) { return os << ( << p.first << , << p.second << ) ; } template <typenam...
/* * * Copyright (c) 2011-2013 * * * * 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 distributed in...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x = 0, xi = INT_MIN, q = 0; vector<int> v; for (int i = 0; i < n; i++) { int y; cin >> y; q = x; v.push_back(y); xi = max(x, v[i]); if (x != q) x = i; } long long ans = 0; ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long mod = 2e18) { long long ans = 1; x %= mod; while (y) { if (y & 1) ans = (x * ans) % mod; x = (x * x) % mod; y >>= 1; } return ans; } signed main() { ios::sync_with_stdio(0)...
// chris_slave.v // This file was auto-generated as a prototype implementation of a module // created in component editor. It ties off all outputs to ground and // ignores all inputs. It needs to be edited to make it do something // useful. // // This file will not be automatically regenerated. You should check it...
//----------------------------------------------------------------------------- // // (c) Copyright 2009-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 (c) 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, distribute,...
#include <bits/stdc++.h> using namespace std; int dp[111111]; int main() { int n, m; cin >> n >> m; vector<int> a; for (int i = 0; i < n; i++) { int x; cin >> x; a.push_back(x); } reverse(a.begin(), a.end()); set<int> b; for (int i = 0; i < n; i++) { if (b.f...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Tue Apr 18 23:18:55 2017 // Host : DESKTOP-I9J3TQJ running 64-bit major 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 la...
module anteconmutador ( input clk, input [7:0] count, input calculate, output reg [3:0] centenas, output reg [3:0] decenas, output reg [3:0] unidades, output reg C, output reg De, output reg U ); reg [7:0] digitT; reg i; initial begin digitT = 0; C = 0;...
#include <bits/stdc++.h> const double PI = 3.141592653589793238460; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; cin >> t; while (t--) { long long int n; cin >> n; long long int a[n], i, sum = 0, maxi = -1000000000, mi...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long fac[200001]; long long inv[200001]; long long modexp(long long b, long long e) { long long ans = 1; while (e > 0) { if (e & 1) { ans = (ans * b) % mod; } b = (b * b) % mod; e >>= 1...
#include <bits/stdc++.h> using namespace std; const int MAXN = 10010; vector<int> v[MAXN]; int childcnt[MAXN] = {0}; int main() { int n; cin >> n; for (int i = 1; i < n; i++) { int a, b; scanf( %d%d , &a, &b); v[a].push_back(b); v[b].push_back(a); } int root = 0; ...
#include <bits/stdc++.h> using namespace std; const int NMAX = 100005; int A[NMAX]; int main() { ios::sync_with_stdio(false); int n; cin >> n; bool ok = true; if (n % 2 == 1) { if ((n - 1) % 4 == 0) { for (int i = 1; i <= n / 2; i += 2) { A[i] = i + 1; A[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; bool IO_FILE = 0; ifstream ifs( input.txt ); ofstream ofs( output.txt ); int main() { if (IO_FILE) { cin.rdbuf(ifs.rdbuf()); cout.rdbuf(ofs.rdbuf()); } int n, m; cin >> n >> m; char *s = new char[m]; bool res = 1; char prev ...
/* * 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: %LPM_MUX% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: LPM_MUX // ============================================================ // File Name: chan_mux.v // Megafunction Name(s): // LPM_MUX // // Simulation Library Files(s): // lpm // ===============================================...
#include <bits/stdc++.h> using namespace std; int arr[int(1e7 + 100)]; void aum(int i) { if (i % 2) { arr[i / 2 + 1] += arr[i]; arr[i / 2] += arr[i]; } else arr[i / 2] += 2 * arr[i]; } int main() { ios_base::sync_with_stdio(0); set<int> conj; memset(arr, 0, sizeof arr); ...
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; long long int mul(long long int x, long long int y) { return (x * 1ll * y) % mod; } long long int add(long long int x, long long int y) { x += y; while (x >= mod) x -= mod; while (x < 0) x += mod; return x; } lo...
#include <bits/stdc++.h> using namespace std; int main() { int k, m, n1, n2; cin >> n1 >> n2 >> k >> m; vector<int> a(n1); for (int i = 0; i < a.size(); ++i) cin >> a[i]; vector<int> b(n2); for (int i = 0; i < b.size(); ++i) cin >> b[i]; if (a[k - 1] < b[n2 - m]) cout << YES n ; ...
#include bits/stdc++.h using namespace std; #define all(x) x.begin(),x.end() #define pb push_back #define ff first #define ss second #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define ar array #define int long long #define F(i,a,b) for(i=a;i<b;++i) #define RF(i,b,a) for(i=b;i>=a;...
#include <bits/stdc++.h> using namespace std; int vis[100005], mark[100005]; vector<int> g[100005]; int prob = 0; void dfs(int node, int k) { mark[node] = k; vis[node] = 1; for (auto i : g[node]) { if (!vis[i]) { dfs(i, 1 - k); } else { if (mark[i] == k) { pro...
// // Generated by Bluespec Compiler, version 2019.05.beta2 (build a88bf40db, 2019-05-24) // // // // // Ports: // Name I/O size props // RDY_server_reset_request_put O 1 reg // RDY_server_reset_response_get O 1 // read_rs1 O 64 // read_rs1_port2 ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, x = 0, y; cin >> n; y = n * n / 2.0 + n / 2.0; cout << 6 * y + 1; return 0; }
(**********************************************************************) (* Equations *) (* Copyright (c) 2009-2020 Matthieu Sozeau <> *) (**********************************************************************) (* This file is distributed under the terms of the ...
#include <bits/stdc++.h> using namespace std; int sti(const string &s) { int x; stringstream ss(s); ss >> x; return x; } string its(const int &x) { string s; stringstream ss(s); ss << x; s = ss.str(); } void sscan(string &str) { str = ; char str_c; scanf( %c , &...
#include <bits/stdc++.h> void stderr_printf(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); } using namespace std; struct flist { int val; int pos; }; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int i, j, k...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 17; int N, Q; int main() { ios_base::sync_with_stdio(false); cin >> Q; while (Q--) { cin >> N; long long mx; cin >> mx; long long diff = 0; while (--N) { long long x; cin >> x; ...
#include <bits/stdc++.h> using namespace std; long long rdtsc() { long long tmp; asm( rdtsc : =A (tmp)); return tmp; } inline int myrand() { return abs((rand() << 15) ^ rand()); } inline int rnd(int x) { return myrand() % x; } const int INF = (int)1e9 + 1; const long double EPS = 1e-9; voi...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int num[maxn]; long long ret; int n; void init() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &num[i]); } void print() { for (int i = 1; i < n; i++) { int j = 0; for (; j < 30; j++) if (...
#include <bits/stdc++.h> using namespace std; vector<int> prim; const int N = 1e5 + 9; int n, dp[10000], a[N]; bool v[100000]; int pos[100000]; void pre() { for (int i = 2; i < 100000; i++) if (!v[i]) { prim.push_back(i); pos[i] = prim.size() - 1; int k = i << 1; ...
/******************************************************************************* * 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> const int MOD = 1000000007; int64_t dp[2001][2001]; int main() { int n, m, k; std::cin >> n >> m >> k; dp[0][0] = 1; for (int i = 1; i <= 2000; ++i) { dp[i][0] = 1; for (int j = 1; j < i; ++j) { dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % MOD; ...
#include <bits/stdc++.h> using namespace std; const long long MXN = 1e6 + 1; const long long MNN = 1e3 + 1; const long long MOD = 1e9 + 7; const long long INF = 1e18; const long long MAGIC = 1000; const long double EPS = 1e-9; const long double PI = 3.1415926536; const string TIME = rovno_ushten_push...
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const int man = 2e5 + 10; const long long mod = 1e9 + 7; struct edge { int v; int w; int next; } e[man << 1]; int head[man]; int cnt; void init(int n) { memset(head, 0, sizeof(int) * (n + 5)); cnt = 0; } void...
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; int N, M; int A[MAXN]; int ans[MAXN][MAXN]; void gen(int x) { if (x <= 2) { for (int i = 0; i < x; i++) { A[i] = 3 + i; } return; } else if (x == 3) { A[0] = 1; A[1] = A[2] = 2; return; ...
/* Copyright 2018 Nuclei System Technology, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except i...
#include <bits/stdc++.h> using namespace std; char s[1000001]; int main() { int n, v = 0; cin >> n; sprintf(s, %X , n); for (int i = 0; i < strlen(s); i++) { if (s[i] == 0 || s[i] == 4 || s[i] == 6 || s[i] == 9 || s[i] == A || s[i] == D ) v++; else if (s[i...
`timescale 1ns / 1ps module spdif_tx_t; reg [23:0] simple_increment_ff; reg [23:0] simple_increment_ff2; parameter TCLK = 40; parameter TCLK_DAI = 10; reg clk; reg clk_dai; reg rst; reg [1:0] ack_i; reg [47:0] data_i; spdif_tx uut( .clk(clk), .rst(rst), .ack_i(ack_i), .data_i(data_i), .udata_i(192'b0)...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long a, b, c, d; cin >> a >> b >> c >> d; bool prob[5]; for (bool& i : prob) { i = true; } if ((a == 0 && b == 0) || (a + b) % 2 == 0) { prob[1] = prob[2] = ...
#include <bits/stdc++.h> using namespace std; int main() { int n, counter = 0, max = 1, a, b = -1; cin >> n; for (int i = 0; i < n; i++) { a = b; cin >> b; if (b >= a) { counter++; } else { if (counter > max) { max = counter; } counter = ...
#include <bits/stdc++.h> using namespace std; const int SIZE = 100005; const int MSIZE = 10000; const int INF = 1 << 30; set<int>::iterator it; int main() { int n, a, b; int p[SIZE]; set<int> fi, se; map<int, int> mp; bool flag[SIZE]; while (cin >> n >> a >> b) { fi.clear(), se...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAX = 1 << 20; bitset<MAX> dpgl, mv, dp[20]; map<char, int> to; char rv[20]; int cnt[20], le[20], ri[20], n, A, B, b; void solve(int ms) { int L = 1e9, R = -1, tot = 0; vector<int> tr, chr, oth; for(int...
#include <bits/stdc++.h> using namespace std; int n, m, tmp = 1; int sum(int a) { int res = 0; while (a) { res += a % 10; a /= 10; } return res; } int main() { cin >> n >> m; if (2 * n > 2220) { int nn = n / 2 + n % 2; for (int i = 1; i <= nn; ++i) { cou...
/* * Copyright 2012, Homer Hsing <> * * 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 ...
#include <bits/stdc++.h> using namespace std; const long double e = 1e-2; int k; long double R, r, l; long double x, y, xl, yl, xr, yr; long double a, b, c, S; long double COS[12], SIN[12]; bool check(long double x, long double y) { long double s = 0; for (int i = 0; i < 12; i += 2) s = ma...
#include <bits/stdc++.h> using namespace std; const int N = 2; const int MO = 1e9 + 7; const int K = 5e8 + 4; struct Matrix { int a[N][N]; Matrix(bool ident = 0) { for (int i = int(0); i <= int((N)-1); i++) for (int j = int(0); j <= int((N)-1); j++) a[i][j] = 0; if (ident) { ...
/* Copyright (C) 2016 Cedric Orban 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 distributed in the ho...
module keyed_permutation #( parameter UNIT_WIDTH = 1 )( input wire i_clk, input wire [`$NUNITS`*UNIT_WIDTH-1:0] i_dat, input wire [`$NUNITS`*INDEX_WIDTH-1:0] i_key, input wire i_inverse, output reg [`$NUNITS`*UNIT_WIDTH-1:0] o_dat ); localparam NUNITS = `$NUNITS`; localparam INDEX_WIDT...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ...
#include <bits/stdc++.h> using namespace std; const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; int powmod(int a, int b) { int tmp = 1; a %= (1000000007); for (; b; b >>= 1) { if (b & 1) tmp = tmp * a % (1000000007); a = a * a % (1000000007); } return tmp; } long long gcd(l...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, m; cin >> n >> m; vector<int> v; vector<bool> b; vector<int> u; vector<int> s; vector<int> t(m, 0); for (int i = 0; i < n + m; i++) { l...
#include <bits/stdc++.h> using namespace std; typedef struct cell { long long mx, pref, suf, total; } cell; int tam[55], vet[300000]; long long sum[55], preffix[55], suffix[55], best[55], v[300000]; long long getMax(int n) { long long ret = -1000000000000000000LL, aux = 0LL; for (int i = 0; i < ...
#include <bits/stdc++.h> using namespace std; int main() { multiset<long long> x, y; long long n, closing = 0, count = 0, i, j, pair = 0; cin >> n; string ss; for (i = 0; i < n; i++) { stack<char> s; closing = 0; cin >> ss; for (j = 0; j < ss.length(); j++) { if (...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, m, x, y, f[N], fa[N], ch[N][2]; char op[5]; long long a[N], siz[N], ssiz[N], ans[N], sans[N], sqsiz[N], all[N]; bool isroot(int u) { return ch[fa[u]][0] != u && ch[fa[u]][1] != u; } int which(int u) { return u == ch[fa[u]][1]; } ...
#include <bits/stdc++.h> using namespace std; void swapll(long long *a, long long *b) { long long tmp = *a; *a = *b; *b = tmp; } void swapc(char *a, char *b) { char tmp = *a; *a = *b; *b = tmp; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long...
#include <bits/stdc++.h> using namespace std; long long nxt[45][3], lnk[45], pre[45][3]; string s; long long n; pair<long long, long long> sh[45][45][2]; long long dp[41][41][41][41][2]; long long sol(long long i, long long pre, long long l, long long r, long long f = 0) { if (pre == s...
/* Copyright 2011 David Fritz, Brian Gordon, Wira Mulia 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. ...
/** * 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) 2001-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 doc...
// Accellera Standard V2.5 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2010. All rights reserved. `ifdef SMV `include "ovl_ported/std_ovl_defines.h" `else `include "std_ovl_defines.h" `endif `module ovl_next (clock, reset, enable, num_cks, start_event, test_expr, fire, fire_comb); parameter ...
////////////////////////////////////////////////////////////////////// //// //// //// Generic Single-Port Synchronous RAM //// //// //// //// This file is part of memory 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 la...