text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { int cen, feet = 0, inch; cin >> cen; inch = cen / 3; if (cen % 3 == 2) inch++; if (inch >= 12) { feet = inch / 12; inch = inch % 12; } cout << feet << << inch << endl; return 0; }
module display( input fclk, input rst_n, input vgaclk, input [31:0] vga_cmd, input vga_cmd_valid, output vga_cmd_ready, output reg VGA_VS_n, output reg VGA_HS_n, output reg [7:0] VGA_red, output reg [7:0] VGA_green, output reg [7:0] VGA_blue, output reg pvalid, ...
#include <bits/stdc++.h> using namespace std; const int oo = 1000000009; const double eps = 1e-9; const int mod = 1000000007; int nos[100001], n, pos = 0; int main() { cin >> n; for (int i = 0; i < n; ++i) scanf( %d , &nos[i]); sort(nos, nos + n); for (int i = 0; i < n; ++i) if (pos + ...
#include <bits/stdc++.h> using namespace std; template <typename T, typename S> ostream &operator<<(ostream &os, const pair<T, S> &p) { return os << ( << p.first << , << p.second << ) ; } template <typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_sam...
///////////////////////////////////////////////////////////// // Created by: Synopsys DC Ultra(TM) in wire load mode // Version : L-2016.03-SP3 // Date : Sun Nov 20 02:48:51 2016 ///////////////////////////////////////////////////////////// module ACA_II_N16_Q8_DW01_add_J42_0 ( A, B, CI, SUM, CO ); input [8:...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000010; char s[maxn]; int tp[maxn >> 3], sz[maxn >> 3], n, cnt; long long ans; int main() { scanf( %d , &n); int l; for (int i = 1; i <= n; i++) { scanf( %s , s + 1); l = strlen(s + 1); for (int k = 1; k <= l; k++)...
#include <bits/stdc++.h> using namespace std; inline int read() { char c = getchar(); int x = 0, f = 1; for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return x * f; } const int MAXN = 3e2 + 5; const int MAXQ = 2e6 + 5;...
#include <bits/stdc++.h> int n, ans, a[15][15]; inline void maxx(int& a, int b) { a = (a > b ? a : b); } inline void minx(int& a, int b) { a = (a < b ? a : b); } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf( %d , &a[i][j]); for (int k = 1; k <= ...
#include <bits/stdc++.h> using namespace std; int main() { int meow, k = 0; string s[4]; for (int i = 0; i < 4; i++) cin >> s[i]; for (int i = 0; i < 4; i++) { int n1 = 0, n2 = 0; for (int j = 0; j < 4; j++) { if (j == i) continue; n1 += (((s[i].size() - 2) * 2) <= (s[j]....
#include <bits/stdc++.h> using namespace std; const int N = 600000; const int MOD = (int)1e9 + 7; int n, m, k, u, v, g[N]; long long c[N], w[N]; set<long long> s; vector<pair<long long, pair<int, int> > > e; int find(int cur) { return cur == g[cur] ? g[cur] : g[cur] = find(g[cur]); } int main() { ...
#include <bits/stdc++.h> using namespace std; unsigned long long int power(unsigned long long int a, unsigned long long int b, unsigned long long int p) { unsigned long long int res = 1; a = a % p; while (b > 0) { if (b & 1) { res = (res * a) % p; 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; int a[200010], n, S, T; vector<int> A; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , a + i), S += a[i]; for (int i = 0; i < n; i++) if (S - a[i] == (long long)a[i] * (n - 1)) A.push_back(i + 1); printf( %d n , (int)A.siz...
module fibfast (clk, n, start, fibn, done); parameter w = 32; input [w-1:0] n; input clk, start; output [w-1:0] fibn; output done; parameter s0 = 3'b000; parameter s1 = 3'b001; parameter s2 = 3'b010; parameter s3 = 3'b011; parameter s4 = 3'b100; reg [2:0] state, nextstate...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int T = 1; while (T--) { long long int n, i, j; cin >> n; long long int a[n + 5]; long long int b[n + 5]; unordered_map<long long int, long long in...
//------------------------------------------------------------------- // // COPYRIGHT (C) 2014, VIPcore Group, Fudan University // // THIS FILE MAY NOT BE MODIFIED OR REDISTRIBUTED WITHOUT THE // EXPRESSED WRITTEN CONSENT OF VIPcore Group // // VIPcore : http://soc.fudan.edu.cn/vip // IP Owner : Yibo FA...
/* * 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) 2007 by Terasic Technologies Inc. // -------------------------------------------------------------------- // // Permission: // // Terasic grants permission to use and modify this code for use // in synthesis for all Terasic De...
(* techmap_celltype = "$reduce_or" *) module my_opt_reduce_or(...); parameter A_SIGNED = 0; parameter A_WIDTH = 1; parameter Y_WIDTH = 1; input [A_WIDTH-1:0] A; output reg [Y_WIDTH-1:0] Y; parameter _TECHMAP_CONSTMSK_A_ = 0; parameter _TECHMAP_CONSTVAL_A_ = 0; wire _TECHMAP_FAIL_ = co...
module LED_top_module( input reset_n, output Len, output Ldir, output Ren, output Rdir ); wire clk; //used for the oscillator's 2.08 MHz clock wire clk_2; //used for slowed down, 5 Hz clock //This is an instance of a special, built in module that accesses our chip's oscillator OSCH #("2.08"...
#include <bits/stdc++.h> using namespace std; long long g, t; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } int main() { int n; long long Max = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> t; if (i) g = gcd(g, t); else g = t...
// megafunction wizard: %FIFO%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: fifo_2k.v // Megafunction Name(s): // dcfifo // ============================================================ // ******************************...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<int> v(7, 0); for (int i = 0; i < s.size(); i++) { if (s[i] == B ) v[0]++; else if (s[i] == u ) v[1]++; else if (s[i] == l ) v[2]++; else if (s[i] == b ) ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 4; int n, ans, ar[maxn], flag[maxn], dp[maxn]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> ar[i]; } for (int i = 0; i < maxn; i++) dp[i] = 1; for (int i...
#include <bits/stdc++.h> int main() { long long a, m, c, i; scanf( %I64d %I64d , &a, &m); for (i = 0; i <= 700; i++) { c = a % m; if (c == 0) break; a = a + c; } if (c == 0) { printf( Yes ); } else printf( No ); return 0; }
#include <bits/stdc++.h> using namespace std; void make(vector<pair<int, int> > &a, long long int b) { int last = 0; int n = a.size(); for (int i = 0; i < a.size() - 1; i++) { if (b >= pow(2, n - 2 - i)) { a[i].first = n - last; last++; b = b - pow(2, n - 2 - i); } el...
/** * 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...
// megafunction wizard: %RAM: 2-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: RAM512x16_2RW.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ======================...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 13:40:25 11/02/2014 // Design Name: // Module Name: InputMux // Project Name: // Target Devices: // Tool versions: // Description: // // Depend...
#include <bits/stdc++.h> const size_t Size = 1e5 + 5; const size_t SqrtS = 775 + 5; int f[Size]; int sum[Size]; int cost[Size]; std::vector<int> d[Size]; int n, k; int main(void) { std::scanf( %d%d , &n, &k); for (int i = 1, x, y; i <= k; ++i) { std::scanf( %d%d , &x, &y); d[y].push_...
////////////////////////////////////////////////////////////////////// //// //// //// Generic Single-Port Synchronous RAM //// //// //// //// This file is part of memory li...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; long long tree[400005]; int n; long long r[100005], h[100005], v[100005]; pair<long long, int> p[100005]; int mp[100005]; void update(int nd, int bb, int ee, int ii, long long vv) { if (bb == ee && bb == ii) { tree[nd] = vv; return; } i...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool fs(T &x) { int c = getchar(); int sgn = 1; while (~c && c < 0 || c > 9 ) { if (c == - ) sgn = -1; c = getchar(); } for (x = 0; ~c && 0 <= c && c <= 9 ; c = getchar()) x = x * 10 + c - 0 ; x *= ...
#include <bits/stdc++.h> using namespace std; long long binpow(long long a, long long b, long long mod) { long long res = 1; while (b != 0) { if (1 & b) res = (res * a) % mod; b >>= 1; a = (a * a) % mod; } return res; } long long mminvprime(long long a, long long b) { return bi...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 04:04:00 04/01/2012 // Design Name: // Module Name: sigma_delta_dac // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies...
/* * 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...
`timescale 1ns / 1ps // @module // display time on segment // @input // clk_src: clock source // sec_data: raw seconds info // min_data: raw minutes info // hour_data: raw hours info // @output // anodes: bind to board for displaying time // cnodes: bind to board for displaying time module time_displayer #(parameter W...
/* ------------------------------------------------------------------------------- This file is part of the hardware description for the Propeller 1 Design for Pipistrello LX45. The Propeller 1 Design is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as publi...
//deps: core.v `timescale 1ns/1ps module core_tb; /*AUTOREGINPUT*/ // Beginning of automatic reg inputs (for undeclared instantiated-module inputs) reg clk; // To core of core.v reg [31:0] dram_data_in; // To core of core.v reg dram_data_...
/* * Copyright (C) 2007 Onno Kortmann <> * * 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 the License, or * (at your option) any later version. * * This program ...
`timescale 1ns / 1ps // The main gpu module for the ceespu system on chip, intended to work with hdmi controller module ceespu_gpu( input I_pix_clk, input I_sys_clk, input [3:0] I_sys_write_enable, input [24:0] I_sys_address, input [31:0] I_sys_data, input [9:0] x,...
// system_mm_interconnect_0_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 15.0 145 `timescale 1 ps / 1 ps module system_mm_interconnect_0_avalon_st_adapter #( parameter inBitsPerSym...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18 + 10, mod = 2147493647; string a[5]; char str[5][100010]; map<string, int> ans; int main() { for (int i = 0; i < 3; i++) scanf( %s , &str[i]); for (int i = 0; i < 3; i++) { int len = strlen(str[i]); for (int j = 0; ...
/*+-------------------------------------------------------------------------- Copyright (c) 2015, Microsoft Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code ...
#include <bits/stdc++.h> using namespace std; bool notprime[1000010]; int sumprime[1000010]; void fun() { for (int i = 2; i <= 1000000; i++) { if (notprime[i] == 0) { for (int j = i * 2; j <= 1000000; j += i) { notprime[j] = 1; } } } } void sum() { sumprime[...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; inline int read() { char c = getchar(); int x = 0, f = 1; while ((c < 0 || c > 9 ) && c - - ) c = getchar(); if (c == - ) f = -1, c = getchar(); while (c >= 0 && c <= 9 ) { x = (x << 3) + (x << 1) + c - 4...
//############################################################################# //# Function: Low power clock gate circuit # //############################################################################# //# Author: Andreas Olofsson # ...
// Polyphase filter bank for upsampling from 32000.0kHz to 48000.0kHz // Depth: 32 module rom_firbank_32_48( input wire clk, input wire [5:0] addr, output wire [23:0] data); reg [23:0] data_ff; assign data = data_ff; always @(posedge clk) begin case(addr) 0: data_ff <= 24'hF55B94; // -697452 ...
///////////////////////////////////////////////////////////// // Created by: Synopsys DC Expert(TM) in wire load mode // Version : L-2016.03-SP3 // Date : Wed Oct 19 14:29:52 2016 ///////////////////////////////////////////////////////////// module Priority_Codec_32 ( Data_Dec_i, Data_Bin_o ); input [25:0] D...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m, l, a[100001], i, t = 0, p, d, k, w; cin >> n >> m >> l; for (i = 0; i < n; i++) cin >> a[i]; if (a[0] > l) t++; for (i = 1; i < n; i++) { if (a[i] >...
#include <bits/stdc++.h> using namespace std; int main() { int n, t, m; cin >> t; while (t--) { cin >> n; int i; int a[n], b[n]; for (i = 0; i < n; i++) { cin >> a[i]; } int f = 0; for (i = 0; i < n; i++) { cin >> b[i]; } int p = 0, v...
/* * 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() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } int mx = *max_element(v.begin(), v.end()); int mn = *min_element(v.begin(), v.end()); int...
/* * 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; cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i == j) cout << 0 << ; else if (min(i, j) == 0) cout << 2 * (i + j) % (n - 1) + 1 << ; else cout <...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of inst_be_i // // Generated // by: wig // on: Sat Mar 3 09:45:57 2007 // cmd: /cygdrive/c/Documents and Settings/wig/My Documents/work/MIX/mix_0.pl -nodelta ../../udc.xls // // !!! Do not edit this f...
#include <bits/stdc++.h> using namespace std; inline int setBit(int N, int pos) { return N = N | (1 << pos); } inline int resetBit(int N, int pos) { return N = N & ~(1 << pos); } inline bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); } int A[400000 + 10]; vector<int> nxt[400000 + 10]; int i...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; while (~scanf( %d %d %d , &a, &b, &c)) { int ans = a + b + c; ans = max(ans, a * b * c); ans = max((a + b) * c, ans); ans = max(a * (b + c), ans); printf( %d n , ans); } return 0; }
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.2 (win64) Build Thu Jun 2 16:32:40 MDT 2016 // Date : Wed Mar 15 19:17:33 2017 // Host : ul-43 running 64-bit Service Pack 1 (b...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll t; cin>>t; while(t--){ ll n,k; cin>>n>>k; ll ans; if(n%2==0) { if(k%n==0) ans=n; else ans=k%n; } else { ll x1=k%n; if(x1==0) x1=n; ll x2=(k/n); ...
#include <bits/stdc++.h> using namespace std; const int M = 210000; struct Node { long long si, fi, ti; } node[M]; int n, m; long long get_num(long long x, long long y, long long z, int dir) { long long sum = 0; if (dir == 1) { if (x <= y) { sum += y - x; if (y <= z) { ...
#include <bits/stdc++.h> using namespace std; int mabs(int a) { if (a < 0) return -a; else return a; } bool vis[4010]; int main() { int x, k; int t, n1, n2; cin >> x >> k; for (int i = 0; i < k; ++i) { cin >> t; if (t == 2) { cin >> n2; vis[n2] =...
#include <bits/stdc++.h> template <typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; } template <typename T> inline T ABS(const T &val) { return val < 0 ? -val : val; } template <typename T> inline T MAX(const T &a, const T &b) { return a > b ? a : b; } templa...
#include <bits/stdc++.h> using namespace std; const int N = 1005; template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + c - 0 ; x *= f; } ...
/* * 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 m, n; int main() { int n; string vic1, vic2, tmp1, tmp2; cin >> vic1 >> vic2; cin >> n; cout << vic1 << << vic2 << endl; for (int i = 0; i < n; ++i) { cin >> tmp1 >> tmp2; if (vic1 == tmp1) vic1 = tmp2; else ...
/* * Copyright 2018-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 to in...
#include <bits/stdc++.h> using namespace std; complex<double> r() { double a, b; cin >> a >> b; return {a, b}; } double cross(complex<double> a, complex<double> b) { return (conj(a) * b).imag(); } double orient(complex<double> a, complex<double> b, complex<double> c) { return cross(b - a...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int arr[n + 1]; int dp[n + 1][3]; for (int i = 1; i <= n; i++) cin >> arr[i]; dp[0][0...
#include <bits/stdc++.h> using namespace std; int main() { int n, t, k, d; cin >> n >> t >> k >> d; int curr = 0; while (curr <= d) { n -= k; curr += t; } if (n > 0) { cout << YES ; } else { cout << NO ; } }
#include <bits/stdc++.h> using namespace std; typedef struct x { int cor; int power; bool operator<(x T) const { return cor < T.cor; } } beacon; beacon arr[2000009]; vector<int> tmp; int dp[2000009]; int main() { int n, m, k; scanf( %d , &n); for (int i = 0; i < n; i++) { sca...
`include "../../../rtl/verilog/gfx/div_uu.v" `include "../../../rtl/verilog/gfx/gfx_interp.v" `include "../../../rtl/verilog/gfx/basic_fifo.v" module interp_bench(); parameter point_width = 16; parameter delay_width = 5; parameter result_width = 3; reg clk_i; // system clock reg ...
#include <bits/stdc++.h> using namespace std; int dx[3] = {-1, 1, 0}; int dy[3] = {1, 1, 1}; int d[5][205]; char mp[5][205]; int n, k, flag; void dfs(int x, int y) { d[x][y] = 1; if (flag) return; if (y >= n) { flag = 1; return; } if (mp[x][y + 1] != . ) return; if (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; const int MAX = 2e3 + 1; int dp[MAX][4], in[MAX]; int main() { ios::sync_with_stdio(0); int n, ans = 1; cin >> n; for (int i = 0; i < n; ++i) { cin >> in[i]; if (in[i] == 1) dp[i][0] = 1; else dp[i][1] = 1; 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 la...
#include <bits/stdc++.h> using namespace std; int n, flag; int a[100005], b[100005], t[100005]; int main() { cin >> n; for (int i = 1; i <= n - 1; i++) cin >> a[i]; for (int i = 1; i <= n - 1; i++) cin >> b[i]; memset(t, -1, sizeof(t)); for (int i = 0; i <= 3; i++) { t[1] = i; in...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; stack<char> st; for (int i = 0; i < s.length(); i++) { if (st.empty()) { st.push(s[i]); } else if (st.top() == s[i]) { st.pop(); } else { st.push(s[i]); } } if (st.e...
////////////////////////////////////////////////////////////////////////////////// // CRC_generator.v for Cosmos OpenSSD // Copyright (c) 2015 Hanyang University ENC Lab. // Contributed by Jinwoo Jeong <> // Ilyong Jung <> // Yong Ho Song <> // // This file is part of Cosmos OpenSSD. // //...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int MAXN = 100000; typedef struct P { int x, y; P() {} P(int x, int y) : x(x), y(y) {} } P; bool operator<(const P &a, const P &b) { if (a.x != b.x) return a.x <...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char grid[n][n]; int hash_count = 0, cross = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> grid[i][j]; if (grid[i][j] == # ) hash_count++; } } for (int i = 0; ...
#include <bits/stdc++.h> using namespace std; const long long linf = 1LL << 62; const int iinf = 1000000009; const double dinf = 1e17; const int Mod = 1e9 + 9; const int maxn = 1000005; int n; long long a, b[maxn]; long long dp[3][maxn]; void solve() { ios::sync_with_stdio(false); cin >> 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...
#include <bits/stdc++.h> using namespace std; const int max_n = 200002, inf = 1111111111; const int max_p = 500005; int n, q, a[max_n], z[max_p], cnt[max_p], used[max_n]; long long ans; int get_cnt(int x) { int res = 0; for (int i = 1; i * i <= x; ++i) { if (x % i == 0) { int d = i; ...
#include <bits/stdc++.h> using namespace std; int main() { vector<vector<string> > tab(9); int emp[3][3]; memset(emp, 0, sizeof emp); for (int i = 0; i < 9; i++) { tab[i].resize(3); for (int j = 0; j < 3; j++) { string a; cin >> a; for (int k = 0; k < a.size(); k+...
/** * 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; bool prime(int x) { int cnt = 0; for (int i = 1; i <= x; i++) if (x % i == 0) cnt++; return (cnt <= 2); } void fl() { fflush(stdout); } int kul[] = {4, 9, 25, 49}; char odg[5]; int main() { int prosti = 1; for (int i = 0; i < 4; i++) ...
module testcall(); reg clk; reg reset; reg [7:0] snoopa; reg [7:0] snoopd; reg snoopp; discus dcs(.clk(clk), .reset(reset), .snoop_clk(clk), .snoopa(snoopa), .snoopd(snoopd), .snoopq(), .snoopm(1'b0), ....
/* * 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; long n, l, x, y, a[1 << 20]; set<long> has; long hx, hy; long ans; long thx, thy; void check(long ps) { if (ps < 0 || ps > l) return; hx = thx; hy = thy; if (has.find(ps + x) != has.end()) hx = 1; if (has.find(ps + y) != has.end()) hy = 1; ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; int type0, type1; void dfs(int s, bool visited[], vector<int> adj[], int type[], int ctr) { if (visited[s]) retur...
////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2013, Andrew "bunnie" Huang // // See the NOTICE file distributed with this work for additional // information regarding copyright ownership. The copyright holder // licenses this file to you under the Apache License...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const long long mod = 1e9 + 7; const long long modd = 1; const long long N = 1e5 + 5; void solve() { long long n, m; cin >> n >> m; long long a[n + 1][m + 1]; for (long long i = 0; i < n; i++) for (long long j = ...
//---------------------------------------------------------------------------- // Wishbone Tube controller //---------------------------------------------------------------------------- module wb_tube #( parameter latency = 0 // 0 .. 7 ) ( input clk, in...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; while (a > 0 && b > 0) { if (a >= 2 * b) { a = a - (a / (2 * b)) * (2 * b); } else if (b >= 2 * a) { b = b - (b / (2 * a)) * (2 * a); } else { break; } } 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...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL); long long k = 0; cin >> k; if (k == 1) { cout << 4 ; return 0; } string s = ; unsigned long long a = 1000000000000000000; unsigned long long num = 0; long lo...