text
stringlengths
59
71.4k
#include <bits/stdc++.h> struct Node { int d[10]; }; Node a[401][401]; char p[401][401]; int main() { int i, j, n, m, res; while (scanf( %d%d , &n, &m) != EOF) { res = 0; for (i = 0; i < n; i++) scanf( %s , p[i]); for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { ...
#include <bits/stdc++.h> using namespace std; vector<int> v[100010], ans; int idx = 1; void dfs(int cur, int prev) { if ((int)v[cur].size() == 1 && cur != idx) ans.push_back(cur); else { for (int i = 0; i < (int)v[cur].size(); i++) { int j = v[cur][i]; if (j != prev) dfs(j, c...
/** * 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 d[3000], g[3000], q[3000]; int i, j, k, m, n, r, t; int main() { scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) { scanf( %d , &g[i]); if (g[i] <= m) d[g[i]]++; else r++; } for (k = 0;; k++) { t = 1; for (i = 2; i <= m; i++...
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { long long prod = 1; while (b) { if (b & 1) prod = (prod * a); a = (a * a); b >>= 1; } return prod; } int main() { int t; cin >> t; while (t--) { int n; cin >> n; ...
#include <bits/stdc++.h> using namespace std; int n, a[2 * 100004], b[2 * 100004], c[2 * 100004], poz, x; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; c[a[i]] = 1; } poz = 1; for (int i = 1; i <= n; ++i) { cin >> b[i]; ...
#include <bits/stdc++.h> using namespace std; const int K = 105; const int N = (int)1e4 + 100; int c[N]; long double dp[K][N]; long double C[K][K]; long double fact[K]; int main(int, char **) { fact[0] = 1; for (int i = 0; i < K; i++) { if (i != 0) fact[i] = fact[i - 1] * i; C[i][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 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.2 (lin64) Build Thu Jun 2 16:32:35 MDT 2016 // Date : Tue Dec 6 23:14:21 2016 // Host : brian-Inspiron-5547 running 64-bit Ubuntu 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...
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; int maxn = 1e9, minn = -1e9; long long modpow(long long base, long long exp, int modulus) { base %= modulus; long long result = 1; while (exp > 0) { if (exp & 1) result = (result * base) % modulus; base = (base * base...
#include <bits/stdc++.h> using namespace std; long long n, m; int main() { string a, b; cin >> a >> b; for (int i = 0; i < a.length(); i++) { if (a[i] < b[i]) { cout << -1 << endl; return 0; } } cout << b << endl; return 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; map<string, string> m; int main() { long long int n, mm, i; string s, b, s1, b1; cin >> n >> mm; for (i = 0; i < n; i++) { cin >> s >> b; m[b] = s; } char c; for (i = 0; i < mm; i++) { cin >> s1 >> b1; int l = b1.len...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, a; vector<pair<int, int> > v; cin >> n; for (i = 0; i < n; ++i) { cin >> a; v.push_back(make_pair(a, i + 1)); } for (i = 0; i < n; ++i) { cin >> a; v.push_back(make_pair(a, i + 1)); } long lo...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); class domino { public: int data[4]; bool IsEqual(domino b) { for (long long move = 0; move <= 3; move++) { bool f = true; for (long long i = 0; i <= 3; i++) if (data[i] != b.data[(i + move) % 4])...
#include <bits/stdc++.h> using namespace std; const int S = 100003; int n, a[S], f[353][S], nn, bl[S], fr[353], to[353], m, bg[353], ed[353], las = 0; deque<int> q[353]; void read(int &s) { s = 0; char c = getchar(), t = 1; while (c != - && (c < 0 || c > 9 )) c = getchar(); if (c ==...
// Copyright (c) 2014 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...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
/* * 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; void solve() { int n, l; cin >> n >> l; vector<int> flags(n + 2); flags[0] = 0, flags[n + 1] = l; for (int i = 0; i < n; ++i) { cin >> flags[i + 1]; } vector<double> s(n + 2); vector<double> e(n + 2); s[0] = 0; e[n + 1] = 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; int main() { string ans = , s; int n; cin >> s >> n; for (int i = 0; i < n; i++) { string t; cin >> t; if (t.length() >= s.length()) if (s == t.substr(0, s.length())) if (ans == || ans > t) ans = t; } if (...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 10010; int f[2][N], g[2][N], a[N], ans[N], b[N], pr[N]; inline int qpow(long long a, int b, const int p) { int ret = 1; a %= p; while (b) { ret = ret * 1ll * (b & 1 ? a : 1) % p; a = a * a % p, b >>= 1...
/* * draw lines * * (c) Arlet Ottens <> */ module line( input clk, /* * vector info: * This module outputs the vector number, and expects to get * the coordinates + color back on the next cycle when * read_vector=1. If read_vector=0, the previous values must be * maintained. * * (x0,y0) indicate...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int maxm = 1e5 + 5; const long double eps = 1e-14; const long double eps2 = 1e-9; const long double INF = 1 << 30; inline int dcmp(const long double& x) { return fabs(x) < eps ? 0 : (x < 0 ? -1 : 1); } template <typename...
#include <bits/stdc++.h> using namespace std; long long V[10005], O[10005], F[1005][10005]; int c[1005], cost[1005]; int n, W, B, X; struct Queue { int p[1005], q[1005]; long long maxp[1005], maxq[1005]; void clear() { *p = 0; *q = 0; maxp[0] = maxq[0] = -1; } void add(in...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; void solve() { long long v, c, vv, cc; cin >> v >> c >> vv >> cc; long long f = 0; if (cc > min(v, c)) { cout << NO n ; return; } v += c; vv += cc; if (vv > v) { cout << NO n ; retu...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); int* x = new int[2 * n]; int odd = 0; int even = n; int len = n - 1; for (int len = n - 1, i = 1; len > 0; len--, i++) if (i % 2 == 1) { x[odd] = i; x[odd + len] = i; odd++; ...
#include <bits/stdc++.h> int main() { int n, pur, foo = 0, quz = 1, bar = 0, baz = 0; scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &pur); foo += pur, bar++; if (foo * quz > bar * baz) quz = bar, baz = foo; } printf( %.6lf n , (double)baz / quz); return 0; } ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; int head[10010], cnt = 1, cur[10010], dis[N], s, t; struct edge { int next, to, w; } e[N << 1]; struct query { int u, t; } q[N]; int main() { auto add = [&](int u, 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 ...
#include <bits/stdc++.h> using namespace std; long long M = 1e9 + 7; const int N = 3e5 + 7; const int K = 5e3 + 7; int n, k; int a[N]; int dp[K][K]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); int top = (n + k - 1) / k; ...
#include <bits/stdc++.h> const int MAXN = 100010; int flag[MAXN << 2]; int a[MAXN << 2]; int add; int N, Q; void PushDown(int rt) { int lc = rt << 1; int rc = rt << 1 | 1; if (flag[rt]) { flag[lc] += flag[rt]; flag[rc] += flag[rt]; flag[rt] = 0; } return; } void bui...
/** * 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 = 1e9 + 7; int a[2010]; bool vis[2010]; long long sum; vector<int> edge[2010]; long long DFS(int u, int d, int fa, int root) { long long ret = 1; for (int i = 0; i < edge[u].size(); i++) { int v = edge[u][i]; if (v != fa...
#include <bits/stdc++.h> using namespace std; long long int m, n, i; long long int a[1000000], ans, sum[1000000] = {0}, x; int check(long long int k) { x = 0; for (i = 1; i <= n; i++) { if (a[i] - (i - 1) / k > 0) x = x + a[i] - (i - 1) / k; } if (x >= m) return 1; else ret...
#include <bits/stdc++.h> using namespace std; struct point { int x, y; }; int dist(const point &a, const point &b) { return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y); } int main(int argc, char *argv[]) { point p[8]; int a[8] = {0, 1, 2, 3, 4, 5, 6, 7}; for (int i = 0; i < 8; ...
#include <bits/stdc++.h> using namespace std; int dp[51][51], n; int len[2]; bool ok[2][26][51][51]; char str[50][51], s[2][51]; void Init(int id) { int st, ed, L, mid; for (int i = 0; i < len[id]; i++) ok[id][s[id][i] - a ][i + 1][i + 1] = true; for (L = 2; L <= len[id]; L++) for (st = 1...
#include <bits/stdc++.h> using namespace std; const int N = (int)123; long long dp[N]; void solve() { long long n, k; scanf( %lld %lld , &n, &k); if (k == 1) { printf( YES %lld n , n - 1); return; } if (n > 31) { printf( YES %d n , n - 1); return; } long long ...
#include <bits/stdc++.h> using namespace std; int main() { int n, c; long long t, a; scanf( %d%lld%d , &n, &t, &c); int ans = 0, tmp = 0; for (int i = 0; i < n; i++) { scanf( %lld , &a); if (a > t) { tmp = 0; } else { tmp++; if (tmp >= c) { ans...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = 0; i < n; i++) arr[i] -= 1; for (int i = 0; i < n; i++) { int count = 1; int ...
module MMIO_slave( input fclk, input rst_n, //AXI Inputs output S_AXI_ACLK, input [31:0] S_AXI_ARADDR, input [11:0] S_AXI_ARID, output S_AXI_ARREADY, input S_AXI_ARVALID, input [31:0] S_AXI_AWADDR, input [11:0] S_AXI_AWID, output S_AXI_AWREADY, input S_AXI_AWVALID, ou...
// DESCRIPTION: Verilator: Verilog Test module // // Copyright 2010 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. `ifdef USE_VPI_NOT_DPI //We call it ...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // 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 la...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, k, b, e; cin >> n >> k; if (n == 1) { cout << 0 << endl; return 0; } long long p = ((k - 1) * k) / 2 - 1; if (n >= 2 && n <= (p + 2)) { b = 2; ...
#include <bits/stdc++.h> using namespace std; const int N = 111; const int INFI = 2147483627; int a[N], b[N]; int main() { int n, ans = -1, flag, t; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); for (int i = 1; i < n; i++) { b[i - 1] = a[i] - a[i - 1]; if (ans < ...
// 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 27 19:26:50 2017 // Host : GILAMONSTER running 64-bit major release (...
module trv_decoder ( input wire [31:0] inst, output wire [2:0] alu_op, output wire [5:0] alu_arg, output wire sel_rs1, output wire sel_rs2, output wire sel_rd, output wire [4:0] rd, output wire [4:0] rs1, output wire [4:0] rs2, output wire [31:0] imm, output wire is_rd_mem, output wire is_wr_mem...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s, t; cin >> s >> t; vector<int> f1(26); vector<int> f2(26); for (int i = 0; i < n; i++) { f1[s[i] - 97]++; f2[t[i] - 97]++; } int f = 0; for (int i = 0; i < 26; i++) { if (f1...
#include <bits/stdc++.h> using namespace std; map<string, int> ma; map<string, int>::iterator p; long i, n, m; double ex, k; int main() { cin >> n >> m >> k; string st; for (i = 1; i <= n; i++) { cin >> st >> ex; ma[st] = (int)(ex * k + 1e-9); if (ma[st] < 100) ma.erase(st); ...
#include <bits/stdc++.h> using namespace std; int main() { map<int, int> m; string s; int n, a; cin >> n >> s; for (int i = 1; i < 10; ++i) { cin >> a; m[i] = a; } for (int i = 0; i < n; ++i) { if (s[i] - 0 < m[s[i] - 0 ]) { while (s[i] - 0 <= m[s[i] - 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; int n; pair<long long, long long> a[100005]; long long pymax[100005], pymin[100005]; long long symax[100005], symin[100005]; bool trial(long long x) { for (int i = 0; i < n; i++) { symax[i] = pymax[i] = a[i].second - x; symin[i] = pymin[i] = a[i]...
#include <bits/stdc++.h> using namespace std; long long int n, a[1000005], an = 0, fact = 1; long long int egcd(long long int aa, long long int bb, long long int &xx, long long int &yy) { if (aa == 0) { xx = 0, yy = 1; return bb; } long long int x1, y1, dd; dd = eg...
/** * 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; long long n, k, a[100100]; int main() { scanf( %lld %lld , &n, &k); int temp = 0, t = 0; vector<int> v; for (int i = 1; i <= n; i++) { long long x; scanf( %lld , &x); if (temp + (i - n) * x * 1ll * (i - t - 1) < k) { v.push_ba...
// Double pumped single precision floating point multiply // Latency = 6 kernel clocks // // (C) 1992-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, an...
//------------------------------------------------------------------------------ // YF32 -- A small SOC implementation based on mlite (32-bit RISC CPU) // @Taiwan //------------------------------------------------------------------------------ //...
/* * Copyright (c) 2004 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) * ...
/******************************************************************************* * 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 ...
/************************************** * Module: vc * Date:2016-01-27 * Author: sara * * Description: virtual channel ***************************************/ `include "constants.v" module vc( output reg [1:`FLIT_SIZE] flit_buff, output reg credit, output reg is_new, input [...
#include <bits/stdc++.h> using namespace std; const int N = 1000005; long long A[N], B[N], n, xx, mx; bool check(int n, int m) { int x = n - xx, y = mx - x; if (x < 0 || x >= n || y < 0 || y >= m) return 0; memset(B, 0, sizeof(B)); for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) ++...
#include <bits/stdc++.h> using namespace std; const int MAX = 500005; long long a[MAX], pre[MAX], suf[MAX], t; int main() { int ans = -1, pos = 0, n; scanf( %d , &n); for (register int i = 1; i <= n; i++) { scanf( %lld , &a[i]); pre[i] = pre[i - 1] | a[i]; } for (register int 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...
// (C) 1992-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 simulati...
#include <bits/stdc++.h> using namespace std; string lower(string second) { for (int i = 0; i < second.size(); i++) if (second[i] >= A && second[i] <= Z ) second[i] = second[i] - A + a ; return second; } char reg(char c, char t) { if (c >= A && c <= Z ) return t - a + A ; retur...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: sparc_tlu_zcmp64.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 ...
#include <bits/stdc++.h> using namespace std; int main() { int tests; cin >> tests; while (tests--) { int n, s, t; cin >> n >> s >> t; cout << min(max(s, t) + 1 - (s + t - n), n + (n - s - t) + 1) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int f(char c) { return c - 48; } void soroban(int n, char *ans) { if (n < 5) { ans[0] = O ; ans[1] = - ; ans[2] = | ; for (int i = 3; i <= 7; i++) { if (i == n + 3) { ans[i] = - ; } else { ans[i] = O...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10/02/2016 // Design Name: // Module Name: vga_noise // Project Name: // Target Devices: // Tool versions: // Description: generate 8-bit VGA output with the...
/* * 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, m; char a[60][60]; bool isRowChecked[60]; bool isColChecked[60]; bool doCheck(int r, int c) { bool isRowRegard[60]; bool isColRegard[60]; memset(isRowRegard, false, sizeof(isRowRegard)); memset(isColRegard, false, sizeof(isColRegard)); ...
module Controller(input clk, reset, z, input [2:0] inst_op, output reg ir_write, B_write, pc_src, pc_write, mem_src, mem_write, stack_src, tos, push, pop); parameter [2:0] IF = 3'b000, ID = 3'b001, POP_B = 3'b010, POP_A = 3'b011, PUSH_ALU = 3'b100, PUSH_INST = 3'b101, POP_INST = 3'b110, JMP = 3'b111; reg [2:0] ...
#include <bits/stdc++.h> using namespace std; struct segment_tree { int val[200005 << 2]; inline void update(int l, int r, int k, int x, int w) { if (l == r) { val[k] = w; return; } int mid = l + r >> 1; if (x <= mid) update(l, mid, k << 1, x, w); else ...
/*************************************************************************************************** ** fpga_nes/hw/src/nes_top.v * * Copyright (c) 2012, Brian Bennett * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the follow...
/** * 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 L = 21; const int N = 1 << L; int n, ans, a[N], best[N][3]; void add(int mask, int value) { auto &b = best[mask]; b[2] = value; if (b[2] > b[1]) swap(b[2], b[1]); if (b[1] > b[0]) swap(b[1], b[0]); } bool possible() { for (int i =...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:500000000 ) using namespace std; int main() { int n, i, s; scanf( %d %d , &n, &s); vector<int> a(n); for (i = 0; i < n; i++) { scanf( %d , &a[i]); } sort(a.begin(), a.end()); long long res = 0; int pos = n / 2; if (...
/** * 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; int main() { cin >> n; int cur = 1; while (n) { if (n == 3) { printf( %d %d %d , cur, cur, cur * n); return 0; } int cnt = n / 2 + n % 2; n -= cnt; while (cnt--) printf( %d , cur); cur *= 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 la...
#include <bits/stdc++.h> using namespace std; const int N = 110000; string s; int n, cnt1, cnt0, cntq, m, p; char last0, last1; int may01, may10; int main() { cin >> s; n = s.size(); for (int i = 0; i < n; i++) if (s[i] == 1 ) cnt1++; else if (s[i] == 0 ) cnt0++; ...
#include <bits/stdc++.h> using namespace std; int main() { int l, r, i, j, d, tp; cin >> l >> r; bool f; for (i = l; i <= r; i++) { tp = i; int arr[10]; for (j = 0; j < 10; j++) arr[j] = 0; while (tp > 0) { d = tp % 10; tp = tp / 10; arr[d]++; } ...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.1 (lin64) Build 881834 Fri Apr 4 14:00:25 MDT 2014 // Date : Tue May 13 22:55:34 2014 // Host : macbook running 64-bit Arch Linux // ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 300005; int q, n; int a[MAXN], lef[MAXN], rig[MAXN]; vector<int> v; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> q; while (q--) { cin >> n; for (int i = 1; i <= n; i++) { lef[i] = rig[i] =...
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx ) #pragma GCC optimize( O2 ) using namespace std; void timestamp(char const* const tag, bool absolute = false); int x2; void read() { cin >> x2; } vector<int> get_divs(int x) { vector<int> ans; for (int d = 2; d *...
/** * 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...
`define SIM_PATH "../../../sim/" //registe address `define REG_CTRL 8'h00 `define REG_STS 8'h04 `define REG_OP 8'h08 `define REG_MSEL 8'h0C `define REG_INV 8'h10 `define REG_M0VAL 8'h14 `define REG_M0MAX 8'h18 `define REG_M0MIN 8'h1C `define REG_M1SPOS 8'h20 `define REG_M1SIZE 8'h24 `define REG_...
`timescale 1ns/1ps module lookup_bit( clk, reset, set_valid, set_data, read_valid, addr, data_out_valid, data_out, key_valid, key, bv_valid, bv ); input clk; input reset; input set_valid; input [35:0] set_data; input read_valid; input [8:0] addr; output reg data...
#include <bits/stdc++.h> using namespace std; int main() { long long a = 1, n; cin >> n; for (int i = 0; i < n; i++) { a *= i + 1; } cout << a * 2 / n / n; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; string s; cin >> n >> s; string an = ; for (int i = 0; i < s.length(); i += 2) { cout << s[i]; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = s...
// module ddr3_int_ex_lfsr8 ( clk, reset_n, enable, pause, load, data, ldata); parameter seed = 32; input clk; input reset_n; input enable; input pause; input load; output[8 - 1:0] data; wire[8 - 1:0] data; input[8 - 1:0] ldata; reg[8 - 1:0] lfsr_data; assign data = lfsr_data ; ...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.2 (win64) Build Thu Jun 15 18:39:09 MDT 2017 // Date : Wed Sep 20 21:29:07 2017 // Host : EffulgentTome running 64-bit major rele...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; const int N = 1e5 + 2; vector<pair<int, int> > seg[3 * N][2]; long long int sig[3 * N]; int a[N]; vector<pair<int, int> > m[2]; int n, x; inline long long int mrg(vector<pair<int, int> > ...
#include <bits/stdc++.h> using namespace std; int main() { int arr[101] = { 0, }; int n; scanf( %d , &n); for (int i = 0; i < n; i++) { int t; scanf( %d , &t); for (int j = 0; j < t; j++) { int tmp; scanf( %d , &tmp); arr[tmp]++; } } ...
/** * 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; double a, b, c; int main() { while (~scanf( %lf%lf%lf , &a, &b, &c)) { double x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a), x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a); if (a < 0) swap(x1, x2); printf( %.6lf n%.6lf n , x1, x2); ...