text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int a[200001]; int b[200000]; int c[200001]; int main() { int n, i, j; cin >> n; map<int, int> m; for (i = 0; i < n; i++) { cin >> b[i]; m[b[i]]++; a[b[i]] = 1; } vector<int> v; for (i = 1; i <= n; i++) { if (a[i...
/***************************************************************************** * File : processing_system7_bfm_v2_0_regc.v * * Date : 2012-11 * * Description : Controller for Register Map Memory * *****************************************************************************/ `timescale 1ns/1ps module processin...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int win(long long s, long long e) { if (e % 2 == 1) { if (s % 2 == 1) return 0; else return 1; } else { if (2 * s > e) { if (s % 2 == 1) return 1; else return 0; ...
#include <bits/stdc++.h> using namespace std; unsigned N, M; vector<unsigned> V; double dens(const unsigned idxV1, const unsigned idxV2, const unsigned eW) { if (eW == 0) { return 0; } return (double)(V[idxV1] + V[idxV2]) / (double)eW; } int main() { unsigned v1, v2, w, n, m; doubl...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.length(); bool sign = false; for (int i = 0; i < n; i++) { if (s[i] == a && !sign) continue; if (s[i] == a && sign) break; s[i]--; sign = true; } if (!sign) s[n - 1] = z ...
#include <bits/stdc++.h> using namespace std; const int pi = 3.14159265; const int INF = 1 << 30; const int maxn = 1e5; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; string s; cin >> n >> k; cin >> s; int t = s.find( T ); int g = s.find( G ); if (g > t) swap(t...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; scanf( %d %d %d %d , &a, &b, &c, &d); int M, M1, M2, V, V1, V2; M1 = (3 * a) / 10; M2 = (a - (a / 250) * c); if (M1 > M2) { M = M1; } else { M = M2; } V1 = (3 * b) / 10; V2 = (b - (b / 250)...
#include <bits/stdc++.h> using namespace std; int a[100002]; int gcd(int a, int b) { int c; while (a != 0) { c = a; a = b % a; b = c; } return b; } int main() { int n; int mina = 2000000009; cin >> n; cin >> a[1]; int ucln; ucln = a[1]; for (long l...
/* * These source files contain a hardware description of a network * automatically generated by CONNECT (CONfigurable NEtwork Creation Tool). * * This product includes a hardware design developed by Carnegie Mellon * University. * * Copyright (c) 2012 by Michael K. Papamichael, Carnegie Mellon University * * ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf( %d%d , &n, &k); long long ans1 = 1, ans2 = 1; for (int i = 1; i <= k - 1; i++) ans1 = ans1 * k % 1000000007; for (int i = 1; i <= n - k; i++) ans2 = ans2 * (n - k) % 1000000007; printf( %I64d n , ans1 * ans2 % 100000...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 0.0000000001; const int N = 100000 + 100; int head[N]; int tot; struct node { int to, next; } edge[N << 1]; int color[N]; int vis[N]; int a[N]; int b[N]; int num[N]; void init() { memset(he...
#include <bits/stdc++.h> using namespace std; int n; int a[100007], ans[100007], vis[100007]; int count(int x) { int cnt = 0, now = 0; memset(vis, 255, sizeof(vis)); for (int i = 1; i <= n; i++) { if (vis[a[i]] == now) continue; vis[a[i]] = now; if (++cnt > x) { cnt = 1; ...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: string_rom.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =============================...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int n; cin >> n; vector<int> a(101); for (int i = 0; i < n; i++) { int x; cin >> x; ++a[x]; } cout << *max_element(a.begin(), a.end()) << ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); template <typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; } template <class L, class R> ostream &operator<<(...
#include <bits/stdc++.h> using namespace std; const long long maxn = 400010, inf = 1e18; long long q, lastans, cnt = 1, w[maxn]; long long fa[maxn][21], sum[maxn][21]; void add(long long x, long long v) { w[++cnt] = v; if (w[cnt] <= w[x]) fa[cnt][0] = x; else { int y = x; for (in...
#include <bits/stdc++.h> using namespace std; const int maxn = 200000 + 10; const int hashnum = 3; long long base[] = {233, 23, 97}; long long mod[] = {122420729, 1000000007, 1000000009}; int sum[maxn]; char s[maxn]; long long power[hashnum][maxn]; int n; struct node { long long hv[hashnum]; ...
module count_minutes( manual_inc, automatic_inc, ones_digit, tens_digit, count_out ); // port declarations input manual_inc; input automatic_inc; output [3:0] ones_digit; output [3:0] tens_digit; output reg count_out; // wire declarations wire carry; reg module_reset; reg pre_count; reg increment; /...
/** * 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 i, j, k, l, s[1000005], n, m, tot, last[1000005], Next[1000005], to[1000005], dfn[1000005], low[1000005]; int vis[1000005], q[1000005], Q[1000005], q1[1000005], r, r1, G[1000005], T; vector<int> gt; int ans[1000005], A[1000005], B[1000005], a[1000005], b...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int c, r; cin >> c >> r; bool flag = true; for (int i = 1; i <= c; i++) { if (i & 1) { for (int j = 1; j <= r; j++) { cout << # ; } cout << endl; } else { ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int n, m, a[100010]; long long t; int main() { cin >> n >> m; a[0] = 1; for (int i = 1; i <= m; i++) { cin >> a[i]; if (a[i] > a[i - 1]) t += (a[i] - a[i - 1]); if (a[i] < a[i - 1]) t += (n - a[i - 1] + a[i]); } cout << t; } ...
#include <bits/stdc++.h> using namespace std; int main() { int n1, n2, k1, k2; cin >> n1 >> n2 >> k1 >> k2; if (n1 > n2) { cout << First ; } else { cout << Second ; } return 0; }
// cog_ctr /* ------------------------------------------------------------------------------- Copyright 2014 Parallax Inc. This file is part of the hardware description for the Propeller 1 Design. The Propeller 1 Design is free software: you can redistribute it and/or modify it under the terms of the GNU General Pub...
/////////////////////////////////////////////////////////////////////////////// // // Project: Aurora Module Generator version 2.8 // // Date: $Date: 2007/09/28 12:50:35 $ // Tag: $Name: i+HEAD+134158 $ // File: $RCSfile: channel_init_sm.ejava,v $ // Rev: $Revision: 1.2 $ // ...
module top(input clk, ce, sr, d, output q); /* IS_C_INVERTED=1'b1, IS_D_INVERTED=1'b1, IS_CLR_INVERTED=1'b1, ERROR: [Place 30-1008] Instance ff has an inverted D pin which is expected to be used as an I/O flop. However, it is used as a regular flop. cliff didn't have constrained, also got annoyed...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int hops[n + 1]; bool vis[n + 1]; int change[n + 1]; for (int i = 1; i <= n; ++i) { cin >> hops[i]; vis[i] = 0; } int cnt = 0; int cnt1 = 0; for (int i = 1; i <= n; ++i) { cin >> cha...
#include <bits/stdc++.h> using namespace std; inline long long mod(long long n, long long m) { long long ret = n % m; if (ret < 0) ret += m; return ret; } long long gcd(long long a, long long b) { return (b == 0LL ? a : gcd(b, a % b)); } long long exp(long long a, long long b, long long m) {...
(************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016 *) (* \VV/ **************************************************************) (* // * Th...
#include <bits/stdc++.h> using namespace std; struct Point { int x; int y; }; struct Rect { int left; int top; int right; int bottom; }; bool FindBoundary(const vector<Point> &pts, Rect *getRect) { if (pts.empty()) { return false; } auto it = pts.begin(); getRec...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n, m, m1, arr[9] = {0}, num = 0, num1 = 0; cin >> n >> m, m1 = m; if (n == 1 && m == 0) cout << 0 0 ; else if (9 * n < m || m == 0) cout << -1 -1 ; else { num1...
#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; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } long long int fact[2 * 10000...
#include <bits/stdc++.h> using namespace std; int n; int s[100005], num[100005]; bool cmp(int a, int b) { return a < b; } int main() { while (scanf( %d , &n) != EOF) { int i; for (i = 0; i < n; i++) scanf( %d , &s[i]); sort(s, s + n, cmp); bool flag = true; for (i = 1; i < n ...
// file: SysMon_tb.v // (c) Copyright 2009 - 2010 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 lice...
//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 associated do...
// part of NeoGS project // // (c) NedoPC 2007-2009 // // ZX dma controller // // includes dma address regs, dma control reg // // CURRENTLY ONLY READ ON ZXBUS SIDE FROM NGS MEM, error in WAIT generation! zx_dma2.v - further development module dma_zx( input clk, input rst_n, // ZXBUS-related sign...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2009 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 package testpackage; localparam PARAM = 1024 >> 3; endpackage import testpackage::*; module t; local...
// (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 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; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } int n, arr[109]; vector<int> odd, even; int main() { scanf( %d , &n); for (int i = 0; i < (int)(n); i++...
/* * Copyright (c) 2014, Franck Jullien <> * All rights reserved. * * Redistribution and use in source and non-source 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 li...
#include <bits/stdc++.h> using namespace std; const bool debug = 0; int main() { if (!debug) { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); } int q; cin >> q; while (q--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]...
module scbd_feeder( valid_wf, ins_half_reqd, ins_half_wfid, issue_vacant, q_empty, q_reset, feed_valid, feed_wfid, clk, rst ); input [39:0] valid_wf; input ins_half_reqd; input [5:0] ins_half_wfid; input [39:0] issue_vacant; input [39:0] q_empty; input [39:0] q_reset; output feed_valid; output [5...
#include<bits/stdc++.h> using namespace std; #define f first #define s second using ll = long long; const int mxN = 200000; const int lgN = 18; const int mod = 1e9 + 7; const ll inf = 1e15; void solve() { int n; cin >> n; int a[n + 1]; int check = true; ...
#include <bits/stdc++.h> int min(int a, int b) { return a < b ? a : b; } int n, m, t1, t2, val[1024]; long long ans; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , &val[i]); } for (int i = 1; i <= m; i++) { scanf( %d%d , &t1, &t2); ans += min(val...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-8; const int mod = 1e9 + 7; const int inf = 1061109567; const int dir[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; double dp[205][205][405], p[205]; int a[205]; int main() { int n, l, tmp; cin >> n ...
//----------------------------------------------------------------------------- // // (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 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; vector<int> nxt[1 << 13], G[15]; vector<pair<int, int> > lca[13]; bool a[14][14], ok[14][1 << 13]; long long int dp[14][1 << 13][2]; int n; long long int solve(int root, int mask, int check) { if (check == 0) { int i; for (i = 0; i < lca[root]....
#include <bits/stdc++.h> using namespace std; double PI = 3.1415926535897932384626433; double DP[(1 << 20)]; vector<double> fx, fy, lg; double calc(double px, double py, double t, double al) { double d = sqrt((px - t) * (px - t) + py * py); double sina = sin(al * (PI / 180.0)); double sinb = fabs(...
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const double eps = 1e-9; const int N = 1 << 19; const int P = (int)1e9 + 7; const int Z = 239; inline int add(int a, int b) { a += b; if (a >= P) a -= P; return a; } int powP[2 * N]; inline int shift(int a, int n) { ...
#include <bits/stdc++.h> using namespace std; const int NMAX = 1e5; int t; int n, m, k; vector<int> graph[NMAX + 5]; int gr[NMAX + 5]; bool active[NMAX + 5]; bool in[NMAX + 5]; bool exists(int i, int j) { vector<int>::iterator it = lower_bound(graph[i].begin(), graph[i].end(), j); if (it != gr...
#include <bits/stdc++.h> using namespace std; const int N = 100005; vector<int> v[2][N]; int a[N], q[N], n; bool vst[2][N]; void bfs(int val) { int i, j, qh = 0, qe = 0, k = val - 1, s, out; for (i = 1; i <= n; i++) if (a[i] == val) q[qe++] = i, vst[k][i] = 1; while (qh < qe) { out =...
// Icarus 0.6, snapshot 20020907 // ================================================== // -- confused by disables from within a fork -- vvp fails // // -- to run, incant // iverilog tt.v // vvp a.out module top; integer simple_fail, loop_fail, fork_fail, tlp_fail, tfk_fail; integ...
#include <bits/stdc++.h> const int N = 1e5 + 5; int n, k, a[N]; int ans[N], top; int main() { scanf( %d%d , &n, &k); int sum = 0; for (int i = 1; i <= n; i++) scanf( %d , a + i), sum += a[i]; if (sum % k) return !printf( No ); int num = sum / k; top = 0; int now = 0, l = 1; for (...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) ch = getchar(); while ( 0 <= ch && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); return x; } int t; int main() { t = read(); while (t--) { int n...
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k, m = 0, n, cnt = 0, x = 0, ans = 0, y, sum = 0, l = 0, r = 0; cin >> n >> m; string a[n]; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { for (j = 0; 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...
#include <stdio.h> #include<iomanip> #include<iostream> #include<iostream> #include <algorithm> #include<string.h> #include<string> #include<cmath> #include<queue> #include<map> #include<set> #include<bits/stdc++.h> using namespace std; #pragma warning(disable:4996) #define inf 0x3f3f3f3f ...
#include <bits/stdc++.h> using namespace std; const int M = 1000000000 + 7; const int N = 200000 + 10; const int NUMHASH = 3; const long long hashNum[3] = {M, M + 2, M + 14}; struct re { int x, y; }; int n, q; string s; int cnt[26][N], f[26][N], g[26][N]; long long h[NUMHASH][26][N], p[NUMHASH...
#include <bits/stdc++.h> using namespace std; const long long maxn = 400010; const long long mod = 1000000007; const long double eps = 1e-9; const long long inf = ((1ll << 31ll) - 1ll); const long long INF = 2000000000000000000ll; const long double pi = acos(-1); long long qpow(long long b, long long e)...
#include <bits/stdc++.h> using namespace std; const int MAXN = 200000 + 10; int a[MAXN]; int sum[MAXN]; int cnt[100 + 10]; vector<int> vc; unordered_map<int, int> mp; int exist[MAXN]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); cnt[a[...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int main() { int n, sum[3] = {0}; cin >> n; int *x = new int[n], *y = new int[n], *z = new int[n]; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> z[i]; sum[0] += x[i]; sum[1] += y[i]; sum[2] += z[i]; } if (sum[0] == ...
/* * stack_tv.v * Testbench for stack.v * * Copyright (C) 2013 James Cowgill * * 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...
module IRRecive( input clk, input ir, output reg [7:0]Code, output reg press ); reg [2:0]IR_reg; initial IR_reg = 3'b0; always @ (posedge clk) //1us begin IR_reg[0] <= ir; IR_reg[1] <= IR_reg[0]; IR_reg[2] <= IR_reg[1]; end wire IR_pos = (IR_reg[0]==1'b1) & (IR_reg[1]==1'b0); wire IR_pos2= (IR_reg[1]==1'b...
#include <bits/stdc++.h> using namespace std; template <class T> inline int countbit(T n) { return (n == 0) ? 0 : (1 + countbit(n & (n - 1))); } template <class T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } const double EPS = 1e-9; const double PI = acos(-1.0); int n, k, h; i...
#include <bits/stdc++.h> using namespace std; int main() { int a[101], dif[100], i, unique[101], c = 0; int min = 0, n, dif1, dif2; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); unique[c] = a[0]; c++; for (i = 1; i < n; i++) { if (a[i] != a[i - 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...
/* Copyright (c) 2014 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,...
/* * Copyright (c) 2002 Stephen Williams () * * 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) * ...
//---------------------------------------------------------------- //-- Inicializador //-- (c) BQ. August 2015. Written by Juan Gonzalez (obijuan) //-- GPL license //---------------------------------------------------------------- //-- Generacion de una señal escalo (0 -> 1) para inicializar //-- circuitos digitales //...
#include <bits/stdc++.h> using namespace std; template <class T> bool ckmax(T& x, T y) { return x < y ? x = y, 1 : 0; } template <class T> bool ckmin(T& x, T y) { return x > y ? x = y, 1 : 0; } inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if...
#include <bits/stdc++.h> using namespace std; void go() { ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed; cout << setprecision(6); } void solve() { string s; cin >> s; long long n = s.size(); vector<long long> arr(n); long long cur = 0; for (long long i = 0; i < ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; map<pair<int, long long>, bool> vis; map<pair<int, long long>, int> memo; int grundy(int x, long long mask) { for (int i = 61; i > x; i--) { if ((mask >> i) & 1) mask ^= (1ll << i); } if (vis[{x, mask}]) return memo[{x, ...
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int n, h; cin >> h >> n; int a[n]; for (int i = 0; i < n; ++i) cin >> a[i]; int cnt = 1; vector<int> v; for (int i = 1; i < n; ++i) { if (a[i] == a[i - 1] - 1) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 505; int a[maxn][maxn], b[maxn][maxn]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf( %d , &a[i][j]); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j+...
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; using namespace std::chrono; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; string s; cin >> s; long long int a[26]; for (int i = 0; i < 26; i++) cin >> a[i]; ...
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> inline istream& operator>>(istream& fin, pair<T1, T2>& pr) { fin >> pr.first >> pr.second; return fin; } template <class T0, class T1, class T2> inline istream& operator>>(istream& fin, tuple<T0, T1, T2>& t) { fin >> get...
/** * 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 N = 100005; char en = n ; long long inf = 1e16; long long mod = 1e9 + 7; long long power(long long x, long long n, long long mod) { long long res = 1; x %= mod; while (n) { if (n & 1) res = (res * x) % mod; x = (x * x) %...
#include <bits/stdc++.h> using namespace std; string st; vector<long> v; long r; int main() { ios_base::sync_with_stdio(0); cin >> st; st += + ; for (int i = 0; i < st.size(); i++) { if (st[i] == + ) { v.push_back(r); r = 0; } else r = r * 10 + st[i] - 48;...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353, MAX = 100003, INF = 1 << 30; long long rui(long long a, long long b) { if (b == 1) return a % mod; else if (b == 0) return 1; else if (b % 2 == 0) return (rui(a, b / 2) * rui(a, b / 2)) % mod; else ret...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: California State University San Bernardino // Engineer: Bogdan Kravtsov // Tyler Clayton // // Create Date: 11:22:00 10/24/2016 // Module Name: I_DECODE_tb // Project Name: MI...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 00:30:44 03/22/2015 // Design Name: fulladder1bit // Module Name: C:/Users/Joseph/Documents/Xilinx/HW1/fulladder1bit_test.v // Project Name: HW1 // Target ...
// Copyright (c) 2016 CERN // Maciej Suminski <> // // 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) // any late...
#include <bits/stdc++.h> using namespace std; int n, first, a[1111]; int b[1111], ub = -1, pos; vector<int> c[1111]; vector<int> d; int can[1111]; void go(int p, int v) { if (v == -1) return; if (v == first) ub = p; c[p].push_back(v); go(p, a[v]); } int main() { scanf( %d%d , &n, &...
/** * sseg_driver.v - Microcoded Accumulator CPU * Copyright (C) 2015 Orlando Arias, David Mascenik * * 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,...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: None // Engineer: Dai Tianyu (dtysky) // // Create Date: 2015/04/07 18:01:07 // Design Name: // Module Name: Mux8 // Project Name: // Target Devices: // Tool Versions: // Description: // // Depende...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } bool isPrime(long long n) { if (n < 2) return 0; if (n < 4) return 1; if (n % 2 == 0 or n % 3 == 0) return 0; for (long long i = 5; i * i <= n; i += 6) ...
#include <bits/stdc++.h> using namespace std; void print(int x) { cerr << x; } void print(long x) { cerr << x; } void print(long long x) { cerr << x; } void print(unsigned x) { cerr << x; } void print(unsigned long x) { cerr << x; } void print(unsigned long long x) { cerr << x; } void print(float x) { c...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<long long> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } int m; cin >> m; long long ans = 0; long long wt = 0, ht = 0; ...
#include <bits/stdc++.h> using namespace std; const int maxint = -1u >> 1; template <class T> bool get_max(T& a, const T& b) { return b > a ? a = b, 1 : 0; } template <class T> bool get_min(T& a, const T& b) { return b < a ? a = b, 1 : 0; } int main() { int f[21]; int a, b, c; cin ...
/*TODO: Test byte masks Add timeout Add FIFO mode */ module wb_bfm_transactor #(parameter aw = 32, parameter dw = 32, parameter VERBOSE = 0, parameter MAX_BURST_LEN = 5, parameter MEM_LOW = 0, parameter MEM_HIGH = 32'hffffffff) (input wb_clk_i, input wb_rst_i, output...
#include <bits/stdc++.h> using namespace std; const int maxn = 4e5 + 5; int fa[maxn]; int m, n, q, i, x, y; int getfa(int x) { if (x == fa[x]) return x; return fa[x] = getfa(fa[x]); } int main() { scanf( %d%d%d , &n, &m, &q); for (i = 1; i <= m + n; i++) fa[i] = i; for (i = 1; i <= q; ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int main() { ios_base ::sync_with_stdio(false); ; cin.tie(NULL); ; long long int t = 1; while (t--) { long long int n; cin >> n; pair<long long int, long long int> tree[n]; long long int i, j, k; map<pair<long long 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; void doRoutine() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); srand(322179); } signed main() { doRoutine(); long long n; cin >> n; long long res = 0; while (n > 0) { ++res; n /= 2; } ...