text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; char s[1005]; char t[1000005]; int main() { scanf( %s , s); scanf( %s , t); int len1 = strlen(s); int len2 = strlen(t); int le = 0x3f3f3f3f; int ri = 0x3f3f3f3f; for (int i = 0, j = 0; j < len2; j++) { if (s[i] == t[j]) i++; i...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; const int MAX = 5005; int n; string strs[MAX]; string strp[MAX]; int anspos = 0; int strlens[MAX]; int vis[MAX]; int change[MAX][2]; string ansa, ansb; bool cal(int pos) { int len = strs[pos].size(); strlens[pos] = len; int l = -1, r = len;...
// File : ../RTL/slaveController/slaveDirectcontrol.v // Generated : 11/10/06 05:37:25 // From : ../RTL/slaveController/slaveDirectcontrol.asf // By : FSM2VHDL ver. 5.0.0.9 ////////////////////////////////////////////////////////////////////// //// ...
#include <bits/stdc++.h> using namespace std; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } const long long MOD = (long long)(1e9) + 7; long long getVal(pair<pair<int, int>, long...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; bool flag; while (t--) { int n; cin >> n; long long int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; flag = true; ...
#include <bits/stdc++.h> int main() { int a[5], maxx = -1, k; for (int i = 0; i < 4; i++) { scanf( %d , &a[i]); if (maxx < a[i]) { maxx = a[i]; k = i; } } for (int i = 0; i < 4; i++) { if (k == i) continue; printf( %d , maxx - a[i]); } printf( n ...
#include <bits/stdc++.h> using namespace std; long long gcd(long long u, long long v) { if (u < v) swap(u, v); while (v != 0) { int r = u % v; u = v; v = r; } return u; } pair<int, int> row[200000], col[200000]; int main(void) { int n, m, k; cin >> n >> m >> k; 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...
/** * 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2014 by Wilson Snyder. `define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", `__FILE__,`__LINE__, (gotv), (expv)); $stop; end while...
#include <bits/stdc++.h> using namespace std; char a[10005]; char b[1000005]; vector<int> poj[10005]; int alen, blen; long long total; int pos; vector<int>::iterator it; int main() { scanf( %s , a); scanf( %s , b); alen = strlen(a), blen = strlen(b); pos = 0; total = 1; for (in...
#include <bits/stdc++.h> using namespace std; const double PI = 4 * atan(1); int T, N; long long X[100013], Y[100013], Z[100013]; long long xmi, xma, ymi, yma, zmi, zma, smi, sma; long long ansx, ansy, ansz; inline bool is(long long x, int p) { return (((x % 2) + 2) % 2) == p; } bool go(long long 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...
/** * 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> #define rb(a,b,c) for(int a=b;a<=c;++a) #define rl(a,b,c) for(int a=b;a>=c;--a) #define LL long long #define IT iterator #define PB push_back #define II(a,b) make_pair(a,b) #define FIR first #define SEC second #define FREO freopen( check.out , w ,stdout) #define rep(a,b) for(...
module SortX8 # ( parameter DSIZE = 18, parameter OFFSET = 8 )( input [DSIZE-1:0] a0, input [DSIZE-1:0] a1, input [DSIZE-1:0] a2, input [DSIZE-1:0] a3, input [DSIZE-1:0] a4, input [DSIZE-1:0] a5, input [DSIZE-1:0] a6, input [DSIZE-1:0] a7,...
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int main() { int n; cin >> n; cout << n / 2 - 2; return 0; }
// Top module connecting all the other modules //`include "verilog/mips_instr_defines.v" module top ( input wire clk, input wire reset ); wire[31:0] instr_top; wire wr_en_imem_top; wire[31:0] curr_pc_top; wire[31:0] next_pc_top; wire[31:0] next_seq_...
/* * 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 n, i, j, a, b, c, t, cnt; int main() { cin >> a >> b >> c; n = 0; t = 0; cnt = 0; while ((a > 0) || (b > 0) || (c > 0)) { switch (t) { case 0: { if (a > 0) a -= 2; break; } case 1: { ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; scanf( %d%d%d%d , &a, &b, &c, &d); if (a < max(c, d) || b < max(c, d)) { printf( -1 n ); } else if (c == 0 && d == 0) { for (int i = 0; i < a; i++) printf( 4 ); for (int i = 0; i < b; i++) printf( 7 ); ...
// Top level which connects all the top-level functional blocks. // Copyright 2010 University of Washington // License: http://creativecommons.org/licenses/by/3.0/ // 2008 Dan Yeager // The controller chooses if and what packet is sent. // RX converts RFID protocol into a serial data stream // and provides TRCAL,...
#include <bits/stdc++.h> using namespace std; map<string, int> Map; string s[181], sn; int n, i; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> sn; cin >> n; s[1] = January ; s[2] = February ; s[3] = March ; s[4] = April ; s[5] = May ; s[6] = June ; ...
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.1 (win64) Build Mon Apr 27 19:22:08 MDT 2015 // Date : Sat Mar 19 19:16:24 2016 // Host : DESKTOP-5FTSDRT running 64-bit major releas...
module ControlUnit (output reg IR_CU, RFLOAD, PCLOAD, SRLOAD, SRENABLED, ALUSTORE, MFA, WORD_BYTE,READ_WRITE,IRLOAD,MBRLOAD,MBRSTORE,MARLOAD,output reg[4:0] opcode, output reg[3:0] CU, input MFC, Reset,Clk, input [31:0] IR,input [3:0] SR); reg [4:0] State, NextState; task registerTask; input [17:0] signals; //6 7 8 ...
/** * 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 num; int arr[110]; cin >> num; for (int i = 0; i < num; i++) { cin >> arr[i]; } for (int i = 1; i <= num; i++) { for (int j = 0; j < num; j++) { if (arr[j] == i) { cout << j + 1 << ; } ...
/* FIX_POINT_FLOAT */ module ADD_FIX_POINT_FLOAT ( A, B, out ); parameter width = 16; input [width:1] A,B; output [width:1] out; assign out = A + B; endmodule //------------------------------------------------- module SUB_FIX_POINT_FLOAT ( A, B, out ) ; parameter width = 16; input [width:1] A,B; output [width:...
/* * 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 val; cin >> val; int cngIn1 = -1; int lDigit = int(val[val.length() - 1] - 0 ); for (int i = val.length() - 2; i >= 0; i--) { int dig = int(val[i] - 0 ); if ((dig % 2 == 0) && (dig < lDigit)) { cngIn1 = i; ...
#include <bits/stdc++.h> using namespace std; int main() { int NWarm, NChip; cin >> NWarm >> NChip; int temp = NWarm * (NWarm + 1) / 2; int ans = NChip % temp; int i; for (i = 1; i <= temp; i++) { ans = ans - i; if (ans < 0) break; } int ans1 = ans + i; cout << ans1 <...
/* -- ============================================================================ -- FILE NAME : ex_stage.v -- DESCRIPTION : EXƒXƒe[ƒW -- ---------------------------------------------------------------------------- -- Revision Date Coding_by Comment -- 1.0.0 2011/06/27 suito V‹Kì¬ -- =============...
`begin_keywords "1364-2005" /* * This tests the synthesis of a case statement that has an empty case. */ module main; reg clk, bit, foo, clr; // Synchronous device that toggles whenever enabled by a high bit. always @(posedge clk or posedge clr) if (clr) foo = 0; else case (bit) 1'b0: ; ...
module test; // force leading zero on outer scope genblk numbers localparam genblk1 = 0; localparam genblk2 = 0; localparam genblk3 = 0; localparam genblk4 = 0; localparam genblk5 = 0; localparam genblk6 = 0; localparam genblk7 = 0; localparam genblk8 = 0; localparam genblk9 = 0; parameter TRUE = 1; genvar i; genvar...
//================================================================================================== // Filename : antares_idex_register.v // Created On : Sat Sep 5 21:08:59 2015 // Last Modified : Sat Nov 07 12:09:34 2015 // Revision : 1.0 // Author : Angel Terrones // Company : Univer...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 06/17/2017 09:57:13 AM // Design Name: // Module Name: Snake // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revi...
`timescale 1 ns / 100 ps // ********************************************************************/ // Actel Corporation Proprietary and Confidential // Copyright 2009 Actel Corporation. All rights reserved. // // ANY USE OR REDISTRIBUTION IN PART OR IN WHOLE MUST BE HANDLED IN // ACCORDANCE WITH THE ACTEL LICENSE AGR...
//control unit for write enable and ALU control //defining the conditions inside the conditional instructions `include "define.v" module control( opcode, //cond, //flag, dmem_wen, rf_wen, alu_op, alusrc, regdest, branch, mem2reg, lhb_llb_con1, s5, s6, s7, ja...
#include <bits/stdc++.h> using namespace std; int main() { int c, d, n, m, k; cin >> c >> d >> n >> m >> k; int users = n * m - k; int ans = 1000000000; for (int i = 0; i <= m; i++) for (int j = 0; j <= 10000; j++) { if (i * n + j >= users) { if (c * i + j * d < ans) ans ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5 + 1; int main() { int N, Q; cin >> N >> Q; set<int> all; multiset<int> gaps; for (int i = 0; i < N; ++i) { int x; cin >> x; all.insert(x); } for (auto iter = all.begin(); iter != all.end(); ++iter) { ...
/** * 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 const N = 202000; set<int> s; set<int>::iterator it; int edg[N]; vector<int> g[N]; int ans[N]; int cur = 1; int vis[N]; void dfs(int node) { vis[node] = 1; ans[cur]++; vector<int> send; for (it = s.begin(); it != s.end();) { if ...
module uart( input clk, input rst, // uart lines input hwrx, output hwtx, // bus interface input addr, // 2 registers input we, input re, input [31:0] wdata, output reg [31:0] rdata, // latch char on rising edge if dosend set // input [7:0] txchar, // input dos...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } long long powmod(long long a, long long b, long long MOD) { if (a == 0ll) { return 0ll; } a %= MOD; ...
/** * 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) 1999 Steve 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) // ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; bool ch1 = false; if (m % 2 == 0) ch1 = true; bool ch2 = false; for (int i = 0; i ...
#include <bits/stdc++.h> using namespace std; int hed[600010], nxt[600010], to[600010], cnt; inline void addedge(int u, int v) { nxt[++cnt] = hed[u]; hed[u] = cnt; to[cnt] = v; } int siz[300010], root[300010], ans[300010]; int mx[300010]; int id[6000010], son[6000010][2], tot; int n, q; 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...
/** * 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<set<int> > A; set<int>::iterator it; int main() { int n, m, a; cin >> n; A.resize(n); int D[101]; for (int i = 1; i <= 100; ++i) D[i] = 0; for (int i = 0; i < n; ++i) { cin >> m; for (int j = 0; j < m; ++j) { cin >>...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> g, rv; int ds[3030][3030]; vector<int> md[3030]; int rd[3030][3030]; vector<int> mr[3030]; int main() { int n, m; scanf( %d %d , &n, &m); g.assign(n, vector<int>()); rv.assign(n, vector<int>()); while (m--) { int ...
#include <bits/stdc++.h> using namespace std; set<int> s; int ans[300005]; int main() { int n, m, l, r, x; cin >> n >> m; for (int i = 1; i < n + 1; i++) { s.insert(i); ans[i] = 0; } for (int i = 0; i < m; i++) { cin >> l >> r >> x; set<int>::iterator lb = s.lower_bou...
/* * fifo module implements simple fifo which could read * and write entry in same cycle. * NOTE: when issued rd command fifo shouldn't be empty, * when issued wr command fifo shouldn't be full, * when issued rd and wr commands fifo shouldn't be empty or full * only when fifo is empty data_out isn't val...
// megafunction wizard: %In-System Sources and Probes%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsource_probe // ============================================================ // File Name: hps_reset.v // Megafunction Name(s): // altsource_probe // // Simulation Library Files(s): // // ========...
#include <bits/stdc++.h> using namespace std; void O_o() { ios::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); } int main() { O_o(); int x, y; bool flag; vector<int> vec; cin >> x; y = x; while (x != 0) { vec.push_back(x % 10); x = ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5, maxh = 3; int mod[maxh] = {(int)1e9 + 7, (int)1e9 + 9, (int)998244353}; struct data { int v[maxh]; data(int a = 0, int b = 0, int c = 0) { v[0] = a; v[1] = b; v[2] = c; } int& operator[](int w) { return v[w]; ...
/** * 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...
/** * 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 mod = 1e9 + 7; struct frac { long long first, second; frac(long long X = 0) : first((X % mod + mod) % mod), second(1) {} frac(long long X, long long Y) : first((X % mod + mod) % mod), second((Y % mod + mod) % mod) {} frac operator+(fr...
module crc_unit ( //OUTPUTS output [31:0] crc_poly_out, output [31:0] crc_out, output [31:0] crc_init_out, output [7:0] crc_idr_out, output buffer_full, output read_wait, output reset_pending, //INPUTS input [31:0] bus_wr, input [ 1:0] crc_poly_size, input [ 1:0] bus_size, input [ 1:0] rev_in_type, input ...
#include <bits/stdc++.h> using namespace std; const int MAX = 3e5 + 9; int sz[MAX], ans[MAX], p[MAX], n, q; vector<int> g[MAX]; int dfs(int v) { sz[v] = 1; for (auto u : g[v]) sz[v] += dfs(u); return sz[v]; } void calc(int v) { int bes = -1; for (auto u : g[v]) { calc(u); 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; inline int read() { int n = 0, f = 1, ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { n = n * 10 + ch - 0 ; ch = getchar(); } return n * f; } ch...
#include <bits/stdc++.h> using namespace std; struct Item { int x[3], y[3]; }; bool check(Item t); inline int Dist(int x1, int y1, int x2, int y2) { return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); } int main() { Item it; for (int i = 0; i < 3; i++) cin >> it.x[i] >> it.y[i]; if (...
// N64 controller read command parser/receiver // // Inputs: clk_4M 4 MHz clock // din Input data line // enable Only samples when this is active // Outputs: ctrl_state 32-bit register with controller state // ctrl_clk Output clock, sample at negative edge module n64_re...
`timescale 1ns / 1ps /* * File : FIFO_NoFull_Count.v * Creator(s) : Grant Ayers () * * Modification History: * Rev Date Initials Description of Change * 1.0 24-May-2010 GEA Initial design. * * Standards/Formatting: * Verilog 2001, 4 soft tab, wide column. * * Description: ...
#include <bits/stdc++.h> using namespace std; int main() { int n; string s[1000]; scanf( %d , &n); for (int i = 0; i < n; i++) { cin >> s[i]; } char ch = s[0][0]; int flg = 0, cnc = 0, cnch = 0; char c = s[0][1]; if (c == ch) flg = 1; for (int i = 0; i < n; 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; inline int read() { int out = 0, fh = 1; char jp = getchar(); while ((jp > 9 || jp < 0 ) && jp != - ) jp = getchar(); if (jp == - ) fh = -1, jp = getchar(); while (jp >= 0 && jp <= 9 ) out = out * 10 + jp - 0 , jp = getchar(); return out...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long a[n]; for (long long i = 0; i <= n - 1; i++) cin >> a[i]; for (long long i = 0; i <= n - 1; i++) if ((a[i] % 2)) a[i] += 1; for (long long i = 0; i <= n - 1; i++) if (!(a[i] % 2)) 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...
module xtime ( output [7:0] y, input [7:0] x ); wire [7:0] w; assign w = x << 1; //MUX MUX_1(.A(w), .B(w ^ 8'h1B), .S(x[7]), .O(y)); /*MUX #( .N(8) ) MUX_1 ( .A(w), .B(w ^ 8'h1B), .S(x[7]), .O(y) );*/ assign y = x[7]? w ^ 8'h1B : w; endmodule module MixColumns( x, z); input [12...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; const ll llinf = (1ll << 61) - 1; const double eps = 1e-6, ldeps = 1e-9; struct Dbg { static constexpr auto &os = cout; template <class C> static auto dud(C *x) -> declty...
#include <bits/stdc++.h> using namespace std; const int N = 1005; long long ara[N]; int main() { long long n, m; cin >> n >> m; for (long long i = 0; i < m; ++i) { long long x; cin >> x; ++ara[x]; } vector<long long> v; for (long long i = 1; i <= 100; ++i) { if (a...
#include <bits/stdc++.h> using namespace std; long long isPalindrome(string str) { long long l = 0; long long h = str.length() - 1; while (h > l) { if (str[l++] != str[h--]) { return -1; } } return 1; } int32_t main() { string s; cin >> s; long long n = s.size...
#include <bits/stdc++.h> using namespace std; int n, a[100005]; long long b[100005], dpMax[100005], dpMin[100005], ans = (1ll << 63); void setup() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n - 1; i++) b[i] = abs(a[i] - a[i + 1]); n--; } void xuly() { for ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k, j = 0, oo = 1; cin >> n >> k; while (k != j) { oo *= 10; j++; } long long int prod = oo * n; while (oo != n) { if (oo > n) { oo %= n; if (oo == 0) oo = n; } else { n...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2005 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; reg [31:0] in_a; reg [31:0] in_b; reg [31:0] e,f,g,h; always @ (/*AS*/in_a) begin ...
//altiobuf_out CBX_AUTO_BLACKBOX="ALL" CBX_SINGLE_OUTPUT_FILE="ON" DEVICE_FAMILY="Cyclone V" ENABLE_BUS_HOLD="FALSE" NUMBER_OF_CHANNELS=1 OPEN_DRAIN_OUTPUT="FALSE" PSEUDO_DIFFERENTIAL_MODE="TRUE" USE_DIFFERENTIAL_MODE="TRUE" USE_OE="FALSE" USE_OUT_DYNAMIC_DELAY_CHAIN1="FALSE" USE_OUT_DYNAMIC_DELAY_CHAIN2="FALSE" USE_TE...
#include <bits/stdc++.h> using namespace std; long long int mod = 1000000007; int main() { ios_base ::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; if (n == 1) { cout << 2; return 0; } if (n == 2) { cout << 3; return 0; } long long in...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long x, y, n, m, t, q, a, b, count = 0; cin >> n >> m; long long arr[n]; for (x = 0; x < n; x++) cin >> arr[x]; a = 0; for (x = 0; x < n; x++) { a = a + arr[x]; ...
#include <bits/stdc++.h> using namespace std; int main() { char s[110]; while (scanf( %s , s) != EOF) { int l = strlen(s); int ans = 0; for (int i = 0; i < l; i++) { if (s[i] == Q ) { for (int j = i + 1; j < l; j++) { if (s[j] == A ) { for (int...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long w, m; cin >> w >> m; vector<int> f; while (m) { f.push_back(m % w); m /= w; } f.push_back(0); f.push_back(0); reverse(f.begin(), f.end()); for (int i...
#include <bits/stdc++.h> using namespace std; long long a[100000], i, n, m, k; set<int> s; int main() { cin >> n >> k; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); s.insert(a[0]); for (i = 1; i < n; i++) { m = s.size(); if (a[i] % k != 0) { s.insert(...
#include <bits/stdc++.h> using namespace std; const int T = 1e3 + 5; int g[T][T]; void add(int a, int b) { g[a][b] = g[b][a] = 1; } int last, K, a, b, i, j, N; int main() { cin >> K; add(0, 2); add(0, 3); for (i = 2; i <= 30; i++) { add(2 * i, 2 * i - 1); add(2 * i, 2 * i - 2); ...
#include <bits/stdc++.h> using namespace std; int dpr[107]; int dps[107]; int dpc[107]; int a[107]; int main() { int n; scanf( %d , &n); for (int i = 1; i < n + 1; i++) scanf( %d , a + i); dpr[1] = 1; dps[1] = (a[1] == 2 || a[1] == 3) ? 0 : -1; dpc[1] = (a[1] == 1 || a[1] == 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...
//----------------------------------------------------------------------------- //-- Microbio. Mini procesador hola-mundo //----------------------------------------------------------------------------- //-- (C) BQ November 2015. Written by Juan Gonzalez //--------------------------------------------------------------...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n_Cases = 1; for (long long case_i = 1; case_i <= n_Cases; case_i++) { long long up, down; cin >> up >> down; long long n = up + down + 1; for (long long i = 1; ...
////////////////////////////////////////////////////////////////////////////////// // AXI4CommandDivider for Cosmos OpenSSD // Copyright (c) 2015 Hanyang University ENC Lab. // Contributed by Kibin Park <> // Yong Ho Song <> // // This file is part of Cosmos OpenSSD. // // Cosmos OpenSSD is free software...
/** * @note: * 1. size of image must be integral multiple of C_M_AXI_DATA_WIDTH * C_M_AXI_BURST_LEN. * 2. the sof [start of frame] must be 1'b1 for first image data. */ module FIFO2MM # ( parameter integer C_DATACOUNT_BITS = 12, // Burst Length. Supports 1, 2, 4, 8, 16, 32, 64, 128, 256 burst lengths parameter i...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long maxn = 1e5 + 10; vector<long long> a[maxn]; long long lo[maxn], hi[maxn]; const long long inf = 1e15; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(...
#include <bits/stdc++.h> using namespace std; int main(int argc, char* argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); long long i, t, n, com, midc; cin >> n; map<int, int> m; set<int> s; vector<int> x(n); vector<int> a(3); for (i = 0; i < n; i++) { cin >> x[i]; ...
#include <bits/stdc++.h> using namespace std; const int N = 702, M = 4900005; int main() { int n, m, a[55], b, i, j, ans, cnt; while (scanf( %d , &n) == 1) { for (i = 1; i <= n; i++) scanf( %d , a + i); scanf( %d , &m); for (i = 1, ans = 0; i <= m; i++) { scanf( %d , &b); ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n; double r, v, l; double tim(double p1, double p2) { double rem = p2 - p1; double k = int(rem / l); rem = rem - k * l; double le = 0, ri = 1e9, mid; for (int I = 1; I <= 200; I++) { mid = (le + ri) / 2.0; ...
#include <bits/stdc++.h> using namespace std; int INTlog2(unsigned long long number) { int logval = 0; while (number >>= 1) logval++; return logval; } int main() { unsigned long long n, k; cin >> n >> k; if (k == 1) cout << n << endl; else cout << (1LL << (INTlog2(n) + 1L...