text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; vector<int> edges[8]; int calc(int a, int b) { vector<int> cnt(8); for (auto e : edges[a]) cnt[e]++; for (auto e : edges[b]) cnt[e]++; int sol = 0; for (int i = 1; i <= 7; i++) if (cnt[i] == 2) sol++; return sol; } int main() { io...
#include <bits/stdc++.h> using namespace std; struct ss { long long sur, x, y, z; ss() {} ss(long long a, long long b, long long c, long long d) { sur = a; x = b; y = c; z = d; } } ans; int n, tot, a[100], b[100]; long long x, uu, p[100], u[200000]; long long calc(lon...
#include <bits/stdc++.h> using namespace std; int s[50]; char a[55][55]; int main() { int n, i, j, c = 1, k, found; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %s , a[i]); int l = strlen(a[i]); for (j = 0; j < l; j++) { s[a[i][j] - a ]++; } } for (i = 0...
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; const long long INF = (long long)1 << 60; long long x[maxn], y[maxn], n; inline long long sqr(long long x) { return x * x; } long long p[maxn], cnt; long long ans; bool cmpy(int a, int b) { return y[a] < y[b]; } void solve(int l, 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...
/** * 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...
// // Generated by Bluespec Compiler, version 2018.10.beta1 (build e1df8052c, 2018-10-17) // // // // // Ports: // Name I/O size props // mv_read O 64 // mav_write O 64 // CLK I 1 clock // RST_N ...
// // Author: Farzad Farshchi <> // Date: Dec 2012 // Simulator: ModelSim 6.6 // Compiler: Design Compiler C-2009.06-SP5 module mult_bth_app_signed( out, in1, in2 ); parameter wl = 4, vbl = 0; output reg signed [wl*2-1:0] out; input signed [wl-1:0] in1, in2; // x, y ...
/** * 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...
#include <bits/stdc++.h> using namespace std; const int N = 2e7 + 7; long long mn = (long long)(1e18 + 7), mx = -(long long)(1e18 + 7); long long n, m, k, s, q, t; long long a, b, c, d, e; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> a >> b >> c >...
#include <bits/stdc++.h> int main() { int a, b, c, i, l; scanf( %d%d%d , &a, &b, &c); if (a > b) { for (i = a; i > 0; i++) { if (i % a == 0 && i % b == 0) { l = i; break; } else { continue; } } } else if (b > a) { for (i = b; i > ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1E5; int a[MAXN]; long long pref[MAXN]; long long suff[MAXN]; int main() { int n, d, m; cin >> n >> d >> m; int bigger = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > m) bigger++; } sort(a, a + n); ...
/** * 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 round_robin_4 ( input wire clock, input wire reset, input wire [3:0] request, output wire [3:0] grant ); reg [$clog2(4)-1:0] counter; wire [3:0] priority [3:0]; assign grant[0-:1] = priority[0][0-:1] | priority[1][3-:1] | priority[2][2-:1] | priority[3][1-:1] ; ...
#include <bits/stdc++.h> using namespace std; const long long maxm = 1e+18; vector<long long> prime; long long power(long long x, long long y) { long long res = 1; x = x % 1000000007; while (y > 0) { if (y & 1) res = (res * x) % 1000000007; y = y >> 1; x = (x * x) % 1000000007; ...
// slice // Full Adder rtl // default_slice module full_adder (in_x, in_y, carry_in, sum_out, carry_out); input in_x; input in_y; input carry_in; output sum_out; output carry_out; wire w_sum1; wire w_carry1; wire w_carry2; assign carry_out = w_carry1 | w_carry2; // Insta...
module genetico(conf_les, conf_outs, in, out); input [10:0] conf_les[8:0]; input [3:0] conf_outs[1:0]; input [2:0] in; output [1:0] out; wire [8:0] le_out; wire [11:0] all_inputs; assign all_inputs = {le_out, in}; assign out = {all_inputs[conf_outs[1]], all_inputs[conf_outs[0]]}; logic_e le00( .conf_f...
// 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 Ge...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of avfb_logic // // Generated // by: wig // on: Tue Apr 18 07:50:26 2006 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl -nodelta ../../bugver.xls // // !!! Do not edit this file! Autogenerated by MIX !!...
#include <bits/stdc++.h> using namespace std; int lg[1000005], jump[1000005][20], depth[1000005], head[1000005], cnt = 4; int q, tot, s, t, zj; struct edge { int to, next; } e[2000005]; void add(int x, int y) { e[++tot].to = y; e[tot].next = head[x]; head[x] = tot; } void dfs(int now, in...
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0; bool flag = false; int a[105]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n; i++) { if (a[i] == 2) { if (a[i - 1] == 1) { if (i >= 2 && a[i - 2] == 3) an...
/* ------------------------------------------------------------------------------- * (C)2012 Korotkyi Ievgen * National Technical University of Ukraine "Kiev Polytechnic Institute" * ------------------------------------------------------------------------------- * * Mesh Network with LAG * */ module LAG_mesh_...
// megafunction wizard: %RAM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: cyclone4gx_dmem.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ========================...
#include <bits/stdc++.h> using namespace std; const int N = (1 << 20) + 15; long long dp[N]; pair<int, int> id[100]; int bit[100], c[100], st[N]; int main() { int u, a, mi, n, m, i, j, b, x, p = 0, idd; long long k, temp; long long ret = 4e18; scanf( %d%d%d , &n, &m, &b); for (i = 0; i <...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pi = pair<int, int>; using pll = pair<ll, ll>; int n, k; vector<int> x; bool disjoint(int l1, int r1, int l2, int r2) { return r1 < l2 || r2 < l1; } int main() { ios_base::sync_with_stdio(false); cout << setprecision(12); ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20); int m; cin >> m; string s; cin >> s; int n = s.size(); vector<int> cnt(26); vector<int> have(n); for (int c = 0; c < 26;...
/** * 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 la...
`timescale 1ns/1ps `include "alu.pkg" `define DISABLE_CHECKER1 `define DISABLE_CHECKER2 `define DISBALE_CHECKER3 `define DISABLE_CHECKER4 `define DISABLE_CHECKER5 module alu_chkr ( // Global inputs input clk, input reset_n, // Control inputs input ...
#include <bits/stdc++.h> using namespace std; map<string, int> globmap; int optwin[32000]; int optptsc[32000]; int optptso[32000]; int pts[32000]; map<string, int> hashid; string hashinv[32000]; void findit(int s) { if (optwin[s] != -1) { return; } string S = hashinv[s]; string a...
#include <bits/stdc++.h> using namespace std; int light[3000]; int agr[3000]; int main() { int n; scanf( %d , &n); int m = pow(2, n + 1) - 1; for (int i = 2; i <= m; i++) { scanf( %d , &light[i]); } int ans = 0; for (int i = m; i >= 3; i--) { if (i % 2 == 0) continue; ...
#include <bits/stdc++.h> using namespace std; template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>; template <class T, class U> inline void MAX(T &a, U b) { if (a < b) a = b; } template <class T, class U> inline void MIN(T &a, U b) { if (a > b) a = b; } template <clas...
#include <bits/stdc++.h> using namespace std; vector<int> A[100005]; int main() { int n, m, i, j; cin >> n >> m; if (n < 4 and m < 4) { bool adj[10][10] = {}, adj2[10][10]; int A[n][m], B[n][m]; for (i = 0; i < n; i++) for (j = 0; j < m; j++) A[i][j] = i * m + j + 1; fo...
/** * 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 ll mod = 998244353; int n, m, t[1 << 19]; struct segTree { struct { ll kk, bk, kb, bb; } a[1 << 20]; void upd(int p, int l, int r) { int mid = l + r >> 1, v = t[mid] == 1 ? 9 - t[mid + 1] : 0; a[p].kk = a[p...
#include <bits/stdc++.h> using namespace std; int n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; long long ans = 0; for (int i = 2; i <= n; i++) for (int j = i + i; j <= n; j += i) ans += j / i; cout << ans * 4 << endl; }
/** * 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; const long long inf = 1e18; const long double pie = acos((long double)-1); int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; unordered_map<int, vector<int>> mp; int indegree[1001]; void addedge(int x, int y) { mp[x].pus...
#include <bits/stdc++.h> using namespace std; template <class X, class Y> bool minimize(X &x, const Y &y) { X eps = 1e-9; if (x > y + eps) { x = y; return true; } else return false; } template <class X, class Y> bool maximize(X &x, const Y &y) { X eps = 1e-9; if (x + ep...
module ham_15_11_encoder ( d, c ); input [10:0] d; output [14:0] c; wire n84, n85, n86, n87, n88, n89, n90, n91, n92, n93, n94, n95, n96, n97; assign c[14] = d[10]; assign c[13] = d[9]; assign c[12] = d[8]; assign c[11] = d[7]; assign c[10] = d[6]; assign c[9] = d[5]; assign c[8] = d[4]; assign...
#include <bits/stdc++.h> using namespace std; const long long N = (long long)(5e5) + 322; const long long INF = (long long)(1e9); const long long mod = (long long)(1e9) + 7; const double eps = 1e-9; int xp, yp, xv, yv, distp, distv; int main() { ios_base ::sync_with_stdio(false); cin.tie(0); c...
/** * fillbox_act.v: fillbox accelarator controle logic */ module fillbox_act ( input wire [27:0] vram, input wire [9:0] width, input wire [9:0] height, input wire start, output wire done, // AXI4 stuff input wire clk, input wire bready, output reg [27:0] awaddr, output reg burst_start, output reg [7:0] ...
#include <bits/stdc++.h> using namespace std; long long a, b, x, y, t; int main() { cin >> t; while (t--) { cin >> a >> b >> x >> y; if (a > b) swap(a, b); cout << abs(a - b) * x + min(y, x * 2) * a << endl; } }
/** * 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 BiquadSingle_tb (); reg clk; reg rst; reg en; reg signed [17:0] dataInCos; reg signed [17:0] dataInSin; wire signed [17:0] dataOutCos; wire signed [17:0] dataOutSin; wire outStrobeCos; wire outStrobeSin; real magnitude; real angle; real temp; integer i, j; localparam MATH_PI = 3.14159; function real ChirpSi...
/* * 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...
// Copyright (c) 2013 Andrew Downing // 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 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
`timescale 1ns / 1ps module testbench(); reg clk = 0, rst = 1; wire [1:0] status_led; always begin clk = 1; #5; clk = 0; #5; end initial begin // Wait for the memory to become fully accessible. // According to the N25Q datasheet the interval should be >= 600 us...
#include <bits/stdc++.h> using namespace std; long long n, k; long long pow(long long a, int b) { if (b == 0) return 1; long long base = pow(a, b >> 1); base = base * base; if (b & 1) base = base * a; return base; } long long f(long long n) { if (n == 1) return 1; map<long long, in...
`include "hrfp_defs.vh" module hrfp_mult_normalize (output reg expdiff, output reg [53:0] normalized_mantissa, input wire clk, input wire [53:0] mantissa4, mantissa5); parameter EARLY_EXPDIFF = 1; parameter EARLY_NORMALIZE = 0; generate // IDEA: In case of emergency: Can check...
#include <bits/stdc++.h> using namespace std; const long long mx = 19; const long long mx1 = 262150; long long s[mx]; long long n, m, k; long long extra[mx][mx]; long long dp[mx][mx1]; long long solve(long long prev, long long bitmask, long long m) { if (m == 0) return 0; if (dp[prev][bitmask] !...
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}; void solve() { int n; cin >> n; int a[n + 1]; for (int i = 0; i < n; i++) { int x; cin >> x; a[x] = i; } int l = 0, r = n - 1; for (int i = n; i > 0; i--) { if (a[i] ==...
#include <bits/stdc++.h> using namespace std; stack<int> ST, SI; vector<int> P; char OR[10000], TEMP[10000]; int L, S, C; int main() { while (scanf( %s , TEMP) == 1) strcat(OR, TEMP); L = strlen(OR); for (S = 0; S < L;) { if (OR[S + 2] == a ) ST.push(0), SI.push(C), C = 0, S += 7;...
module note2dds_3st_gen(CLK, NOTE, ADDER); input wire CLK; input wire [6:0] NOTE; output [31:0] ADDER; reg [31:0] ADDER_tbl [15:0]; reg [3:0] addr; reg [3:0] divider; // note div 12 ( * 0,08333333333333333333333333333333) //; Add input / 16 to accumulator //; Add input / 64 to accumulator initial begin addr <= 4...
module check (input unsigned [22:0] a, b, c); wire unsigned [22:0] int_AB; assign int_AB = a + b; always @(a, b, int_AB, c) begin #1; if (int_AB !== c) begin $display("ERROR"); $finish; end end endmodule module stimulus (output reg unsigned [22:0] A, B); parameter MAX = 1 << 23; parameter S ...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2009 Xilinx, Inc. // This design is confidential and proprietary of Xilinx, All Rights Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ /...
/* Top level module for button demo WITH debouncing This uses button 1 of the keypad when installed correctly. */ module top ( // input hardware clock (12 MHz) hwclk, // LED led1, // Keypad lines keypad_r1, keypad_c1, ); /* Clock input */ input hwclk; /* LED outputs ...
#include <bits/stdc++.h> using namespace std; int z[201010]; int cost[201010], acc[201010]; string s, aux, text, text2, patt; pair<int, int> dp[201010]; void build() { text = aux; text2 = aux; int n = (int)aux.size(); for (int i = 0; i < n; i++) { cost[i] = -1; acc[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 la...
// Copyright (C) 2020-2021 The SymbiFlow Authors. // // Use of this source code is governed by a ISC-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/ISC // // SPDX-License-Identifier:ISC (* techmap_celltype = "$alu" *) module _80_quicklogic_alu (A, B, CI, BI, X, Y, CO);...
#include <bits/stdc++.h> int main() { int q; int a[510][2]; int m = 0; int l1, r1, l2, r2; int flag; scanf( %d , &q); for (int i = 0; i < q; i++) { scanf( %d%d%d%d , &l1, &r1, &l2, &r2); flag = 0; for (int j = l1; j <= r1; j++) { a[m][0] = j; for (int k = ...
/** * 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 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 la...
#include <bits/stdc++.h> using namespace std; template <typename T> string to_str(T str) { stringstream stream; stream << str; return stream.str(); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, d, e; long long result = 1000000000; cin >> n >>...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int pre[N]; void solve() { string s; int n, k, ans = 0; cin >> n >> k >> s; for (int i = 0; i < n; i++) { if (s[i] == 1 ) { if (i == 0) pre[i] = 1; else pre[i] = pre[i - 1] + 1; ...
#include <bits/stdc++.h> using namespace std; const int OO = (int)1e9 + 7; const int mod = (int)1e9 + 7; const int MAX = (int)1e5 + 5; int main(void) { ios_base::sync_with_stdio(false); int n; while (cin >> n) { vector<pair<int, int> > h; for (int i = 0; i < n; i++) { int cur; ...
/* Copyright (c) 2013-2018 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri...
#include <bits/stdc++.h> using namespace std; int read() { char ch; for (ch = getchar(); ch < 0 || ch > 9 ; ch = getchar()) ; int x = ch - 0 ; for (ch = getchar(); ch >= 0 && ch <= 9 ; ch = getchar()) x = x * 10 + ch - 0 ; return x; } const int N = 3e5 + 5; int n, m, q,...
/////////////////////////////////////////////////////////////////////////////// // (c) Copyright 2008 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 //...
#include <bits/stdc++.h> using namespace std; void ckmx(int &x, int y) { x = max(x, y); } const int N = 100050; const int L = 17; const int M = 2 * N; int root, ls[M], rs[M], tsz, mx[M], lzy[M]; void Build(int &c, int ss, int se, int a[]) { c = ++tsz; lzy[c] = 0; if (ss == se) { mx[c] = ...
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; n /= 2; if ((x == n || x == n + 1) && (y == n || y == n + 1)) printf( NO ); else printf( YES ); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int cnt[26] = {0}; for (int i = 0; i < s.size(); i++) { cnt[s[i] - a ]++; } int ans[26] = {0}; vector<int> v; for (int i = 0; i < 26; i++) { ans[i] = cnt[i] / 2; cnt[i] = cnt[i] % 2; ...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\velocityControlHdl\velocityControlHdl_Clamp_block1.v // Created: 2014-08-25 21:11:09 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // ------------------------------------------------------...
#include <bits/stdc++.h> using namespace std; int n, m, k, a[100001][11], x[100001], cnt[11], u, v; int main() { scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf( %d , &a[i][j]); for (int i = 1; i <= k && scanf( %d%d , &u, &v); i++) x[u]++, cnt[v]++; ...
/** * 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 main() { char s[150]; int o = 1, z = 0, a[150]; scanf( %s , &s); for (int i = 0; i < strlen(s); i++) { a[i] = s[i] - 0 ; } for (int i = 0; i < strlen(s) - 1; i++) { if (a[i] == a[i + 1]) { o++; if (o == 7) { printf( YES n ); ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long double PI = acosl(-1); const long long inf = 3e18; const int nmax = 1e5 + 5; const int MAXLG = log2(nmax) + 1; vector<int> g[nmax]; long long val[nmax], chein[nmax], path[nmax]; long long dfs(int u, int p = 0) { chei...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 5; const int mod = 998244353; map<pair<int, int>, int> mp; pair<int, int> a[maxn], b[maxn]; int n; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d%d , &a[i].first, &a[i].second); for (int i = 1; i <= n; +...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int cas = 0; cas < t; cas++) { int n; cin >> n; vector<int> numbers(n); int sum = 0; int zer = 0; int ans; for (int i = 0; i < n; i++) { cin >> numbers[i]; sum = sum...
#include <bits/stdc++.h> using namespace std; int dp[2][4500005], xl[3005], ans, gd[3005]; void merge(int l, int r) { if (l == r) return; int mid = (l + r) >> 1; merge(l, mid), merge(mid + 1, r); int i = l, j = mid + 1, dq = l; while (i <= mid && j <= r) { if (xl[i] <= xl[j]) gd[...
//------------------------------------------------------------------------- // OPB Slave IPIF with PS2 Control Register Protocol Interface - Module //------------------------------------------------------------------------- // // XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" // SOLELY FOR U...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<char> s(n); long long ans = 0; for (int i = 0; i < n; ++i) { cin >> s[i]; if (i > 0 and s[i] == . and s[i - 1] == . ) ++ans; } for (int i = 0; i < m; ++i) { int pos; cin ...
#include <bits/stdc++.h> using namespace std; const int OO = 1e8 + 10; const int MOD = 1e9 + 7; const int MAX = 2e5 + 1; const double EPS = (1e-9); map<int, bool> mp; int main() { int n, x, y, l, last, ans; bool f1 = 0, f2 = 0, f3 = 0; cin >> n >> l >> x >> y; for (int i = 0; i < n; i++) {...
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = RDLU ; long long ln, lk, lm; void et(bool f = 0) { puts(f ? MAGIC : NOT MAGIC ); exit(0); } int a[2505][2505]; bitset<2505> bs[2505]; void fmain()...
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; long long fac[1100000], inv[1100000], p[1100000]; long long pow_mod(long long a, long long b, long long m) { long long ans = 1LL; a %= m; while (b) { if (b & 1) ans = ans * a % m; a = a * a % m; b >>= 1; ...
module test(); parameter signed snv1 = 4'd1; parameter signed [2:0] s3v1 = 4'd1; parameter signed [3:0] s4v1 = 4'd1; parameter signed [4:0] s5v1 = 4'd1; parameter signed snv15 = 4'd15; parameter signed [2:0] s3v15 = 4'd15; parameter signed [3:0] s4v15 = 4'd15; parameter signed [4:0] s5v15 = 4'd15; pa...
#include <bits/stdc++.h> using namespace std; int main() { string s, e; cin >> s >> e; int h1, m1, h2, m2; h1 = (s[0] - 0 ) * 10 + (s[1] - 0 ); h2 = (e[0] - 0 ) * 10 + (e[1] - 0 ); m1 = (s[3] - 0 ) * 10 + (s[4] - 0 ); m2 = (e[3] - 0 ) * 10 + (e[4] - 0 ); long long int total1 ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 34; int n, m; int f[MAXN][MAXN], s[MAXN][MAXN]; int work2(int j) { s[m][m + 1 + j] = s[m][j] * s[m][m]; int tot = s[m][j] * f[m][j] + s[m][m + 1 + j] * f[m][m + 1 + j]; for (int i = 0; i < m; ++i) { int x = f[i][j] + s[i][m] * f[...
#include <bits/stdc++.h> using namespace std; int n, m, len, kmpA[100010], ans, kmpB[100010], mxA[100010], mxB[100010]; char S[100010], A[100010], B[100010]; int main() { scanf( %s , S + 1); n = strlen(S + 1); scanf( %d , &m); while (m--) { scanf( %s , A); kmpA[0] = -1; len = s...
// (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, and any output // files any of the foregoing (including device programming or simulati...
/** * 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 main() { int ans = 0; int tub[3] = {0}; int n, a; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a); tub[a % 3]++; } ans = (tub[0] / 2) + ((tub[1] > tub[2]) ? tub[2] : tub[1]); printf( %d , ans); return 0; }
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; map<string, long long int> month; void Month() { month[ January ] = 1, month[ February ] = 2, month[ March ] = 3, month[ April ] = 4, month[ May ] = 5, month[ June ] = 6; month[ July ] = 7, month[ August ] = 8, month[ Septem...
`timescale 1ns / 1ps /* -- Module Name: Test Engine Core -- Description: Nucleo para pruebas funcionales del acelerador basado en multiples nucleos. El objetivo del modulo no es llevar a cabo procesamiento util, solo el generar modificaciones a un set de datos pre definido. El procesamiento es...
#include <bits/stdc++.h> using namespace std; int main() { long long int k, d, t; cin >> k >> d >> t; long long int k1, k2; k1 = k; k2 = (k / d) * d + (int)(k % d != 0) * d - k; t *= 2; long long int bal = 2 * k1 + k2; long long int n = t / bal; double time = n * (k1 + k2); d...
#include <bits/stdc++.h> using namespace std; string s; int isPalin(int start, int end) { if (start == end) return 1; int i = (start + end - 1) / 2; while (start <= i) { if (s[start++] != s[end--]) return 0; } return 1; } int main() { cin >> s; int start = 0, end = s.length()...