text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; vector<long long int> arr; vector<long long int> b; long long int l, f; long long int mid; long long int bin_s(long long int x) { l = 0; f = b.size() - 1; while (l <= f) { mid = (l + f) / 2; if (b[mid] > x) f = mid - 1; if (b[mid] <...
//Legal Notice: (C)2010 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...
/** * This is written by Zhiyang Ong * for EE577b Homework 4, Question 4 */ // Behavioral model for the register file module regfile(data_out, data_in, wraddr, rdaddr, wren, clk); // Definitions for the constants the SIPO convertor // parameter PARAM_NAME = VALUE; /** * Depth = number of rows for the register ...
#include <bits/stdc++.h> enum { WHITE, GREY, BLACK }; using namespace std; long long int inf = 1e18; template <class T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <typename T> T last_bit(T n) { ret...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2007 Corgan Enterprises LLC // // 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 Foundation; either version 2 of...
#include <bits/stdc++.h> using namespace std; inline long long cal(int a, int b, int c, int l) { int x = min(l, a - b - c); if (x < 0) return 0; return (long long)(x + 2) * (x + 1) / 2; } int main() { int a, b, c, l; cin >> a >> b >> c >> l; long long ans = (long long)(l + 1) * (l + 2) *...
#include <bits/stdc++.h> using namespace std; template <typename T> void pfill(T* pst, const T* ped, T val) { for (; pst != ped; *(pst++) = val) ; } const double pi = acos(-1); const double eps = 0; typedef class Point { public: int x, y, deg, id; Point() : x(0), y(0), deg(0), id(0) {...
#include <bits/stdc++.h> using namespace std; struct pl { int num, t1, t2, h1, h2; }; vector<pl> h[(1 << 16) + 5]; int n, k, su; int s[22], sum[(1 << 16) + 5], si[(1 << 16) + 5]; bitset<200000000> fl, ft; int work(int a) { if (a % k == 0) return work(a / k); return a; } int change(int a,...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int MODV = 1e9 + 7; int b[1001]; int ans[1005]; vector<pair<int, int> > sorted; vector<pair<int, int> > unsorted; void make_ans(int n) { for (auto it : sorted) { int x = it.first; int y = it.second; for (int i...
#include <bits/stdc++.h> using namespace std; double PI = 3.14159265358979323843; void Time() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void print(int n) { if (n == 0) { return; } print(n - 1); cout << Hello world << endl; } long long arr[1000...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int count = 1; bool res = false; for (int i = 0; i < s.length() - 1; i++) { if (s.at(i) == s.at(i + 1)) { count++; if (count > 6) { res = true; break; } } else {...
/** * 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 /* Copyright 2015, Google Inc. 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 l...
/** * 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; struct chip { char dir; chip *u, *r, *d, *l; chip(char _dir) { dir = _dir; u = r = d = l = NULL; } }; int main(int argc, char* argv[]) { int n, m; cin >> n >> m; chip*** t; t = (chip***)malloc(n * sizeof(chip**)); for ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2006 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=0; reg [63:0] crc; reg [63:0] sum; reg out1; sub...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, i, pos = -1, flag; string s1, s2; cin >> n >> m; cin >> s1; cin >> s2; for (i = 0; i < n; i++) { if (s1[i] == * ) { pos = i; break; } } if (pos == -1) { if (s1 == s2) ...
//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 associate...
#include <bits/stdc++.h> using namespace std; long long ara[400005], csum1[400005], csum2[400005]; int main() { int n; scanf( %d , &n); long long sum = 0; for (int i = 0; i < n; i++) scanf( %lld , &ara[i]), sum += ara[i], csum1[ara[i]] += ara[i], csum2[ara[i]]++; for (int i = 1...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:47:57 05/30/2013 // Design Name: // Module Name: fsm_mulplier // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; const double EPS = 1E-9; const int INF = 1000000000; const long long INF64 = (long long)1E18; const double PI = 3.1415926535897932384626433832795; long long gcd(long long a, long long b) { if (a < b) return gcd(b, a); if (b == 0) return a; return gcd...
#include <bits/stdc++.h> const int N = 200000; int f[N + 5]; namespace segt { const int S = (N << 2); struct type { int mn, lm, rm, m, s; friend type operator+(const type &a, const type &b) { type c; c.mn = std::min(a.mn, b.mn), c.m = std::max(a.m, b.m); if (a.mn < b.mn) { c....
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/* * global_reset Holds the system in reset for the first few cycles * * Ensures reset functionality is completed at start up * Relies on FPGA setting default value for reset counter * * Part of the CPC2 project: http://intelligenttoasters.blog * * Copyright (C)2016 * * This program is free software; you ca...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return x * f; } const long long MAXN = 600010; const long long INF ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10, p = 1e9 + 7; int n, cnt[26], inv[N], fac[N], finv[N]; char a[N], b[N]; inline int solve(char *s) { int ans = 0, noans = fac[n]; memset(cnt, 0, sizeof cnt); for (int i = 1; i <= n; ++i) ++cnt[a[i] - a ]; for (int i = 0; i < ...
#include <bits/stdc++.h> using namespace std; int ch[3000005][2]; int v[3000005]; map<int, int> mp; int sz; void inser(int x) { int u = 0; for (int i = 20; i >= 0; i--) { int c = x >> i & 1; if (!ch[u][c]) { memset(ch[sz], 0, sizeof(ch[sz])); v[sz] = 0; ch[u][c] =...
#include <bits/stdc++.h> using namespace std; int gcd(int A, int B) { if (B == 0) return A; else return gcd(B, A % B); } long long int mod_exponentiation(long long int base, long long int exponent, int modulus) { long long int result = 1; while (exp...
#include <bits/stdc++.h> using namespace std; long long int a[100001] = {0}; long long int d[100001] = {0}; long long int vis[100001] = {0}; long long int cons[100001] = {0}; vector<long long int> vec[100001]; void dfs(long long int x, long long int p) { vis[x] = 1; if (a[x] == 1) { if (a[p]...
`default_nettype none module execute_load_store( input wire iCLOCK, input wire inRESET, input wire iRESET_SYNC, //Event CTRL input wire iEVENT_HOLD, input wire iEVENT_START, input wire iEVENT_IRQ_FRONT2BACK, input wire iEVENT_IRQ_BACK2FRONT, input wire iEVENT_END, //State input wire iSTATE_NORM...
#include <bits/stdc++.h> int main() { int n, k, l, c, d, p, nl, np, a, b, r; scanf( %d %d %d %d %d %d %d %d , &n, &k, &l, &c, &d, &p, &nl, &np); a = (k * l) / (n * nl); b = c * d / n; r = p / (n * np); int x; if ((a < 1) || (b < 1) || (r < 1)) x = 0; else { x = (a < b) ? ((...
`default_nettype none `timescale 1ns / 1ps // This module implements the set of 31 64-bit wide registers for the CPU. // // Note that reading the register bank is _synchronous_, not asynchronous. // This means you must present the desired register address prior to a clock // edge, and the contents of the indicated reg...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000010; int ro[maxn]; int up(int u) { return (ro[u] == u) ? u : ro[u] = up(ro[u]); } int me[maxn]; vector<int> no[maxn]; vector<pair<int, int> > q; int o[maxn]; queue<int> s[2]; int main() { int n, m, t, k; scanf( %d%d , &n, &m)...
#include <bits/stdc++.h> int main() { long long a, b, c; scanf( %lld %lld , &a, &b); c = (b > (a + 1) / 2) ? 2 * (b - (a + 1) / 2) : 2 * b - 1; printf( %lld , c); return 0; }
#include <bits/stdc++.h> using namespace std; map<int, map<int, vector<int>>> answers; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int bus, tram, money; cin >> bus >> tram >> money; string s; cin >> s; int cur = s.size() - 2; while (true) { c...
#include <bits/stdc++.h> using namespace std; const int N = (int)6e4 + 2; int n; map<string, int> mp; vector<pair<string, int>> v; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; string str; for (int i = 0; i < n; ++i) { cin >> str; mp[str] = i; } ...
#include <bits/stdc++.h> using namespace std; int a, b, c, d, e; int main() { scanf( %d%d%d%d%d , &a, &b, &c, &d, &e); cout << min(a, min(b, min(c / 2, min(d / 7, e / 4)))); return 0; }
Require Import Iron.Language.SimplePCF.Preservation. Require Export Iron.Language.SimplePCF.SubstExpExp. Require Export Iron.Language.SimplePCF.Step. Require Export Iron.Language.SimplePCF.Ty. Require Export Iron.Language.SimplePCF.Exp. (* Big Step Evaluation. This is also called 'Natural Semantics'. It provid...
#include <bits/stdc++.h> using namespace std; int dp[505][505]; int a[505][505]; int main() { int n; int i, j, k; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i][i]; for (j = i; j <= n; j++) dp[i][j] = j - i + 1; } for (int len = 2; len <= n; len++) { for (i = 1; i + l...
#include <bits/stdc++.h> using namespace std; int x[101010], v[101010], t[101010]; int n, s; int l[1010101], r[1010101]; bool check(double m) { memset(l, 0, sizeof(l)); memset(r, 0, sizeof(r)); for (int i = 1; i <= n; i++) { if (t[i] == 1) { if (1.0 * x[i] / v[i] < m) l[0]+...
#include <bits/stdc++.h> using namespace std; struct dragon { int sila; int dodatek; }; bool operator<(dragon A, dragon B) { return A.sila < B.sila; } int main() { int s, n; cin >> s >> n; vector<dragon> D(n); for (int i = 0; i < n; i++) { cin >> D[i].sila >> D[i].dodatek; } ...
#include <bits/stdc++.h> using namespace std; long long int fast_expo(long long int x, long long int p) { if (p == 0) return 1; else if (p % 2 == 0) { long long int t = fast_expo(x, p / 2) % 998244353; return (t * t) % 998244353; } else return (x * (fast_expo(x, p - 1)) % 9982443...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// (c) Copyright 1995-2015 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 // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant ...
/* * 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 n, a[11] = {0}, i, maxx, c; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; if (i == 1) maxx = a[1]; else maxx = max(a[i], maxx); } printf( %d , maxx ^ a[n]); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; int ans = 1; for (int i = 1; i <= min(a, b); i++) ans *= i; cout << ans; }
// ---------------------------------------------------------------------- // Copyright (c) 2016, 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 = 203; const int MOD = 1e9 + 7; int n, ssz; string s; int len[N][2]; int dp[N][N][N][2]; int calc(const string &t) { int tsz = t.size(); for (int i = tsz; i > 0; --i) { if (s.substr(0, i) == t.substr(tsz - i, i)) return 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...
//############################################################################# //# Function: Dual data rate input buffer (2 cycle delay) # //############################################################################# //# Author: Andreas Olofsson # ...
#include <bits/stdc++.h> using namespace std; int A, B; char a[5555]; char b[5555]; int dp[5555][5555]; int main() { scanf( %d%d , &A, &B); scanf( %s%s , a + 1, b + 1); int ans = 0; int i, j; for (i = 1; i <= A; i++) { for (j = 1; j <= B; j++) { if (a[i] == b[j]) dp[i][j] =...
#include <bits/stdc++.h> using namespace std; const int max_dp = 2e5 + 1; int dp[101][max_dp]; int n, k; int a[101], b[101]; int solve(int num, int bal) { if (dp[num][bal] != -1) { return dp[num][bal]; } if (num == 0) { if (bal == 1e5) { return 0; } else { retur...
module buf_add_manage( input clk, input reset, input [3:0] aging_recycle_addr, input aging_recycle_addr_wr, input [3:0] pkt_out_recycle_addr, input pkt_out_recycle_addr_wr, output reg buf_addr_wr, output reg [3:0] buf_addr ); reg [3:0] count; wire aging_recycle_add...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03:39:55 05/13/2012 // Design Name: // Module Name: tv80_to_t80_wrapper // Project Name: // Target Devices: // Tool versions: // Description: // // Dependen...
#include <bits/stdc++.h> using namespace std; int euclid(int m, int n) { int amari; if ((amari = m % n) == 0) { return n; } else { return euclid(n, amari); } } int main() { int N; int A[101]; cin >> N; for (int i = 1; i <= N; i++) { cin >> A[i]; } vector...
// ledtest_mm_interconnect_2_avalon_st_adapter.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 17.0 595 `timescale 1 ps / 1 ps module ledtest_mm_interconnect_2_avalon_st_adapter #( parameter inBitsPerS...
#include <bits/stdc++.h> using namespace std; bool comp(pair<long long, long long> a, pair<long long, long long> b) { return a.first > b.first; } long long findBest(vector<pair<long long, long long> > &ps, long long x) { long long res = 0; for (long long i = 0; i < ps.size(); i++) { long long ...
module block #( parameter M = 8 ) ( input [M-1:0] in, input clk, input start, output [M-1:0] out ); if (`CONFIG_BERLEKAMP) begin reg [M-2:0] b = 0; reg i = 0; reg s = 0; always @(posedge clk) begin s <= start; if (start) begin b <= b[M-2:0]; i <= in[M-1:0]; end else begin i <= in[M-2]; b <...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k, i, j; cin >> n >> k; int a[n - k + 1]; string s; for (i = 0; i < n - k + 1; i++) { cin >> s; if (s[0] == Y ) a[i] = 0; else a...
#include <bits/stdc++.h> using namespace std; int a[4][2]; int b[4][2]; int vis[205][205]; int main() { bool flag = 0; int x1, x2, y1, y2; for (int i = 0; i < 4; i++) { scanf( %d %d , &a[i][0], &a[i][1]); } for (int i = 0; i < 4; i++) { scanf( %d %d , &b[i][0], &b[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 la...
#include <bits/stdc++.h> int arr[100005]; int k; void unsort(int left, int right) { if (k <= 0 || left >= right - 1) return; int mid = (left + right) / 2; std::swap(arr[mid - 1], arr[mid]); --k; unsort(left, mid); unsort(mid, right); } int main() { int n; scanf( %d%d , &n, &k);...
// ================================================================== // >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< // ------------------------------------------------------------------ // Copyright (c) 2013 by Lattice Semiconductor Corporation // ALL RIGHTS RESERVED // ------------...
#include <bits/stdc++.h> using namespace std; int i, j, viz[1005], n; int sol[100005], nrsol; int main(void) { cin >> n; for (i = 2; i <= n; ++i) if (viz[i] == 0) { int nrp = i; int put = nrp; while (put <= n) { sol[++nrsol] = put; put *= nrp; } ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; void rot(int n, int *x, int *y, int rx, int ry); int xy2d(int n, int x, int y) { int rx, ry, s, d = 0; for (s = n / 2; s > 0; s /= 2) { rx = (x & s) > 0; ry = (y & s) > 0; d += s * s * ((3 * rx) ^ ...
/* * 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 "senior_defines.vh" module write_back_mux #(parameter ctrl_w = `WB_MUX_CTRL_WIDTH) ( input wire [15:0] io_rf_bus_i, input wire [15:0] id_data_bus_i, input wire [15:0] mac_data_bus_i, input wire [15:0] alu_data_bus_i, input wire [15:0] rf_opa_in_bus_i, input wire [15:0] dm0_data_bus_i, ...
/* This file is part of JT51. JT51 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 Foundation, either version 3 of the License, or (at your option) any later version. JT51 program is distributed in the hope...
#include <bits/stdc++.h> constexpr static int MAXD = 20000; using namespace std; bool check() { int n; cin >> n; int dist = 0; bool r = true; for (int i = 0; i < n; i++) { int t; string dir; cin >> t >> dir; if (dist == 0 && dir != South ) r = false; if (dist == ...
#include <bits/stdc++.h> using namespace std; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int32_t main() { c_p_c(); long long int t; cin >> t; while (t--) { long long int n, k; cin >> n >> k; vector<long long int> a(n), b(k); for (l...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; using ll = long long; using ld = long double; using pi = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vpi = vector<pi>; using si = set<int>; using sl = set<ll>; using qi = qu...
#include <bits/stdc++.h> using namespace std; const int Maxn = 100000 + 19; int a[Maxn], Le[Maxn], Ri[Maxn], cnt, L, R, n, i, ans; int main() { scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &a[i]); Le[cnt = 1] = 1; a[++n] = a[n - 1] - 1; for (i = 1; 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 la...
#include <bits/stdc++.h> using namespace std; template <typename X> void MA(X &a, X b) { a = max(a, b); } template <typename X> void MI(X &a, X b) { a = min(a, b); } int DEBUG = 0, MULTI = 0, GCJ = 0; struct solver_t; solver_t *solver; struct solver_t { vector<int> A; vector<vector...
/** * 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 t; cin >> t; while (t--) { long long n; cin >> n; vector<long long> v(n), vec; for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 0; i < n; i++) { if (v[i] == -1) continue; if (i - 1 >= ...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const long long MOD = 1000000007; const long long INF = 1LL << 60; long long xn[101010]; int solve() { long long a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f; long long ans = 0; for (long long i = 0; i <= d; i++...
// encodes a one hot signal into an address // 0001 --> 0, v=1 // 0010 --> 1, v=1 // 0100 --> 2, v=1 // 1000 --> 3, v=1 // 0000 --> 0, v=0 // O*1O*1O* --> undefined `include "bsg_defines.v" // we implement at this as a parallel prefix computation // it is basically a big, clever tree of OR's with...
#include <bits/stdc++.h> long long int n, k; long long int a[100010], max; long long int print[100010], pc; int main(void) { long long int i, j, f, l, mid; long long int sum, baki = 2147483647; scanf( %I64d %I64d , &n, &k); for (i = 1; i <= n; i++) { scanf( %I64d , &a[i]); if (max < ...
//Dummy tb for sound mx. //Tb is only for debug this module. `timescale 1ns / 1ps `include "aDefinitions.v" `include "collaterals.v" `include "SoundControllerMX.v" `include "SoundControllerOSC1.v" `include "SoundControllerOSC2.v" module tb; reg clk; wire clk131k; wire clk262k; reg rst; wire [4:0] rig...
/** * 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 I2S_DAC(clk50M, sck, ws, sd, //DAC_L, DAC_R dac_dat, outr, sw1 ); //general input wire clk50M; //i2s input wire sck, ws, sd; //custom dac //output wire DAC_L, DAC_R; //r2r 8bit dac output wire [7:0] dac_dat; output wire outr; input wire sw1; //i2s receiver wire [31:0] data_left; wire [31:0] data_right; i2s...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int MAXN = 1000; const int MAXK = 1000; int n, K; char s[MAXN + 1]; int act[MAXN + 1][2 * MAXK + 1]; char ret[MAXN + 1]; void run() { scanf( %d%d%s , &n, &K, s); m...
#include <bits/stdc++.h> std::mt19937 rng( (int)std::chrono::steady_clock::now().time_since_epoch().count()); struct PT { long long x, y; PT(long long _x = 0, long long _y = 0) : x(_x), y(_y) {} PT operator+(const PT &p) const { return PT(x + p.x, y + p.y); } PT operator-(const PT &p) const { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1000000007; const int inv3 = (mod + 1) / 3; const int maxn = 3003003; int fac[maxn], ifac[maxn]; int qpow(int a, int n) { int ans = 1; for (; n; n >>= 1, a = (ll)a * a % mod) if (n & 1) ans = (ll)ans * a % mo...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int n, m; bool graph[101][101]; bool traversed[101]; void search(int x) { for (int i = 0; i <= m; i++) if (graph[x][i]) for (int k = 0; k < n; k++) if (graph[k][i] && !traversed[k]) { traversed[k] = true; search(...
module I2C_WRITE_WDATA ( input RESET_N , input PT_CK, input GO, input [15:0] REG_DATA, input [7:0] SLAVE_ADDRESS, input SDAI, output reg SDAO, output reg SCLO, output reg END_OK, //--for test output reg [7:0] ST , outp...
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; int t; void solve() { int n, res = 0, j = 0; string s; cin >> n >> s; map<int, int> m; for (int i = 0; i <= n; i++) { if (s[i] == x ) { m[j]++; } else { j++; } } for (auto i...
#include <bits/stdc++.h> using namespace std; int n; long long j; long long ix, iy; int mx[100100], my[100100]; inline void reflect(int in, long long ax, long long ay, long long& bx, long long& by) { bx = ax + ((mx[in] - ax) << 1); by = ay + ((my[in] - ay) << 1); return; ...
/* * 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 <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<map<int, vector<string> > > A(m + 1); for (int x = 0; x < n; x++) { string name; int r, points; cin >> name >> r >> points; A[r][points].push_back(name); } for (int x = 1; x <= ...
//--------------------------------------------------------------------------- //-- Copyright 2015 - 2017 Systems Group, ETH Zurich //-- //-- This hardware module 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 ...
#include <bits/stdc++.h> using namespace std; long long b, a, r; int k; int d0[360360 + 5], d1[360360 + 5]; void sim() { assert(a <= b); while (b > a) { long long w = b - 1; for (int i = 2, ThxDem = k + 1; i < ThxDem; ++i) if (b / i * i >= a) w = min(w, b / i * i); b = w; ...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:64000000 ) char buf[1 << 7]; string s; int smask; int D1[5][5] = {{0, 3, 7, -1, -1}, {1, 4, 8, 12, -1}, {2, 5, 9, 13, 16}, {6, 10, 14, 17, -1}, {11, 15, 18, -...
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000; const long long LINF = (long long)INF * INF; const int MAX = 2e5; const double EPS = 1e-9; const double PI = acos(-1.); int n, m, k; vector<pair<int, long long> > g[300005]; set<pair<pair<int, int>, int> > elist; set<i...
module erx_timer (/*AUTOARG*/ // Outputs timeout, // Inputs clk, reset, timer_cfg, stop_count, start_count ); parameter DW = 32; parameter AW = 32; input clk; input reset; input [1:0] timer_cfg; //masks MSB of each byte (all zero is off) input stop_count; ...