text
stringlengths
59
71.4k
#include <bits/stdc++.h> const int inf = (1 << 29) - 1; const int maxn = (int)3e5 + 10; const int mod = (int)1e9 + 7; using namespace std; int n, m, k; vector<int> g[2020]; int col[2020][1010]; pair<int, int> e[maxn]; int ans[maxn]; void dfs(int v, int cur, int nxt) { if (col[v][cur] == 0) { ...
#include <bits/stdc++.h> using namespace std; long long int mul(long long int a, long long int b) { return ((a % int(1e9 + 7)) * (b % int(1e9 + 7))) % int(1e9 + 7); } long long int add(long long int a, long long int b) { return ((a % int(1e9 + 7)) + (b % int(1e9 + 7))) % int(1e9 + 7); } long long in...
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (x) return (gcd(y % x, x)); else return y; } int main() { int a, b, n; cin >> a >> b >> n; for (int i = 0; i < 1000; i++) { int x = gcd(a, n); if (x <= n) n -= x; else { cou...
/* * 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 law...
#include <bits/stdc++.h> using namespace std; int main() { int q, n, x, y, f1, f2, f3, f4; cin >> q; for (int i = 0; i < q; ++i) { cin >> n; int minx = -100000, miny = -100000, maxx = 100000, maxy = 100000; for (int o = 0; o < n; ++o) { cin >> x >> y >> f1 >> f2 >> f3 >> f4; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int cnt = 0, rem = m; int arr[10000]; for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = 0; i < n; i++) { if (rem >= arr[i]) rem -= arr[i]; else { cnt++; rem = m; ...
#include <bits/stdc++.h> using namespace std; unsigned long long int fibonocci(unsigned long long int n) { unsigned long long int f, f1, f2, i; f1 = 1; f2 = 2; i = 2; while (1) { f = f1 + f2; if (f > n) { return i - 1; } f1 = f2; f2 = f; i++; } }...
// Copyright (c) 2015 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...
// Code ok to distribute module autoasciienum_auto(); reg [2:0] /* auto enum sm_psm */ sm_psm; reg [2:0] /* auto enum sm_ps2 */ sm_ps2; localparam [2:0] // auto enum sm_psm PSM_IDL = 0, PSM_RST = 6, PSM_ZOT = 7; localparam [2:0] // auto enum sm_ps2 PS2_IDL = 0, PS2_...
module stimulus; parameter cyc = 10; parameter delay = 1; reg clk, rst_n, mode, ivalid; reg [`WIDTH-1:0] DATA; wire ovalid; wire [8:0] zeros; reg debug_level; reg [8*128-1:0] fsdbfile, inputfile, goldenfile; reg [`WIDTH+1:0] input_vector[0:30000]; reg [8:0] golden_vector[0:30000]; integer i, j, error; L...
#include <bits/stdc++.h> using namespace std; int main() { int n, s; int ans = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> s; ans += s * i; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n; const int maxn = 4001; long long dp[maxn], c[maxn][maxn], s[maxn][maxn], sum[maxn]; long long pow(int k) { if (k == 0) return 1LL; if (k == 1) return 2LL; long long ans = pow(k >> 1); ans *= ans; if (k % 2) ans *= 2LL; return (ans % ...
#include <bits/stdc++.h> const int maxn = 100100; int t, T, n, m, n0, n1; int l[maxn], r[maxn], c[maxn], vis[maxn]; std::vector<int> v[maxn]; std::queue<int> q; inline void dfs(int x) { if (vis[x]) return; vis[x] = 1; for (auto i : v[x]) c[i] = !c[x], dfs(i); } int main() { std::ios::syn...
// ---------------------------------------------------------------------- // Copyright (c) 2015, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> using namespace std; const int N = 500005; const int inf = 1000 * 1000 * 1000; const int mod = 998244353; int n; vector<int> g[N]; int dp[N][3]; int sz[N][3]; void dfs(int v, int p) { dp[v][0] = dp[v][1] = 0; sz[v][0] = 1; sz[v][1] = 0; for (int i = 0; i < (int...
#include <bits/stdc++.h> using namespace std; int main() { int r, c; char s[15][15]; int cake = 0; int row = 0; scanf( %d %d , &r, &c); for (int i = 1; i <= r; i++) { scanf( %s , s[i]); } for (int i = 1; i <= r; i++) { for (int j = 0; j < c; j++) { if (s[i][j] == ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000 * 100 + 10; vector<int> vec[MAXN]; int c[MAXN]; long long dp[2][MAXN]; void dfs(int v) { vector<int> temp; long long all = 1; for (int i = 0; i < (int)vec[v].size(); i++) { int u = vec[v][i]; dfs(u); temp.push_...
#include <bits/stdc++.h> using namespace std; template <class T> inline void checkMin(T& a, T b) { if (b < a) a = b; } template <class T> inline void checkMax(T& a, T b) { if (b > a) a = b; } const int N = 22; const long long INF = 1LL << 60; int n, m, a[N], b[N]; long long dp[N][N], tmp[N...
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; int dy8[] = {1, -1, -1, 0, 1, -1, 0, 1}; long long bigmod(long long a, long long b, long long c) { if (b == 0) return 1 % c; long long x = bigmod(a, b / 2, c); ...
//altpll bandwidth_type="AUTO" CBX_DECLARE_ALL_CONNECTED_PORTS="OFF" clk0_divide_by=10 clk0_duty_cycle=50 clk0_multiply_by=1 clk0_phase_shift="0" compensate_clock="CLK0" device_family="Cyclone IV E" inclk0_input_frequency=20000 intended_device_family="Cyclone IV E" lpm_hint="CBX_MODULE_PREFIX=comm_pll" operation_mode="...
#include <bits/stdc++.h> using namespace std; long long n, a, b, k; long long q; long long param = 0; string ciag; long long MOD = 1000000009; long long potega(long long a_1, long long n_1) { if (n_1 == 0) return 1; if (n_1 == 1) return a_1; else if (n_1 % 2 == 0) { long long s = p...
// 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 May 09 14:50:53 2017 // Host : DESKTOP-7MUQLTN running 64-bit major releas...
#include <bits/stdc++.h> char a[200005], b[200005]; int cmp(char *p, char *q, int n) { if (!strncmp(p, q, n)) return 1; if (n % 2) return 0; int temp = n / 2; if (cmp(p, q, temp) && cmp(p + temp, q + temp, temp)) return 1; else if (cmp(p + temp, q, temp) && cmp(p, q + temp, temp)) re...
#include <bits/stdc++.h> using namespace std; string s[100001]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> s[i]; } long double x = 0; long long ans = 0; for (int i = n; i >= 1; i--) { if (s[i] == halfplus ) { x += 0.5; } ...
#include <bits/stdc++.h> using namespace std; const int INFint = 2e9; const long long INF = 1e18; const long long MOD = 1000000007ll; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; vector<long long> a(n), b; for (auto &x : a) cin >> x; b = a; sort(b.begin(), b.end()); ...
#include <bits/stdc++.h> using namespace std; const long long maxn = 5e5 + 10; const long long INF = 1e18; long long n, a[maxn], po, maxx = 0, m[maxn]; int main() { std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> m[i]; if (...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<vector<int> > v = {{1}}; for (int i = 0; i < k; i++) { int current = v.size(); for (int j = 0; j < current; j++) { vector<int> vnew(2 * current); for (int l = 0; l < current; l++) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using cd = complex<ld>; int query(int l, int r) { cout << ? << l << << r << endl; cin >> l; return l; } int main() { ios_base::sync_with_stdio(false); cin.ti...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ `timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time unit ...
#include <bits/stdc++.h> using namespace std; bool cmp_vector(const vector<int>& a, const vector<int>& b) { int i; for (i = 0; i < a.size(); i++) { if (a[i] > b[i]) { return false; } else if (a[i] < b[i]) { return true; } } return false; } int main() { int h...
#include <bits/stdc++.h> using namespace std; int n; int mx = 0, sum = 0; int main() { cin >> n; for (int i = 1; i <= n; ++i) { int a; cin >> a; mx = max(mx, a); sum += a; } sum *= 2; sum += n; sum /= n; cout << max(sum, mx) << 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...
/** * 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...
//Legal Notice: (C)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 do...
#include <bits/stdc++.h> char year[10]; int main() { scanf( %s , year); int l = strlen(year) - 1; int num = 0, num2 = 0; for (int i = 0; i <= l; i++) { num = num * 10 + year[i] - 0 ; } for (int i = 1; i <= l; i++) num2 = num2 * 10 + year[i] - 0 ; int x = 1; for (int i = 1; i ...
#include <bits/stdc++.h> using namespace std; struct team { int prob; int time; }; bool comp(team a, team b) { return (a.prob > b.prob) || ((a.prob == b.prob) && (a.time < b.time)); } int main(int argc, char const *argv[]) { int n, k; cin >> n >> k; team t[n]; for (int i = 0; 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; struct node { int t, l, r, m; } op[5010]; int a[5010], b[5010], n, m; bool solve() { int p, i, k; for (i = 1; i <= n; i++) { a[i] = 1000000000; } memset(b, 0, sizeof(b)); for (p = 1; p <= m; p++) { if (op[p].t == 1) for ...
#include <bits/stdc++.h> const long long mod = 1e9 + 9; using namespace std; const long long N = 105; long long vis[N], l[N], who[N], n, m; void fail() { cout << -1 n ; exit(0); } int32_t main() { cin >> n >> m; for (long long i = 1; i <= m; i++) cin >> l[i]; long long cur = l[1]; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, A[100], B[100]; cin >> n >> k; for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 0; i < k; i++) cin >> B[i]; if (k > 1) { cout << Yes n ; return 0; } for (int i = 0; i < n; i++) if (!A[i]) A[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; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long long maxn = 60; const long long mod = 1e9 + 7; const long double PI = acos((long double)-1); long long pw(long long a, long long b, long long md = mod) { long long res = 1; w...
////////////////////////////////////////////////////////////////////// //// //// //// File name "pciw_fifo_control.v" //// //// //// //// This file is part of the "PCI ...
`timescale 1ns / 1ps module CPUSim(); reg clk; reg reset; wire [31:0] pc, pcNext; wire [2:0] state; wire [31:0] instruction; wire [31:26] op; wire [25:21] rs; wire [20:16] rt; wire [15:11] rd; wire [10:6] sa; wire [15:0] imm; wire [25:0] address; wire [31:0] readData...
module top; reg a; reg q, d; event foo; real rl; int ar []; int start = 0; int stop = 1; int step = 1; int done = 0; task a_task; real trl; event tevt; reg tvr; $display("user task"); endtask always_latch begin: blk_name event int1, int2; real intrl; q = d; -> f...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 0; char ch = getchar(); while (!isdigit(ch)) f |= ch == - , ch = getchar(); while (isdigit(ch)) x = 10 * x + ch - 0 , ch = getchar(); return f ? -x : x; } inline long long llread() { long long x = 0, f = 0...
module ledtest ( clk_clk, hps_io_hps_io_emac1_inst_TX_CLK, hps_io_hps_io_emac1_inst_TXD0, hps_io_hps_io_emac1_inst_TXD1, hps_io_hps_io_emac1_inst_TXD2, hps_io_hps_io_emac1_inst_TXD3, hps_io_hps_io_emac1_inst_RXD0, hps_io_hps_io_emac1_inst_MDIO, hps_io_hps_io_emac1_inst_MDC, hps_io_hps_io_emac1_inst_RX_CTL, ...
#include <bits/stdc++.h> using namespace std; const int mn = 1e6 + 10; const long long mod = 998244353; int a[100], t[100]; string s[100]; int dp[21][1 << 20]; int main() { int n, m; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , a + i); sort(a, a + n, greater<int>()); scanf(...
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); const int N = 3e5 + 7; const int LG = 19; int go[N][LG]; int a[N]; int last[LG]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, q; cin >> n >> q; for ...
/////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2014 Francis Bruno, All Rights Reserved // // 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; struct data { int x; int y; }; int main() { long long n; cin >> n; vector<data> info; long long smallest = 9999999999; long long largest2 = -1; for (int i = 0; i < n; i++) { data temp; cin >> temp.x >> temp.y; if (te...
/* * 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...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <queue> #include <deque> #include <bitset> #include <iterator> #include <list> #include <stack> #include <map> #include <set> #include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> ...
#include <bits/stdc++.h> using namespace std; int main() { string s, ans, s1; cin >> s; s1 = s; int l = s.length(), i; int j = l - 1, flag = 0; while (i < j) { if (s[i] != s[j]) { flag = 1; break; } i++; j--; } if (flag) { reverse(s1.begi...
#include <bits/stdc++.h> using namespace std; int n, m, sx, sy, ma[1005][1005], vis[1005][1005], ans, t, tot = 99999999; int dx[5] = {1, -1, 0, 0}; int dy[5] = {0, 0, 1, -1}; char maa[1005][1005]; void bfs(int u, int v) { queue<int> qx; queue<int> qy; queue<int> qt; qx.push(u), qy.push(v), q...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * 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 INF = (int)1E9; const long long LINF = (long long)1E18; int INP, AM; char BUF[(1 << 10) + 1], *inp = BUF; template <typename T> T gcd(T a, T b) { return (b == 0) ? abs(a) : gcd(b, a % b); } template <typename T> inline T lcm(T a, T b) { ...
/** * 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 char nl = n ; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, v1, v2, t1, t2; cin >> n >> v1 >> v2 >> t1 >> t2; if (n * v1 + t1 * 2 < n * v2 + t2 * 2) cout << First << nl; else if (n * v1 + t1 * 2 > n * v2 + t2 * 2...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ff first #define ss second #define pb push_back #define mp make_pair #define deb(x) cout<< #x << << x << n ; #define MAX 9223372036854775807 #define MIN -9223372036854775807 #define setbits(n) __builtin_popcountll(n...
#include <bits/stdc++.h> using namespace std; const int N = 55; const int dx[4] = {0, 0, -1, 1}; const int dy[4] = {-1, 1, 0, 0}; int n, m, cnt, cur; char a[N][N], s[N][N]; bool vis[N][N]; inline void dfs(int x, int y) { vis[x][y] = 1; ++cur; for (int xx, yy, k = 0; k < 4; k++) { xx = ...
//============================================================= // // Copyright (c) 2017 Simon Southwell. All rights reserved. // // Date: 22nd May 2017 // // This code 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 So...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; void run() { int n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << 1 << << 1 << n << -a[0] << n ; cout << 1 << << 1 << n << 0 << n ...
#include <bits/stdc++.h> using namespace std; int main() { long long int a = 100, c = 20, d = 10, e = 5; long long int note, n, rem; while (scanf( %lld , &n) != EOF) { note = n / a; rem = n % a; note = note + (rem / c); rem = rem % c; note = note + (rem / d); rem = re...
#include <bits/stdc++.h> using namespace std; void printAll(int n, ...) { if (1) { va_list ap; va_start(ap, n); for (int i = 1; i <= n; i++) cout << va_arg(ap, long long int) << ; cout << endl; va_end(ap); } } template <typename T> string toString(T n) { stringstre...
// nios_solo_mm_interconnect_0_avalon_st_adapter_002.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 15.1 185 `timescale 1 ps / 1 ps module nios_solo_mm_interconnect_0_avalon_st_adapter_002 #( paramete...
/** * 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; struct st { long long int num; long long int big; } w[200001]; bool cmp(st a, st b) { return a.big < b.big; } int main() { std::ios::sync_with_stdio(false); long long int n, i; char p; while (cin >> n) { queue<long long int> q; ...
// rom.v // // 16bit rom block with 4k of memory // // AVM rom block in Verilog // // This is an implementation of AVM in C for experimenation purposes. // It is both an AVM interpretr and an assembler for the instruction set. // // (C) 2016 David J. Goehrig // All rights reserved. // // Redistribution and use in so...
#include <bits/stdc++.h> using namespace std; long long ans[100100]; int c[100100]; int v[100100]; int main() { int n, q; scanf( %d%d , &n, &q); for (int i = (0); i < (n); ++i) scanf( %d , &v[i]); for (int i = (0); i < (n); ++i) { scanf( %d , &c[i]); c[i]--; } for (int i = ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(0); ; long long n, k, i; cin >> n >> k; long long a[n], pr[n + 1]; map<long long, long long> f; for (i = 0; i < n; i++) { cin >> a[i]; f[a[i]]++; } int fl = 0; for (aut...
#include <bits/stdc++.h> using namespace std; using namespace std; const long long mo = 1000000007; int n, k; long long c[15][15]; long long f[210][210][10]; int flag[10][10] = {{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {1, 2, 0, 1, 0, 0, ...
// megafunction wizard: %ROM: 2-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: rom_shared.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =============...
/** * 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-2022 F4PGA 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed...
#include <bits/stdc++.h> using namespace std; void doit(long long int a[], long long int i, long long int sz) { long long int x; x = i + sz - 1; a[i] = x; for (i++; i <= x; i++) a[i] = i - 1; return; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n,...
#include <bits/stdc++.h> using namespace std; int a[1001]; int main() { int n, t, i, j, k, m; cin >> t; while (t--) { cin >> n >> m; for (i = 0; i < n; i++) cin >> a[i]; int ans = a[0]; for (i = 1; i < n; i++) { if (ans + a[i] <= m) ans += a[i]; else {...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; char c[101][101]; cin >> a >> b; for (int i = 1; i <= a; i++) { for (int j = 1; j <= b; j++) { if (i % 2 != 0) { c[i][j] = # ; } } } for (int i = 2; i <= a; i += 4) { for (int j ...
#include <bits/stdc++.h> using namespace std; int a[3005]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); } int ans = 0; for (int i = 1; i < n; i++) { for (int j = 0; j < i; j++) { if (a[i] < a[j]) { ans++; } ...
#include <bits/stdc++.h> using namespace std; int n; int a[1001], b[1001], c[1001], d[1001]; void solve() { cin >> n; int r = 1; int i = 1; cin >> a[i] >> b[i] >> c[i] >> d[i]; int sum = a[1] + b[1] + c[1] + d[1]; for (int i = 2; i <= n; i++) { cin >> a[i] >> b[i] >> c[i] >> d[i]; ...
`include "../scripts/crc_serial_gen.conf" module tb_crc_parallel; localparam CRC_SIZE = `CRC_SIZE; localparam FRAME_SIZE = `FRAME_SIZE; localparam CRC_INIT = 0; localparam CODE_SIZE = FRAME_SIZE + CRC_SIZE; localparam PATTERN_VECTOR_NUMBER = `PATTERN_VECTOR_NUMBER; localparam PATTERN_POLYNOMIAL_NUMBER = `PATTERN_VECTO...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:44:48 03/23/2016 // Design Name: Pi // Module Name: Y:/TEOCOA/EXP2/TEST_P.v // Project Name: EXP2 // Target Device: // Tool versions: // Descripti...
#include <bits/stdc++.h> using namespace std; typedef long long ll; using mseti = multiset<int>; using mmapii = multimap<int, int>; inline int int_max() { return numeric_limits<int>::max(); } inline int int_min() { return numeric_limits<int>::min(); } inline ll ll_max() { return numeric_limits<ll>::max();...
//----------------------------------------------------------------------------- // Title : MIPS Single-Cycle Control Unit // Project : ECE 313 - Computer Organization //----------------------------------------------------------------------------- // File : control_single.v // Author : John...
/** * 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 n, k, i, j; cin >> n; long long ans = 0; for (i = 1; i <= n; i++) { for (j = i; j <= n; j++) { k = sqrt(i * i + j * j); if (k * k == i * i + j * j && j <= k && k <= n) { ans++; } } ...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int mod = 10007; const long long INF = 1e18 + 1234; int setbit(int n, int pos) { return n = n | (1 << pos); } int resetbit(int n, int pos) { return n = n & ~(1 << pos); } bool checkbit(int n, int pos) { return (bool)(n & (1 <<...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:53:19 10/26/2014 // Design Name: // Module Name: tb_uart // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
/*************************************************************** ** Author: Oswaldo Cadenas () ** Date: September 27 2011 ** ** Test: Intended to test the vhd code in enumsystem.vhd ** ** A stimulus modules generates a count 0,1,.., 7, 1 and an enable signal ** A scoreboard forces a check according to the operation fou...
#include <bits/stdc++.h> using namespace std; using namespace std; const int MaxN = 100005, NA = -1, MaxC = 0x3F3F3F3F; int a[MaxN]; int n; multiset<int, greater<int> > s; deque<int> d; int main(void) { int i, v; multiset<int>::iterator it; while (scanf( %d , &n) != EOF) { for (i = 0;...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, a, b; cin >> n >> a >> b; string s = ; char x = a ; for (int i = 0; i < n; i++) { if (i % b == 0) x = a ; s += x; x++; } cout...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
// Copyright (c) 2000-2012 Bluespec, Inc. // 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, pub...
module dcache_top ( // System clock, reset and stall clk_i, rst_i, // to Data Memory interface mem_data_i, mem_ack_i, mem_data_o, mem_addr_o, mem_enable_o, mem_write_o, // to CPU interface p1_data_i, p1_addr_i, p1_MemRead_i, p1_MemWrite_i, p1_data_o, p1_st...
#include <bits/stdc++.h> using namespace std; int main() { int n, w, one = 0, two = 0, sum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> w; if (w == 100) { one++; } else { two++; } sum += w; } if (two % 2 == 0) { if (one % 2 == 0) { ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string s; cin >> s; long long tot = 0; long long cont = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == - && cont == 0) { tot += i + 1; } else if (s[i] ...