text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; long long exgcd(long long a, long long b, long long &x, long long &y) { long long d = a; if (b != 0) { d = exgcd(b, a % b, y, x); y -= (a / b) * x; } else { x = 1; y = 0; } return d; } int main() { long long n, a, b, x...
module helloonechar #(parameter CLOCK_FREQ = 12000000, parameter BAUD_RATE = 9600) ( input ext_clock, output uart_tx_pin, output uart_tx_led, output counter_led, output uart_clock_led); wire reset; /* uart tx */ wire uart_ready; wire [7:0] uart_data; wire uart_clock_enable; wire uart_clock; reg [32:0] cou...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, n, t = 1; while (t--) { cin >> n; vector<long> v(n), b(n), ans(n, 0); for (i = 0; i < n; i++) { cin >> v[i]; b[i] = v[i]; } for (i = n - 2; i >= 0; i--) { if (b[i + 1] >= v[i]) ans[i...
// ---------------------------------------------------------------------- // Copyright (c) 2015, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const long long MOD = 1000000007LL, INF = 1e9, LINF = 1e18; const long double PI = 3.141592653589793116, EPS =...
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, a[100005], sta[100005]; vector<int> V; int calc(int k) { while (k) { int d = k % 10; k /= 10; if (d != 4 && d != 7) return 0; } return 1; } using pii = pair<int, int>; int tar[100005], to[100005]; ...
#include <bits/stdc++.h> using namespace std; vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(move(x)); return move(v); } void err(vector<string>::iterator it) {} template <typename T, typename... Args> ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, two, one; cin >> n >> m; if (m < n - 1 || m > 2 * n + 2) cout << -1 ; else { if (m < n) { cout << 0 ; n--; } while (m > 0 || n > 0) { two = max(m - n - 1, 0); one = min(2 * ...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10, pi = acos(-1.0); int main() { int n, t = 1; while (t--) { double a, b, x, y, v; double ans = 1000000000.00; cin >> a >> b; cin >> n; for (int i = 0; i < n; i++) { cin >> x >> y >> v; doubl...
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 10, LOG = 20; int n, q, F[N], T[N], P[N], D[N], Par[LOG][N]; pair<int, int> Q[N]; vector<int> Adj[N], Ap[N], V[N << 2]; void Pre(int v) { for (int i = 1; i < LOG; i++) Par[i][v] = Par[i - 1][Par[i - 1][v]]; for (auto X : Adj[v]) ...
#include <bits/stdc++.h> using namespace std; set<long long> s; map<long long, long long> m; vector<long long> v; long long n, a[100010], b[100010], dp[100010], mx = 0; bool mark[100010]; int main() { ios_base::sync_with_stdio(false); cin >> n; for (long long i = 1; i <= n; i++) { cin >>...
#include <iostream> int main(void) { int count; std::cin >> count; for (int i = 0; i < count; ++i) { int number; std::cin >> number; int64_t sum = 0; for (int j = 0; j < number; ++j) { int part; std::cin >> part; sum += part; } std::cout << (sum % number) * (number -...
#include <bits/stdc++.h> using namespace std; const int Inf = 1e9 + 7; int dp[107][107]; int par[107][107]; string t = .,!? ; bool check(char c) { return t.find(c) == string::npos; } void solve() { int t; cin >> t; for (int k = 0; k < t; k++) { int n; cin >> n; vector<strin...
#include <bits/stdc++.h> using namespace std; const long long fuck = 4e17; long long n, arr[100010]; vector<long long> ans; bool chk(long long x) { vector<int> diffs; for (int i = 0; i + 1 < n; i++) { long long next = arr[i + 1]; if (arr[i] <= x) next = min(arr[i + 1], x); long long ...
`timescale 1ns / 1ps /* -- Module Name: West First Minimal -- Description: Algoritmo parcialmente adaptativo para el calculo de de ruta en NoCs con topologia Mesh. El algoritmo esta basado en el "Turn Model". Se puede encontrar mas informacion en: The turn model for adaptive routing Christop...
/** * 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; using ll = long long; const int N = 3e6 + 44; const int X[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int Y[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int mod = 998244353; const int INF = 1e9; ll ans[N], add[N]; vector<int> g[N]; vector<pair<int, int> > query[N];...
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; string a[maxn], ans[maxn]; int main() { int n; while (cin >> n) { int cnt[2][26]; memset(cnt, 0, sizeof cnt); for (int i = 0; i < n; ++i) cin >> a[i], ++cnt[0][a[i][0] - A ]; multiset<string> Q; for (...
//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> long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } inline long long qmul(long long a, long long b, long long m) { long long res = 0; while (b) { if (b & 1) res = (res + a) % m; a = (a << 1) % m; b = b >> 1; } return res; } inline ...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2017 Xilinx, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // /...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int a[n]; map<int, int> mp; for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]]++; } long long ans = 0; for (int i = 0; i < n; i++) { fo...
#include <bits/stdc++.h> using namespace std; template <typename T> using maxpq = priority_queue<T, vector<T>, greater<T>>; template <typename T> using minpq = priority_queue<T>; int n, TOT; string a[305]; int HASH[305], len[305], p[100005]; inline int add(int a, int b) { long long c = a + b; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 5; const int MAXM = 2e6 + 5; char s[MAXN]; vector<int> v[MAXN]; multiset<int> ss[MAXN]; int trie[MAXN][26], fail[MAXN]; int pos[MAXN], dat[MAXN], siz[MAXN]; int fa[MAXN], dep[MAXN], top[MAXN], dfn[MAXN]; int rev[MAXN], son[MAXN], d...
// 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 : Thu Oct 26 22:45:01 2017 // Host : Juice-Laptop running 64-bit major relea...
#include <bits/stdc++.h> using namespace std; struct query { long long l, r, x; }; int n, a[109]; long long m; int main() { cin >> n >> m; vector<query> v; vector<long long> cp = {1LL << 60}; for (int i = 0; i < n; i++) { cin >> a[i]; int pr = sqrt(a[i]); for (int j = 1...
#include <bits/stdc++.h> using namespace std; bool Check(int N, int pos) { return (bool)(N & (1 << pos)); } int Set(int N, int pos) { return (N | (1 << pos)); } long long BigMod(long long B, long long P, long long M) { long long R = 1; while (P > 0) { if (P % 2 == 1) { R = (R * B) % M; ...
//------------------------------------------------------------------------------ // YF32 -- A small SOC implementation based on mlite (32-bit RISC CPU) // @Taiwan //------------------------------------------------------------------------------ // // ...
#include <bits/stdc++.h> using namespace std; bool cutPaper(int n, int x, int y) { int count = 1; while ( x % 2 == 0 || y % 2 == 0 ) { if ( x % 2 == 0 ){ x /= 2; count *= 2; }else if ( y % 2 == 0 ) { y /= 2; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; while (~scanf( %d , &n)) { int cnt = 1; while (n != 1) { if (n % 2 != 0) cnt++; n /= 2; } printf( %d n , cnt); } return 0; }
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); parameter PAR = 3; input clk; `ifdef verilator // Else it becomes a localparam, per IEEE 4.10.1, but w...
#include <bits/stdc++.h> using namespace std; struct Point { int x, y; Point(int x = 0, int y = 0) : x(x), y(y) {} Point operator-(const Point z) const { return Point(x - z.x, y - z.y); } friend long long Cross(Point a, Point b) { return 1ll * a.x * b.y - 1ll * a.y * b.x; } } a[2010], b[...
/* **************************************************************************** This Source Code Form is subject to the terms of the Open Hardware Description License, v. 1.0. If a copy of the OHDL was not distributed with this file, You can obtain one at http://juliusbaxter.net/ohdl/ohdl.txt Description: mo...
// ##################################################################################### // # Copyright (C) 1991-2008 Altera Corporation // # Any megafunction design, and related netlist (encrypted or decrypted), // # support information, device programming or simulation file, and any other // # associated ...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of ent_ac // // Generated // by: wig // on: Tue Jul 4 08:39:13 2006 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../../verilog.xls // // !!! Do not edit this file! Autogenerated by MIX !!! // $Author...
// DESCRIPTION: Verilator: Verilog Test module // // Copyright 2011 by Wilson Snyder. This program is free software; you can // redistribute it and/or modify it under the terms of either the GNU // Lesser General Public License Version 3 or the Perl Artistic License // Version 2.0. // SPDX-License-Identifier: LGPL-3.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...
/** * 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 ll = long long; using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); int t; cin >> t; for (ll _ = 0, _Len = (t); _ < _Len; ++_) { ll n; cin >> n; vector<ll> a(n); vector<pa...
/** * @module regfile * @author sabertazimi * @email * @brief register files for MIPS CPU, contains 32 D flip-flop registers * @param DATA_WIDTH data width * @input clk clock signal * @input we write enable signal * @input raddrA read address (No.register) for A out port * @input raddrB read address (No.regis...
// (C) 2001-2017 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; const double PI = acos(-1.0); long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } pair<long long, int> all[2000111]; long long cntA, cntB; int cnt; int main() { long...
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; int n, m; vector<int> a; bool chk(int c) { int lst = a[0]; if (a[0] + c >= m) lst = 0; for (int ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 05.03.2016 20:20:22 // Design Name: // Module Name: data_formatter // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // /...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; int n, m, cnt, belong[N]; vector<int> g[N], ans[N]; int get(int x) { return belong[x] ? belong[x] = get(belong[x]) : x; } void dfs(int i) { ans[cnt].push_back(i); belong[i] = i + 1; for (int j = get(1), k = 0; j <= n; j = get(j...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx ) using namespace std; const long long maxn = 1e5 + 20; const long long inf = (long long)2e9; const long double pi = asin(1) * 2; c...
////////////////////////////////////////////////////////////////////// //// //// //// Generic Wishbone controller for //// //// Single-Port Synchronous RAM //// //// ...
/** * 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 N = 1e5 + 100, M = 10 + 10, SQ = 333; pair<int, int> nxt[N][M]; char a[N][M]; bool mark[N][M]; int n, m, q; bool OK(pair<int, int> x) { return x.first > 0 && x.second > 0 && x.second <= m; } pair<int, int> go(int x, int y) { if (!OK({x, y...
#include <bits/stdc++.h> using namespace std; inline int read() { int s = 0, w = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = s * 10 + ch - 0 , ch = getchar(); return s * w; } const int inf...
/** * 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 N = 5005; vector<int> adj[N]; bool visited[N]; bool reach[N]; pair<int, int> has[N]; int cnt = 0; void dfs(int s) { if (!visited[s]) { visited[s] = 1; reach[s] = 1; for (int i = 0; i < adj[s].size(); i++) { dfs(adj[s][...
#include <bits/stdc++.h> using namespace std; const int maxn = (int)1e6 + 10; const int mod = (int)1e9 + 7; const int inf = (1 << 30) - 1; int n, m, q; int a[maxn]; int good[maxn]; vector<int> g[maxn]; int p[maxn]; int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 1}; char dir[] = { U , D , L , ...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { for (size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? : ); return o; } template <int n, class... T> typename enable_if<(n >=...
#include <bits/stdc++.h> using namespace std; long long pw(long long a, long long b, long long md) { return (!b ? 1 : (b & 1 ? a * pw(a * a % md, b / 2, md) % md : pw(a * a % md, b / 2, md) % md)); } const long long MOD = 1e9 + 7, MAXN = 1e6 + 10; bool prime[MAXN]; ...
#include <bits/stdc++.h> using namespace std; const long long nax = 105; long long a[nax]; signed main() { long long n, cnt0 = 0, cnt1 = 0; cin >> n; for (long long i = 1; i <= n; i++) { cin >> a[i]; if (a[i] == 0) cnt0++; else cnt1++; } if (cnt0 == n) { ...
#include <bits/stdc++.h> using namespace std; const long long int N = 200001; const long long int M = 21; struct point { long long int x, y, cur; bool operator==(const point b) { if (this->x == b.x && this->y == b.y) return 1; return 0; } bool operator!=(const point b) { return !(*th...
#include <bits/stdc++.h> using namespace std; long long mod; long long lgput(long long a, long long b) { if (b == 0) return 1; if (b == 1) return a % mod; long long c = lgput(a, b / 2); c = c * c % mod; if (b & 1) c = c * a % mod; return c; } map<long long, int> hh; int main() { ...
#include <bits/stdc++.h> using namespace std; int dis[200009]; int con[200009]; bool cmp(int a, int b) { return a < b; } int main() { int i, p, j, n, t, y; int x; long long int nail; scanf( %d , &n); for (i = 0; i <= n - 1; i++) scanf( %d , &dis[i]); sort(dis, dis + n, cmp); nail =...
#include <bits/stdc++.h> using namespace std; const long long MXN = 2e5 + 10; const long long LOG = 21; const long long MXM = (1LL << LOG); const long long INF = 1e9; int n, m, ans; int dp[MXN], ps[MXN], Best[LOG][MXM]; string S[MXN]; int Cost(int i, int j) { for (int x = m; x; x--) { if (S[...
#include<bits/stdc++.h> using namespace std; void solve(){ int n; cin >> n; int a[n]; for(int i=0;i<n;i++){ cin >> a[i]; } vector<int> ans; ans.push_back(0); int current = a[0]; for(int i=1;i<n;i++){ int cans = (current|a[i])^a[i]; ans.push_back(cans); current =...
module lsuc_top ( clk, reset_, led, switches, segment_, digit_enable_, up_, down_, left_, right_, tx, rx); input clk; input reset_; output [7:0] led; // LogicSmart LEDs input [6:0] switches; // LogicSmart toggle swi...
/** * 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; template <class T> inline T abs(T x) { return x < 0 ? -x : x; } const double EPS = 1e-9; int n, m, a[55], b[55], mx, ans, x; double cur; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) scanf( %d , a + i); scanf( %d , &m); for (i...
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; while (t--) { long long n, min, cnt = 0, x; cin >> n; vector<long long> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; min = *min_element(v.begin(), v.end()); for (int i = 0; i < n; ++i) { if (m...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > arr[111]; int vis[111], maxs; void dfs(int now, int wei) { if (vis[now]) return; vis[now] = 1; maxs = max(maxs, wei); for (int e = 0; e < arr[now].size(); e++) { int next = arr[now][e].first, n_wei = wei + arr[now][e].se...
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 7; const int inf = 1e9; char s[60][60]; char s1[60]; int l; int n; int num[60]; int check(char *s) { for (int i = 0; i < l; ++i) { int j; for (j = 0; j < l; ++j) { if (s1[j] != s[(j + i) % l]) break; } ...
#include <bits/stdc++.h> using namespace std; long long arr[100005], ans[2]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { scanf( %lld , arr + i); } for (int sum = 1; sum <= m << 1; sum++) { vector<int> vec = {0}; for (int i = 0; i < n; i++) { ...
module mojo_top( // 50MHz clock input input clk, // Input from reset button (active low) input rst_n, // cclk input from AVR, high when AVR is ready input cclk, // Outputs to the 8 onboard LEDs output [7:0] led, // AVR SPI connections output spi_miso, input spi_ss, in...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> int v[1000001]; using namespace std; int main() { int a, b, c, d; scanf( %d%d%d%d , &a, &b, &c, &d); while (b <= 1000000) { v[b] = 1; b += a; } while (d <= 1000000) { if (v[d] == 1) { printf( %d , d); return 0; } d += c; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Xilinx // Engineer: Parimal Patel // Create Date: 04/13/2017 // Module Name: trace_generator_controller // Project Name: PYNQ /////////////////////////////////////////////////////////////////////////////...
// // Generated by Bluespec Compiler, version 2019.05.beta2 (build a88bf40db, 2019-05-24) // // // // // Ports: // Name I/O size props // result_valid O 1 // result_value O 64 reg // CLK I 1 clock // RST_N ...
//Legal Notice: (C)2014 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 associate...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, i, j, k, c = 0, sm = 0, t = 0, ans = 0; cin >> n >> m; int a[n + 2], b[n + 2]; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < n; i++) { sm += a[i]; if (sm > m) { sm -= a[t]; ++t; } ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; using ll = long long; using ull = unsigned long long; template <typename T> void print(vector<T> v) { for (T i : v) cout << i << ; cout << n ; } template <typename T> void prin...
/** * 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) 2011-2012 * * * * 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; const int maxn = 505, maxmax = 1000000; int n, javab[maxn][maxn]; vector<int> v; int dp(int l, int r) { int x = maxmax; if (l == r) { javab[l][r] = 1; return 1; } if (l == r - 1) { if (v[r] == v[l]) { javab[l][r] = 1; ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
////////////////////////////////////////////////////////////////// // // // Fetch - Instantiates the fetch stage sub-modules of // // the Amber 25 Core // // ...
#include <bits/stdc++.h> using namespace std; const int pos[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int n; char s[510][510]; int v[510][510]; vector<pair<int, int> > vec, ans; int operator*(const pair<int, int> &a, const pair<int, int> &b) { return a.first * b.second - a.second * b.first; } pa...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2008 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Outputs q, // Inputs clk, d ); input clk; input d; output...
#include <bits/stdc++.h> using namespace std; int main() { int n; set<int> s; cin >> n; int i, j; for (i = 0; i < n; i++) { cin >> j; if (j != 0) s.insert(j); } cout << s.size(); }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, v; scanf( %d%d%d , &n, &m, &v); int spec = 1; if (m < n - 1 || m > (n - 1) * (n - 2) / 2 + 1) { printf( -1 n ); return 0; } if (spec == v) spec++; printf( %d %d n , v, spec); m--; for (int i = 1; i <...
#include <bits/stdc++.h> using namespace std; int n, k; int a[1000000]; vector<pair<int, int> > ans; int main() { ios_base::sync_with_stdio(false); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= k; i++) { int high = 1, low = 1; for (int j = 2; j <= n;...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int sum(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; } int sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; } int mul(int a, int b) { return (1LL * a * b) % MOD; } const int MAXN = 1e6 + 7; int shuru[MAXN], she...
//---------------------------------------------------------------------------- // Copyright (C) 2001 Authors // // This source file may be used and distributed without restriction provided // that this copyright statement is not removed from the file and that any // derivative work contains the original copyright notic...
/** * 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, m, x1, x2, y1, y2; cin >> n >> m >> x1 >> y1 >> x2 >> y2; int dx = abs(x2 - x1); int dy = abs(y2 - y1); if (dx <= 4 && dy <= 2 || dy <= 4 && dx <= 2 || dx == 3 && dy == 3) { cout << First ; } else { cout << Secon...
#include <bits/stdc++.h> using namespace std; int dp[5005][5005]; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> s; memset(dp, -1, sizeof dp); int ans = 0; for (int i = 0; i < s.size(); i++) { int can_rev = 0; int cur = 0; for (int j = i; j < s....
#include <bits/stdc++.h> using namespace std; int n; int s[4040][4040]; bool u[4040][4040], r[4040][4040]; int su[4040][4040], sr[4040][4040]; bool b[4040][4040]; int get(int x1, int y1, int x2, int y2) { return s[x2][y2] + s[x1 - 1][y1 - 1] - s[x1 - 1][y2] - s[x2][y1 - 1]; } struct Point { in...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d %d , &n, &m); char s[n + 5]; scanf( %s , s); vector<int>* vp[30]; for (int i = 0; i <= 25; i++) vp[i] = new vector<int>(); for (int i = 0; s[i]; i++) { int now = s[i] - a ; vp[now]->push_back(i); ...
/////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2014 Francis Bruno, All Rights Reserved // // 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 Found...
#include <bits/stdc++.h> using namespace std; long long int ax, ay, bx, by, cx, cy; double k1, k2, k3; int main() { long long int dis_ab, dis_ac, dis_bc, max_dis = -1; cin >> ax >> ay >> bx >> by >> cx >> cy; dis_ab = (ax - bx) * (ax - bx) + (ay - by) * (ay - by); k1 = (double)(ax - bx) / (ay - ...
module PS_flops_issue_lsu ( in_lsu_select, in_wfid, in_lds_base, in_source_reg1, in_source_reg2, in_source_reg3, in_mem_sgpr, in_imm_value0, in_imm_value1, in_dest_reg, in_opcode, in_instr_pc, out_lsu_select, out_wfid, out_lds_base, out_source_reg1, out_source_reg2, out_source_reg3, ...
#include <bits/stdc++.h> using std::min; const int MAXL = 3000000 + 9, MAXM = 5000 + 9, M = 4194304; int tr[M + M]; int ask(int k) { int i; for (i = 1; i < M;) if (k > tr[i + i]) { k -= tr[i + i]; i += i + 1; } else i += i; return i - M; } void change(int u, i...
#include <bits/stdc++.h> using namespace std; int n, m, a[500005], l = 1, r, b[500005]; queue<int> Q; bool flag = false; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) a[i] = i & -i; for (int i = 1; i <= n; ++i) b[i] = 1; r = n; while (m--) { int opt, x, y; sc...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: sparc_ifu_cmp35.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 a...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFF = 0x3f3f3f3f3f3f3f3fll; const long long M = 1e9 + 7; const long long maxn = 2e6 + 7; const double eps = 0.00000001; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } template <typename ...