text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const int MAX = 50050; vector<int> e[MAX]; vector<int> ee[MAX]; int c[MAX][555]; int vis[MAX]; int n, k; void solve(int indx) { c[indx][0] = 1; vis[indx] = 1; for (int i = 0; i < e[indx].size(); i++) { if (vis[e[indx][i]] == 1) continue; ...
/* * ram_w.v * * Created on: 09/10/2012 * Author: Lord_Rafa */ `timescale 1 ps / 1 ps module ram_w( input clk, input rst, output wire[ADD_WIDTH-1:0] ram_w_address, input ram_w_waitrequest, output wire[BYTE_ENABLE_WIDTH-1:0] ram_w_byteenable, output wire ram_w_write...
/** * 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 = 1 << 20; int n; int part[N][2]; bool vis[N]; vector<int> ans; vector<pair<int, int> > G[N]; void dfs(int u) { vis[u] = true; for (auto v : G[u]) if (!vis[v.first]) dfs(v.first); } bool check(int Mask) { for (int i = 0; i <...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 5e3 + 10; int dp[maxn][maxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; string a, b; cin >> a >> b; int ans = 0; for (int i = 1; i <= n; i++) { for (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 law...
#include <bits/stdc++.h> int main() { int n, k, i; scanf( %d , &n); int a[n][2]; for (i = 0; i < n; i++) { scanf( %d%d , &a[i][0], &a[i][1]); } scanf( %d , &k); for (i = 0; i < n; i++) { if (k >= a[i][0] && k <= a[i][1]) { printf( %d , n - i); break; } ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n / 2 * 2 + (n + 1) / 2 << endl; for (int i = 2; i <= n; i += 2) cout << i << ; for (int i = 1; i <= n; i += 2) cout << i << ; for (int i = 2; i <= n; i += 2) cout << 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 MAXN = 1e6 + 5; const long long MOD = 1e9 + 7; set<char> seen; void solve() { int n; cin >> n; string a; string b; cin >> a >> b; for (int i = 0; i < n; i++) { if (a[i] > b[i]) { cout << -1 n ; return; ...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:36777216 ) template <class T> inline T &RD(T &); template <class T> inline void OT(const T &); inline int RD() { int x; return RD(x); } inline double &RF(double &); inline double RF() { double x; return RF(...
#include <bits/stdc++.h> using namespace std; constexpr int MOD = 998244353; int main() { int R, C; cin >> R >> C; int X = 1; while (R--) X = (2 * X) % MOD; while (C--) X = (2 * X) % MOD; cout << X << 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...
`default_nettype none `timescale 1ns/1ns module tb_memif(); wire clk, reset; clock clock(clk, reset); reg a_write = 0; reg a_read = 0; reg [31:0] a_writedata = 0; reg [1:0] a_address; wire [31:0] a_readdata; wire a_waitrequest; wire [17:0] b_address; wire b_write; wire b_read; wire [35:0] b_writedata; ...
/** * 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; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long r; cin >> r; if ((r - 1) % 2 == 0 && r > 3) cout << 1 << << (r - 3) / 2; else cout << NO ; }
/** * 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; void solve(); int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int TESTS = 1; while (TESTS--) { solve(); } return 0; } void solve() { string s, t; cin >> s >> t; long long a[10]; memset(a, 0,...
#include <bits/stdc++.h> using namespace std; const int INFint = 2e9; const long long INF = 1e18; const long long MOD = 1000000007ll; int g[100][100]; vector<int> used; set<int> roots; int n, m; void dfs(int v, int p) { used[v] = 1; for (int i = 0; i < n; i++) { if (i == p || !g[v][i]) c...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:300000000 ) #pragma warning(disable : 4800) using namespace std; const double pi = 3.1415926535897932384626433832795; template <class T> T abs(const T &a) { return a >= 0 ? a : -a; }; template <class T> T sqr(const T &x) { return x * x; ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const double EPS = 1e-9; int n, k, deg[1000015], ans, vis[1000015]; vector<int> e[1000015]; int dfs(int u) { if (e[u].size() == 1) return 1; vis[u] = 1; vector<int...
#include <bits/stdc++.h> using namespace std; long long binpow(long long a, long long b, long long m) { a %= m; long long res = 1; while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res; } void solve() { long long int x, n, y, z, ans = 1;...
#include <bits/stdc++.h> using namespace std; int main() { string s; int i, j, k, n, l, n1, n2, m, m1, m2; cin >> s; l = s.size(); for (i = l - 1; i >= 0; i--) { n = s[i] - 48; m = n; if (m == 0) { cout << YES << endl << 0 << endl; exit(0); } if (n...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<long long> a(n); vector<int> nx(n); for (int i = 0; i < n; i++) { cin >> a[i]; } map<long long, int> mp; long long sig = 0; for (int i =...
#include <bits/stdc++.h> using namespace std; int n, m, k; int per; int main() { cin >> n >> m >> k; per = 2; int flag = 0; int sum = 0; int ff = 0; int a = 1; for (int i = 1; i <= n; ++i) { if (!flag) { for (int j = 1; j <= m; ++j) { if (sum % 2 == 0 && a == ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 1000000001; const long long int LLINF = 1000000000000000001LL; struct ITree { vector<long long int> T; int p = 1; ITree(int n) { while (p < n) p *= 2; T.resize(2 * p - 1, 0); } int par(int...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; long long maxi; maxi = -9999999999; cin >> n >> k; for (int i = 1; i <= n; i++) { int a, b; long long tmp; cin >> a >> b; if (b > k) { tmp = a - (b - k); } else { tmp = a; } ...
#include <bits/stdc++.h> using namespace std; int main() { int n, p, q, i = 1, j, k, temp = 0, flag = 0; string s; cin >> n >> p >> q; cin >> s; if (n % p == 0 && n != p + q || n % q == 0 && n != p + q) { if (n % p == 0) { cout << n / p << endl; for (i = 0; i < n; i++) { ...
// megafunction wizard: %LPM_MULT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: lpm_mult // ============================================================ // File Name: MULT_sumXsq.v // Megafunction Name(s): // lpm_mult // // Simulation Library Files(s): // lpm // =========================================...
// (C) 2001-2013 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 doc...
// modelling dma_sequencer.v together with dma_access.v `define CLK_PERIOD 40 //`define NO_CPU module tb; parameter DEVNUM = 4; integer i,j,k; reg clk,rst_n; reg can_go; tri1 iorq_n,mreq_n,rd_n,wr_n; tri0 busrq_n,busak_n; trireg [15:0] zaddr; tri [7:0] zdata; wire dma_req,dma_rnw; ...
#include <bits/stdc++.h> using namespace std; long long int n, i, j, t, ans, arr[3009], crr[3009][3009]; int main() { scanf( %lld , &t); while (t--) { scanf( %lld , &n); ans = 0; for (i = 1; i <= n; i++) scanf( %lld , &arr[i]); for (i = n; i >= 1; i--) { for (j = i - 1; j >...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; const long long mod = 1e9 + 7; void solve(); signed main() { ios::sync_with_stdio(false); cin.tie(0); long long tests = 1; while (tests--) solve(); return 0; } void solve() { long long n; cin >> n; p...
//====================================================================== // // Module Name: WHIRLPOOL_WCIPHER_SBOX // Description: SBox function of Whirlpool W-Cipher // // Language: Verilog-2001 // // Module Dependencies: none // // Developer: Saied H. Khayat // URL: https://github.com/saiedhk ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const ll OO = 1e18; int di[8] = {0, 0, 1, -1, -1, 1, -1, 1}; int dj[8] = {1, -1, 0, 0, 1, 1, -1, -1}; string ys = YES , no = NO ; const long double dgr = acos(-1) / 180, dg = 180 / acos(-1); const int mod = 1...
// $Id: $ ///////////////////////////////////////////////////////////////////// // This file is part of the GOST 28147-89 CryptoCore project // // // // Copyright (c) 2014 Dmitry Murzinov () // //////////////////////////////////////////////////...
#include <bits/stdc++.h> using namespace std; const int MAX = 60; const int A = 26; const int INF = 1000000001; char G[MAX + 2][MAX + 3]; int D[MAX + 2][MAX + 2]; bool ok[A + 1]; pair<int, int> S, T; vector<char> ans; vector<int> K; int n, m, k; inline int con(char c) { return a <= c && c <= ...
#include <bits/stdc++.h> using namespace std; int n, l, r; vector<pair<int, int> > G[100005]; int seq[100005], cnts, siz[100005], rch[100005], num[100005]; bool vis[100005]; int rt, Min; void dfs(int now, int ff, int tsz) { int Max = 0; siz[now] = 1; rch[now] = 0; for (int i = 0, v, sz = G...
// `include "../define.v" module memory ( input rst, input ce, input[`MemDataWidth-1:0] data_i, input[`MemAddrWidth-1:0] addr_i, input we, input[`ByteSlctWidth-1:0] byte_slct, `ifdef DEBUG output reg[`MemDataWidth-1:0] data_o, output[`MemDataWidth-1:0] mem20, output[`MemDataWidth-1:0] ...
// *************************************************************************** // *************************************************************************** // Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved. // // In this HDL repository, there are many different and unique modules, consisting // of...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; const int MAXN = 1000100; int q = 0, qq, n; double x[MAXN], y[MAXN]; double c1[MAXN]; double c2[MAXN]; double c[MAXN]; void solve() { cin >> n; for (int i = 0; i < n; ++i) { cin >> c1[i]; } ...
#include <bits/stdc++.h> using namespace std; priority_queue<pair<int, string> > all[10010]; int main() { int n, m; cin >> n >> m; string name; int reg, sc; for (int i = 0; i < n; i++) { cin >> name >> reg >> sc; all[reg].push(make_pair(sc, name)); } for (int i = 1; i <= m;...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ii = pair<ll, ll>; using vi = vector<ll>; using vb = vector<bool>; using vvi = vector<vi>; using vii = vector<ii>; using vvii = vector<vii>; const int INF = 2000000000; const ll LLINF = 90000000000000...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk, fastclk ); input clk; input fastclk; // surefire lint_off_line UDDIXN integer _mode; initial _mode=0; ...
/* Copyright (c) 2015-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...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Tue Apr 18 23:15:20 2017 // Host : DESKTOP-I9J3TQJ running 64-bit major re...
`timescale 1 ps / 1 ps module ov7670_marker_tracker_v1_0 # ( // Users to add parameters here // User parameters ends // Do not modify the parameters beyond this line // Parameters of Axi Slave Bus Interface S00_AXI parameter integer C_S00_AXI_DATA_WIDTH = 32, parameter integer C_S00_AXI_ADDR_WIDTH = ...
#include<bits/stdc++.h> using namespace std; #define ll long long int const ll mod = 1e9+7; void solve(){ int a; cin>>a; float arr[a]; float sum=0; for(int i=0;i<a;i++){ cin>>arr[i]; sum+=arr[i]; } float avg = sum/(float)a; sort(arr,arr+a); int ans=0; ...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2009 Altera Corporation, San Jose, California, USA. ...
#include <bits/stdc++.h> using namespace std; using namespace chrono; long long mod_add(long long a, long long b, long long m) { a = a % m; b = b % m; return (((a + b) % m) + m) % m; } long long mod_mul(long long a, long long b, long long m) { a = a % m; b = b % m; return (((a * b) % m...
#include <bits/stdc++.h> using namespace std; struct edge { int v, nxt, c; } e[1505 * 1505 * 2]; int p[1505], eid; void init() { memset(p, -1, sizeof p); eid = 0; } void insert(int u, int v, int c) { e[eid].v = v; e[eid].c = c; e[eid].nxt = p[u]; p[u] = eid++; } void add(in...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; template <typename T> using V = vector<T>; const int N = 1e5 + 5; bool taken[3 * N]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tc; cin >> tc; while (tc--) { int...
#include <bits/stdc++.h> using namespace std; map<long long, int> MP; int Q = 1; vector<pair<int, int> > adj[500005]; long long C[500005]; set<int> S; int p[500005]; long long pw(int x) { if (!x) return 1LL; if (x & 1) return 2 * pw(x - 1) % 1000000007; long long hf = pw(x / 2); return h...
#include <bits/stdc++.h> using namespace std; inline long long read() { char i = getchar(); long long f = 1, res = 0; while (i < 0 || i > 9 ) { if (i == - ) f = -1; i = getchar(); } while (i >= 0 && i <= 9 ) { res = res * 10 + i - 0 ; i = getchar(); } retu...
#include <bits/stdc++.h> using namespace std; inline void sfr(int *a) { char c = 0; while (c < 33) c = fgetc(stdin); *a = 0; while (c > 33) { *a = *a * 10 + c - 0 ; c = fgetc(stdin); } } inline void sfp(int a) { char c[1000]; sprintf(c, %d , a); puts(c); } int m...
#include <bits/stdc++.h> using namespace std; const int N = 100105; const double eps = 1e-6; long double x1, y1_, x2, y2, mx, my, vx, vy, d, L, ans = 1e16; vector<pair<long double, int> > V; int X[N], Y[N], R[N], n, s = 0; long double check(int k, long double t, int op) { return ((sqrt(d * d + t * t) ...
/** * 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...
//-------------------------------------------------------------------------------- // trigger.vhd // // Copyright (C) 2006 Michael Poppitz // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Found...
#include <bits/stdc++.h> using namespace std; int main() { string a, b; int n; cin >> n >> a >> b; int T[n], pom[n]; for (int i = 0; i < n; ++i) T[i] = -1; for (int i = 0; i < n; ++i) { bool ud = false; for (int j = 0; j < n; ++j) { if (T[j] == -1 && a[j] == b[i]) { ...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; int main() { int n; long long x, d; int cntDist = 0; string inp; cin >> n >> x; getline(cin, inp); for (int i = 0; i < n; i++) { getline(cin, inp); stringstream ss(inp.substr(2)); ss >> d; if (inp[0] == + ) { ...
#include <bits/stdc++.h> using namespace std; int total_operation = 0; bool is_prime(long long n) { if (n == 2) return true; if (n % 2 == 0 || n < 2) return false; for (int i = 3; i * i <= n; i += 2) { if (n % i == 0) return false; } return true; } int countprime_in_range(int n) { ...
#include <bits/stdc++.h> using namespace std; int main() { string str; int n; cin >> n >> str; int A[n], m = 0; string RE[n]; A[0] = 0; for (int i = 1, t = 0, tmp = [ ; i < n; i++) { if (str[i] == tmp) { if (str[i] == ] ) t--; else t++; }...
#include <bits/stdc++.h> using namespace std; long long cross2(long long x1, long long y1, long long x2, long long y2) { return x1 * y2 - x2 * y1; } long long cross(long long i, long long j, long long k, const long long* xx, const long long* yy) { return cross2(xx[j] - xx[i], yy[j] - y...
#include <bits/stdc++.h> using namespace std; int n, m, k; int main() { cin >> n >> m >> k; if (m >= n && k >= n) cout << Yes ; else cout << No ; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> inline T euclide(T a, T b, T& x, T& y) { if (a < 0) { T d = euclide(-a, b, x, y); x = -x; return d; } if (b < 0) { T d = euclide(a, -b, x, y); y = -y; return d; } if (b == 0) { x = 1; ...
#include <bits/stdc++.h> using namespace std; void display(std::vector<int> v) { for (int i = 3; i >= 0; i--) { for (int j = 0; j < v[i]; j++) { if (i == 3) cout << 7; else if (i == 2) cout << 5; else if (i == 1) cout << 3; else if (i == 0) ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; string ans; for (int i = 0; i < n; i++) ans += U ; for (int i = 0; i < m; i++) ans += L ; for (int i = 0; i < n; i++) { for (int j = 0; j ...
#include <bits/stdc++.h> using namespace std; int tree[262192]; int a[262192], pre[262192], ok[262192]; int n; void check() { int i, all_1 = 1; for (i = 1; i <= n; ++i) { if (a[i] != 1) all_1 = 0; } if (all_1) { printf( 1 n ); exit(0); } } void update(int pt, int l, i...
// soc_design_mm_interconnect_0_avalon_st_adapter_006.v // This file was auto-generated from altera_avalon_st_adapter_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 16.0 211 `timescale 1 ps / 1 ps module soc_design_mm_interconnect_0_avalon_st_adapter_006 #( parame...
#include <bits/stdc++.h> using namespace std; inline int read() { char ch = getchar(); int nega = 1; while (!isdigit(ch)) { if (ch == - ) nega = -1; ch = getchar(); } int ans = 0; while (isdigit(ch)) { ans = ans * 10 + ch - 48; ch = getchar(); } if (nega == -...
//############################################################################# //# Function: 12:1 one hot mux # //############################################################################# //# Author: Andreas Olofsson # ...
////////////////////////////////////////////////////////////////////// //// //// //// Generic Double-Port Synchronous RAM //// //// //// //// This file is part of memory li...
#include <bits/stdc++.h> using namespace std; long long int arr[1000005], t = 0; int main() { int n, cnt; cin >> n; map<long long int, int> m; for (int i = 0; i < n; i++) { cin >> arr[i]; } cnt = 1; long long int t = arr[0]; m[t]++; for (int i = 1; i < n; i++) { t =...
#include <bits/stdc++.h> using namespace std; const long double PI(acos((long double)-1.0)); struct cpx { long double r, i; cpx() : r(0), i(0) {} cpx(long double a, long double b) : r(a), i(b) {} cpx conj() { return cpx(r, -i); } } u[20], iu[20], a[524288], b[524288]; cpx operator+(const cpx &...
`timescale 1ns / 1ns ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 12/06/2013 06:51:42 PM // Design Name: // Module Name: main // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revis...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2007 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; reg toggle; integer cyc; initial cyc=1; wire [7:0] cyc_copy = cyc[7:0]; always @...
#include <bits/stdc++.h> using namespace std; bool b[123][123]; int arr[123][123]; int k[123]; int z[123]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); bool valid = 0, flag = 0; pair<int, int> ans1, ans2; int n; cin >> n; string s, t; cin >> s >> t; for (int i =...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; using ll = long long; const char E = n ; const int N = 1005; const ll mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k, x, dp[2][1024] = {0}; cin >> n >> k >> x; fo...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int n, k; long long dp[2005][2005][2]; string s; int main() { cin >> n >> k >> s; dp[n][0][0] = 1; dp[n][0][1] = 1; for (int i = n - 1; i >= 0; --i) { for (int j = 0; j <= k; ++j) { for (int eq = 0;...
// *************************************************************************** // *************************************************************************** // Copyright 2015(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are...
/* * yaswanth phani kommineni */ #include <bits/stdc++.h> using namespace std; typedef long long int ll; #define endl n ; void solve(){ ll n; cin >> n; n*=2; vector <ll> v(n); map <ll,ll> m; for(ll i=0;i<n;i++){ cin >> v[i]; m[v[i]]++; } sort(v.begin(),v.end()); ...
/* * 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 maxN = 2e5 + 9, MOD = 1e9 + 7; int n; long long arr[maxN], ot[maxN]; long long maxsub(long long *arr, int n) { long long cr = LLONG_MIN / 4, maxi = LLONG_MIN / 4; for (int i = 0; i < n; i++) { cr = max(arr[i], cr + arr[i]); maxi = max...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int gizzly; cin >> gizzly; priority_queue<int> scoreList; for (int i = 1; i < n; i++) { int x; cin >> x; scoreList.push(x); } int candy = 0; while (gizzly <= scoreList.top()) { int...
#include <bits/stdc++.h> using namespace std; int f[20]; bool ischange[300000]; int main() { memset(ischange, 0, sizeof ischange); int n; scanf( %d , &n); string a; cin >> a; for (int i = 1; i <= 9; i++) { scanf( %d , &f[i]); } int ff = 0; for (int i = 0; i < a.length()...
//`include "vga.v" `timescale 10ns/10ns module vga_export_tb(); // Declare inputs as regs and outputs as wires reg clk; reg[0:0] rst; wire red; wire green; wire blue; wire hsync; wire vsync; vga_export DUT( .CLOCK_50(clk) , // input CLOCK_50_sig .KEY(rst) , // inpu...
/** * 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() { long long b; while (cin >> b) { long long ans = 0; long long i; for (i = 1; i * i < b; i++) { if (b % i == 0) ans += 2; } if (i * i == b) ans++; cout << ans << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int q; scanf( %d , &q); while (q--) { int n; scanf( %d , &n); int sum = 0, a; for (int i = 0; i < n; ++i) { scanf( %d , &a); sum += a; } printf( %d n , (int)ceil(sum * 1.0 / n)); } retu...
#include <bits/stdc++.h> using namespace std; const int maxN(1e3 + 10); int N, M, P[maxN], A[maxN][maxN], C; void dfs(const int u) { C++; for (int v = 1; v <= N; v++) if (A[u][v] && !P[v]) { P[v] = u; dfs(v); } } int main() { cin >> N >> M; if (M != N - 1) { ...
`timescale 1ns / 1ps module MultiState( input clk, input rst, input [5:0] op, output [2:0] state ); reg [2:0] tmp; assign state = tmp; always@(posedge clk) begin if (rst == 0) begin tmp = 3'B000; end else begin case (tmp) 3'B00...
`ifndef _alu `define _alu /*`include "rc_adder.v"*/ module alu( input [3:0] ctl, input [31:0] a, b, output reg [31:0] out, output zero); wire [31:0] sub_ab; wire [31:0] add_ab; wire oflow_add; wire oflow_sub; wire oflow; wire slt; assign zero = (0 == out); assign sub_ab = a - b; assig...
#include <bits/stdc++.h> using namespace std; const long long maxN = 1e7 + 5; const long long inf = 1e10; const long long mod = 1e9 + 7; long long n; long long a[maxN]; double f[maxN]; int main() { ios_base::sync_with_stdio(0); cin >> n; for (long long i = 1; i <= n; i++) { cin >> a[i]...
#include <bits/stdc++.h> using namespace std; int a[300007]; int main() { int n, k; scanf( %d%d , &n, &k); string s; cin >> s; int sum = 1; a[0] = 1; for (int i = (1); i <= (n - 1); ++i) { if (sum && s[i] == . ) a[i] = 1; sum += a[i]; if (i >= k) sum -= a[i - k]; ...
#include <bits/stdc++.h> using namespace std; const int N = 100010; int num[N], tot; int main() { int n, a1 = 2, a2 = 1, ans = 1; cin >> n; while (a1 - a2 <= n) { if (n % (a1 - a2) == 0) ans = a1 - a2; a1 *= 4; a2 *= 2; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long aa; bool bb; char ch; long long scan() { while (ch = getchar(), (ch < 0 || ch > 9 ) && ch != - ) ; ch == - ? (bb = 1, aa = 0) : (bb = 0, aa = ch - 48); while (ch = getchar(), (ch >= 0 && ch <= 9 )) aa = aa * 10 + ch - 48; r...
#include <bits/stdc++.h> using namespace std; void solve() { long long int n; cin >> n; string s = <3 ; for (int i = 0; i < n; i++) { string a; cin >> a; s += a; s += <3 ; } string b; cin >> b; long long int j = 0; for (int i = 0; i < b.size(); 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...