text
stringlengths
59
71.4k
/* * 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...
/** * bsg_nonsynth_mem_1r1w_sync_dma.v * */ `include "bsg_defines.v" module bsg_nonsynth_mem_1r1w_sync_dma #(parameter `BSG_INV_PARAM(width_p) , parameter `BSG_INV_PARAM(els_p) , parameter `BSG_INV_PARAM(id_p) , parameter data_width_in_bytes_lp=(width_p>>3) , parameter write_mask_width_lp=data...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x, l; int cnt = 0; for (int i = 0; i < n; i++) { cnt = 0; cin >> x; if (x % 7 != 0) { cnt++; } x /= 7; cout << x + cnt << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; string st; long n, k, ans, calc; int main() { ios_base::sync_with_stdio(0); cin >> n >> k; cin >> st; for (int i = 0; i < st.size(); i++) { if (st[i] == # ) ++calc; else { ans = max(ans, calc); calc = 0; } ...
#include <bits/stdc++.h> using namespace std; int a[3001]; void swap(int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } int main() { int n; cin >> n; ; for (int i = 0; i < n; i++) { cin >> a[i]; } vector<pair<int, int> > x; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, s, ans = 0, counter = 0; cin >> n >> s; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); while (ans < s) { counter++; ans += a[n - counter]...
#include <bits/stdc++.h> using namespace std; int main() { string s; int n, m; cin >> n >> m; char a, b; int flag1, flag2; cin >> s; for (int i = 0; i < m; i++) { cin >> flag1 >> flag2 >> a >> b; for (int j = flag1 - 1; j <= flag2 - 1; j++) { if (s[j] == a) { ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7, MAXN = 4e5 + 10; int dp[MAXN], dp2[MAXN]; int *cur = dp2, *prv = dp; int main() { int r, g; cin >> r >> g; int b = r + g; int n; for (n = 1; n * (n + 1) / 2 <= b; n++) ; n--; cur[0] = 1; for (int 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...
#include <bits/stdc++.h> using namespace std; typedef long long big; #define bigvec vector<big> #define pbb pair<big, big> #define pii pair<int, int> #define fe first #define se second #define maxheap priority_queue #define uset unordered_set #define umap unordered_map #define fr(i, j) for(big ...
#include <bits/stdc++.h> using namespace std; int main() { string p; int i; bool work = false; cin >> p; for (i = 0; i < p.size(); i++) if (p[i] == H || p[i] == Q || p[i] == 9 ) work = true; if (work) cout << YES ; else cout << NO ; return 0; }
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Mon Feb 27 19:26:51 2017 // Host : GILAMONSTER running 64-bit major release (...
// // Copyright 2011 Ettus Research 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 3 of the License, or // (at your option) any later version. // // This program is dis...
/** * 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 sm (/*AUTOARG*/ // Outputs state_r, // Inputs clk, rst_ ); //==================== Constant declarations ============== parameter [2:0] // synopsys enum state_info IDLE = 3'b000, SEND = 3'b001, WAIT1 = 3'b010, UPDATE1 = 3'b011, WAIT2 = 3'b100; parameter [2:0] /* synop...
/** * A module for fetching the next instruction for * the processor to execute. * * @author Robert Fotino, 2016 */ `include "definitions.vh" module instr_cache ( input clk, input boot_done, // Requests for instructions input [`ADDR_BITS-1:0] inst...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: fifo_64_1.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // =================================...
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, j, r, mn, mx, x, cnt = 0, a = 1, b = 1; string s; cin >> n; for (i = 0; i < n; i++) { cin >> s; if (s == UR || s == DL ) a++; else if (s == UL || s == DR ) b++; else { a++...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int x[n], x1[m], x2[m], y[m]; for (int i = 0; i < n; i++) cin >> x[i]; sort(x, x + n); vector<int> v; for (int i = 0; i < m; i++) { cin >> x1[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; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long n, k; cin >> n >> k; long long l = 0; long long r = n; while (l != r) { long long mid = (l + r) / 2; if (mid * (mid + 1) / 2 - (n - ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 18:05:46 12/02/2014 // Design Name: // Module Name: ycrcb2rgb // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // ...
#include <bits/stdc++.h> using namespace std; double ans, m; int n; double binpow(double a, int b) { if (b == 0) return 1; else if (b == 1) return a; else if (b % 2 == 0) { double t = binpow(a, b / 2); return t * t; } else return a * binpow(a, b - 1); } int main...
module pipeline_ctrl( clk, RST, // clk e reset A_addr, // endereco dos registradores decodificados no pipe 2 B_addr, ctrl, // indica operacao a ser executada (ainda nao foi pro pipeline 3) ctrl_p34, // ctrl pipe 3-4 ctrl_p45, // ctrl pipe 4-5 reg_en_p52, // enable reg pipe 5-2 reg_addr_p34,...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2018.2 // Copyright (C) 1986-2018 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 * 1000 + 10; int n, t[MAXN]; vector<int> v; int main() { cin >> n >> t[0]; v.push_back(1); for (int i = 1; i < n; i++) { cin >> t[i]; if (t[i] == t[i - 1]) v[(int)v.size() - 1]++; else v.push_back(...
#include <bits/stdc++.h> using namespace std; template <class T> string i2s(T x) { ostringstream o; o << x; return o.str(); } int n, wt[100001], root; bool visited[100001]; pair<long long, long long> mem[100001]; vector<int> adj[100001]; pair<long long, long long> go(int u) { if (visit...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, m; cin >> n >> m; for (long long int i = 0; i < n; i += 1) { long long int s, f, t; cin >> s >> f >> t; long long int q = t / (m - 1); ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Engineer: Amber // // Create Date: 05/23/2017 // Module Name: LED_joystick // Project Name: Joystick_Controller // Target Devices: ICE40 // Tool versions: APIO // Description: Toggles on-board LEDs depe...
//***************************************************************************** // (c) Copyright 2008 - 2013 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 /...
// Check that operators in an assignment pattern are evaluated correctly. The // result should be the same as assigning the expression to a variable with the // same type as the base type of the assignment pattern target. module test; int d[]; int tmp; bit failed = 1'b0; `define check(expr) \ d = '{expr...
// File expr.vhd translated with vhd2vl v2.4 VHDL to Verilog RTL translator // vhd2vl settings: // * Verilog Module Declaration Style: 1995 // vhd2vl is Free (libre) Software: // Copyright (C) 2001 Vincenzo Liguori - Ocean Logic Pty Ltd // http://www.ocean-logic.com // Modifications Copyright (C) 2006 Mark Go...
// ====================================================================== // DES encryption/decryption testbench // tests according to NIST 800-17 special publication // Copyright (C) 2012 Torsten Meissner //----------------------------------------------------------------------- // This program is free software; you ca...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e18 + 7; const long long N = 2e6 + 5; int main() { long long i, j, k, l = 0; long long n, m, t; cin >> n; for (long long i = 0; i < n; i++) cin >> k, l += k; if (l % n) cout << n - 1 << endl; else cout << n ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/*! btcminer -- BTCMiner for ZTEX USB-FPGA Modules: HDL code: hash pipelines Copyright (C) 2011 ZTEX GmbH http://www.ztex.de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation...
#include <bits/stdc++.h> using namespace std; bool X[1000001], vis[1000001]; int main() { int n; while (scanf( %d , &n) == 1) { vector<int> V; int x; for (int i = 0; i < n; i++) { scanf( %d , &x); X[x] = true; V.push_back(x); } deque<int> Q; for ...
/* * 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 maxn = 100000; bool isprime[maxn]; int p[5], s[5], n; const int tenpow[6] = {1, 10, 100, 1000, 10000, 100000}; int tenpowmul[6][10]; int getd[maxn][5]; int ans; bool good[2 * maxn][6]; int tans[maxn]; void solve(int i) { if (i == 0) { ...
// *************************************************************************** // *************************************************************************** // 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; const int inf = int(1e9) + 1; const long double eps = 1e-9; map<string, int> jogos; map<string, int> pontos; map<string, int> gol; map<string, int> leva; set<string> times; vector<string> falta; int x1, x2; bool menor(string x, string y) { int g1 =...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_clk_cclk_scanlasr_2x.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistrib...
// (c) Copyright 1995-2017 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 ...
module autoinst_bits_lba_gi // ==xxxxxxx== // xxxxxxxxx 1997-1998, xxxxx xxx. // xxx xxxxxx xxxxxxxx // ****************************************************************** / // ****************************************************************** / // xxxxx, xxxxxxxxxxxx // xxxxxxx: xxx-4080 // xxxxxx: ...
#include <bits/stdc++.h> const long long mod = (long long)1e9 + 7; const int maxn = (int)4e5 + 2; long long inf = 1LL << 60; const double eps = 1e-9; using namespace std; template <class N> inline void read(N &n) { N x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (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 law...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 100010; int dp[550][550], A[550], B[550], path[550][550], n, m; bool print(int x) { if (!x) return false; if (print(path[n][x])) printf( %d , B[x]); else printf( %d , B[x]); return true; }...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { int x, y; cin >> x >> y; if ((x == 1 || x == 2 && 3 < y || x == 3 && x < y) && x != y) { cout << NO << endl; } else cout << YES << endl; } }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 10; const int MOD = 998244353; const int INF = 10; int fact[MAXN], invfact[MAXN]; int add(int a, int b) { int sum = a + b; return (sum >= MOD ? sum -= MOD : (sum < 0 ? sum += MOD : sum)); } int mul(int a, int b) { return 1LL * ...
#include <bits/stdc++.h> using namespace std; vector<bool> vis; vector<vector<long long>> adj; void dfs(long long node) { vis[node] = true; for (long long child : adj[node]) { if (vis[child]) continue; dfs(child); } } signed main() { ios::sync_with_stdio(false); cin.tie(0); ...
/* This file is a simple top level that will generate one of four types of Avalon-MM master. As a result all the ports must be declared and it will be up to the component .tcl file to stub unused signals. */ // altera message_off 10034 module custom_master ( clk, reset, // control inputs and outputs control_fix...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fll; const int N = 1e4 + 10; const int M = 3e6 + 10; const int maxn = 1e6 + 10; const int mod = 1000173169; const double eps = 1e-10; const double pi = acos(-1.0); struct Tree { int n...
// megafunction wizard: %RAM: 2-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: ram1.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...
// ulight_fifo_hps_0_hps_io.v // This file was auto-generated from altera_hps_io_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 17.1 593 `timescale 1 ps / 1 ps module ulight_fifo_hps_0_hps_io ( output wire [12:0] mem_a, // memory.mem_a output wire [2:0] m...
#include <bits/stdc++.h> using namespace std; void use_cio() { ios_base::sync_with_stdio(0); cin.tie(0); } template <typename... Args> void dbg(Args... args) { ((cout << args << ), ...); cout << endl; } int n; int ask(int r1, int c1, int r2, int c2) { string ans; dbg( ? , r1, ...
#include <bits/stdc++.h> using namespace std; template <class T> void gi(T &x) { int f; char c; for (f = 1, c = getchar(); c < 0 || c > 9 ; c = getchar()) if (c == - ) f = -1; for (x = 0; c <= 9 && c >= 0 ; c = getchar()) x = x * 10 + (c & 15); x *= f; } const int N = 4e5 + 10...
//`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:54:24 05/17/2016 // Design Name: // Module Name: Encryption // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAX = 1e5 + 55; const int INF = 1e9 + 77; const long long INFINF = 1e18 + 1e17; const double PI = acos(-1.0); long long power(long long x, long long y) { if (y == 0) return 1; long long s = power(x, y / 2); s *= s...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 10; int ans = 0, n; int a, b, c; void cbh(int uuu, int len) { if (len == n) return; if (uuu == 1) { if (a < b) ans += a, cbh(2, len + 1); else ans += b, cbh(3, len + 1); } else if (uuu == 2) { i...
#include <bits/stdc++.h> using namespace std; const int MAXN = 70, MAXM = 100, MOD = 1e9 + 7, INF = 1e9; char c[] = { c , o , d , e , f , o , r , c , e , s }; void solve() { long long n; cin >> n; long long x = 0, x1 = 0; while (pow(x + 1, 10) <= n) x++; while (pow(x, 10 - x1) * pow...
#include <bits/stdc++.h> using namespace std; char s[1005]; int main() { int n, f = 1; char *p, *q; scanf( %s , s); n = strlen(s); p = s; q = s + n - 1; while (p <= q) { if (*p == *q) { p++; q--; } else { f = 0; break; } } print...
#include <bits/stdc++.h> using namespace std; template <class T> inline T BM(T p, T e, T M) { long long int ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; ...
#include <bits/stdc++.h> using namespace std; long double EPS = 1e-9; long long cel(long long a, long long b) { return ((a - 1) / b + 1); } long long gcd(long long a, long long b) { if (a < b) swap(a, b); return (b == 0) ? a : gcd(b, a % b); } long long MIN(long long a, int b) { long long ans; ...
/* Copyright (c) 2015-2017 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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 29.11.2016 16:55:54 // Design Name: // Module Name: frequency_analyzer_testbench // Project Name: // Target Devices: // Tool Versions: // Description: // // Depend...
#include <bits/stdc++.h> using namespace std; const unsigned int maxn = 35000, maxk = 50; class STree { public: void build(const unsigned int l, const unsigned int r, STree*(&cur), unsigned int dat[]) { lv = l; rv = r; mv = (l + r) >> 1; if (r - l == 1) return; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int n, i; int d = 0, c = 0; cin >> n; string s; cin >> s; for (i = n - 1; i >= 0; i--) { if (...
#include <bits/stdc++.h> int n, m; int a[2000]; int b[2000]; int can[2000]; using namespace std; int main() { int c = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j && !can[j] &&...
#include <bits/stdc++.h> using namespace std; long double mem[50 + 5][50 + 5][50 + 5]; long double fact[55]; vector<int> num; int n, p, L; long double dp(int sum, int idx, int cnt, int last) { if (sum > p || cnt > L) { return 0; } if (idx == n) { return (sum + num[last] > p && cnt + ...
//#include<bits/stdc++.h> #include <iostream> #include <vector> #include <deque> #include <queue> #include <map> #include <set> #include <list> #include <cmath> #include <cstring> #include <algorithm> using namespace std; #define fast ios_base::sync_with_stdio(0); cin.tie(0) #define file fr...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long inf = 1e18; const long long N = 2e2 + 5; long long n; long long a[N]; void solve(long long id) { cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i]; } long long odd = 0, even = 0; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: BMSTU // Engineer: Oleg Odintsov // // Create Date: 15:09:47 01/19/2012 // Design Name: // Module Name: ag_main // Project Name: Agat Hardware Project // Target Devices: // Tool ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cnt = 0; int val; int min = 1000; int evesum = 0, total = 0, oddsum = 0; for (int i = 0; i < n; i++) { cin >> val; if (val % 2 == 0) { evesum += val; } else { oddsum += val; ...
#include <bits/stdc++.h> using namespace std; bool checkPal(string s) { for (int i = 0, j = s.size() - 1; i <= j; i++, j--) { if (s[i] != s[j]) { return false; } } return true; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; ci...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; long long Pot(long long a, long long b) { if (b == 0) return 1; if (b % 2 == 0) { long long x = Pot(a, b / 2); return x * x % MOD; } else return Pot(a, b - 1) * a % MOD; } long long Inv(long long x) {...
#include <bits/stdc++.h> struct info { int p, c; }; bool vis[5010]; int check[10010], level = 1, I[5010], pair[10010], result[5010]; info input[5010]; std::vector<int> graph[10010]; bool dfs(int index) { check[index] = level; for (int i = 0; i < graph[index].size(); i++) { int next = gra...
`timescale 1 ns / 1 ps `include "BoardInit_AXI_v1_0_tb_include.vh" // lite_response Type Defines `define RESPONSE_OKAY 2'b00 `define RESPONSE_EXOKAY 2'b01 `define RESP_BUS_WIDTH 2 `define BURST_TYPE_INCR 2'b01 `define BURST_TYPE_WRAP 2'b10 // AMBA AXI4 Lite Range Constants `define S00_AXI_MAX_BURST_LENGTH 1 `defi...
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { long long int res = 1; a %= 1000000007; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % 1000000007; a = a * a % 1000000007; } return res; } long long int modI...
module dvi_top( input SYSCLK, input PANO_BUTTON, inout V_SPD, output V_SPC, output [11:0] V1_D, output V1_XCLK_P, output V1_XCLK_N, output reg V1_HSYNC, output reg V1_VSYNC, output reg V1_DE, output V1_RESET_N ); // Video timing parameters parameter X_RESOLUTION = 640; parameter X_FRONT_PORCH = 16; ...
#include <bits/stdc++.h> using namespace std; int n, x[105], mem[101][201][51][3], ans; string s; int solve(int idx, int pos, int rem, int dir) { int &ret = mem[idx][100 + pos][rem][dir + 1]; if (rem == 0) { int cur_dir = dir, sum = 0; for (int i = idx; i < s.size(); i++) if (x[i]) ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, g, t; cin >> n >> k; char a[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { if (a[i] == G ) g = i; if (a[i] == T ) t = i; } for (int i = 0; i < n; i++) { if (g < t) { ...
#include <bits/stdc++.h> using namespace std; void solve() { long long int h, m; cin >> h >> m; long long int t = h * 60 + m; long long int a = 1440 - t; cout << a << endl; } int32_t main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); long long int t = 1; ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3F3F3F3F; const int MAXN = 100001; char str[MAXN]; inline void solve(int test) { int t, sx, sy, ex, ey; scanf( %d %d %d %d %d , &t, &sx, &sy, &ex, &ey); scanf( %s , str); ; int X, Y; X = ex - sx, Y = ey - sy; pair<char...
#include <bits/stdc++.h> using namespace std; long long modpow(long long a, long long b, long long mod = (long long)(1e9 + 7)) { if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod; } mt19937 rng(chrono::steady_clock::now().time_since_epoch()...
#include <bits/stdc++.h> using namespace std; int n, m, tp; int a[2000002]; int main() { scanf( %d , &tp); int p = 1, i, j; for (i = 0; i <= 100; i++) { n++; if (p == tp) break; p *= 4; } for (i = 0; i < tp; i++) scanf( %d , &a[i]); sort(a, a + tp); long long ans = ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10, inf = 1e9 + 10, P = 53, MOD = 1e9 + 7; vector<int> a, b; int main() { ios_base::sync_with_stdio(false); long long n, x, t = 0; long long ans = 1; cin >> n >> x; for (int i = 0; i < 42; i++) if ((1ll << i) & x) { ...
/** * 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; int t = 1; if (m == 10) { if (n == 1) { cout << -1 ; return 0; } else { cout << 1 ; for (int i = 1; i < n; i++) { cout << 0 ; } } } else { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005, inf = 1e9 + 7; int fa[maxn]; long long n, m, dp[maxn]; int sz[maxn], costs[maxn]; vector<int> fas; bool vis[maxn]; int findfa(int x) { if (fa[x] == x) return x; else return fa[x] = findfa(fa[x]); } void bag(in...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll my_exp(ll a, ll b) { if (b == 0) { return 1; } else { ll temp = my_exp(a, b / 2); temp *= temp; if (b % 2 == 1) { temp *= a; } return te...
#include <bits/stdc++.h> using namespace std; string a, b, c, s; map<string, long long> m[3]; long long f, q; bool sach(string aa) { if (s.size() >= aa.size() && s.substr(s.size() - aa.size(), aa.size()) == aa) return true; return false; } void solve(long long i) { if (sach(a)) { i...
// the clock is manually controlled to set the inputs correctly module jfsmMealyWithOverlapTb; wire dataout; reg clock, reset, datain; jfsmMealyWithOverlap jfsmM(dataout, clock, reset, datain); initial begin reset = 1; datain = 0; clock = 1; #5; clock = 0; #5; reset = 0; clock = 1; #5; clock ...
#include <bits/stdc++.h> using namespace std; int n; int f[55][55][55][55]; string s[100]; bool dfs(int n, int a, int b, int c) { if (n == 1) return 1; if (f[n][a][b][c]) return 0; if (s[c][0] == s[b][0] || s[c][1] == s[b][1]) if (dfs(n - 1, n - 3, a, c)) return 1; if (n > 3 && (s[c][0] ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016 // Date : Tue Oct 31 15:07:48 2017 // Host : vldmr-PC running 64-bit Service Pack 1 ...
#include <bits/stdc++.h> using namespace std; class data { public: long long k, b; bool operator<(const data a) const { if (k * a.k < 0) return (b * a.k < a.b * k); else return (b * a.k > a.b * k); } bool operator==(const data a) const { return b * a.k == a.b * k; } ...
module GPU( input clk, input [15:0] cpuline, input clr, output outvga, output hsync, output vsync ); wire [7:0] out; wire [9:0] pix_x; //pixel vertical location wire [9:0] pix_y; reg [15:0] cmd = 0; reg [15:0] param = 0; reg [7:0] ram [11:0]; reg [11:0] pointer = 0; reg [11:0] tmpx = 0; reg [11:0] tmpy = 0; reg nop...
#include <bits/stdc++.h> using namespace std; int dirx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int diry[8] = {0, 1, 0, -1, 1, 1, -1, -1}; string str1, str2; int main() { int n, m; cin >> n >> m; cin >> str1 >> str2; if (str1[0] == > && str2[0] == v || str1[0] == < && str2[0] == ^ ) cout...
#include <bits/stdc++.h> #define MULTI_TEST false #define int long long #define double long double //#pragma GCC optimize( Ofast ) //#pragma GCC optimize( no-stack-protector ) //#pragma GCC optimize( unroll-loops ) //#pragma GCC target( sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native ) #define a...