text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; long long gcd(long long n1, long long n2) { if (!n1) return n2; if (!n2) return n1; if (n1 % n2 == 0) return n2; return gcd(n2, n1 % n2); } long long powmod(long long base, long long exponent) { base %= 1000000007; long long ans = 1; whil...
#include <bits/stdc++.h> using namespace std; long long r = 1000000007; int h[10]; int n, k, m, i, j; long long a[100001], b[100001]; long long ans, x, y, z, c1, c2; int main() { cin >> n >> k; for (i = 1; i <= n / k; i++) cin >> a[i]; for (i = 1; i <= n / k; i++) cin >> b[i]; h[0] = 1; ...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.4 (lin64) Build Wed Nov 18 09:44:32 MST 2015 // Date : Sat Jun 4 16:53:15 2016 // Host : Dries007-Arch running 64-bit unknown // Com...
//i2s_mem_controllerv /* Distributed under the MIT license. Copyright (c) 2011 Dave McCoy () 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 r...
/* Copyright (c) 2019 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, distribute,...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1E-15; const int inf = int(1e9) + 7; const int maxN = 1000 + 5; int in[maxN], to[maxN], cs[maxN]; int n, m; int main() { scanf( %d%d , &n, &m); int a, b, c; for (int(i) = 0; (i) < (m); ++(i)) { ...
// A simple circuit that can be used to detect brownouts and other hardware issues module top ( input clk, output LED1, output LED2, output LED3, output LED4, output LED5 ); reg [7:0] reset_counter = 0; reg resetn = 0; always @(posedge clk) begin reset_counter <= reset_counter + 1; resetn <= resetn | &re...
#include <bits/stdc++.h> using namespace std; inline long long mod(long long n, long long m) { long long ret = n % m; if (ret < 0) ret += m; return ret; } long long gcd(long long a, long long b) { return (b == 0LL ? a : gcd(b, a % b)); } long long exp(long long a, long long b, long long m) {...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2005 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 // // Example module to create problem. // // generate a 64 bit value with bits // [HighMaskSel_Bot...
#include <bits/stdc++.h> using namespace std; int cnt = -1; struct node { bool op; string val; int op1, op2; int type; node() { op = 0; val = ; type = 0; } } m[5020]; map<string, int> ind; inline int cti(char i) { return (int)(i - 0 ); } vector<string> vct; b...
/* Copyright (c) 2014-2018 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri...
#include <bits/stdc++.h> using namespace std; int n, x, i; int reachable[1000000]; int need_to_convert[1000000]; int main(int argc, char **argv) { scanf( %d , &n); for (i = 0; i < n; ++i) { scanf( %d , &x); int trans_op_num = 0; while (x) { ++reachable[x]; need_to_con...
// (C) 2001-2015 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated doc...
//////////////////////////////////////////////////////////////////////////////// // Project Name: CoCo3FPGA Version 3.0 // File Name: ps2_keyboard.v // // CoCo3 in an FPGA // // Revision: 3.0 08/15/15 //////////////////////////////////////////////////////////////////////////////// // // CPU section copyrighted by John...
#include <bits/stdc++.h> using namespace std; const int N = 10; int mx = 0; vector<int> g[N]; int n; int col[N]; int cnt[N][N]; void gen(int v) { if (v == n) { for (int i = 0; i < n; i++) for (int u : g[i]) { int t = col[i]; int z = col[u]; cnt[min(t, z)][...
/* * 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...
module diffeq_paj_convert (Xinport, Yinport, Uinport, Aport, DXport, Xoutport, Youtport, Uoutport, CLK, reset); input[31:0] Xinport; input[31:0] Yinport; input[31:0] Uinport; input[31:0] Aport; input[31:0] DXport; input CLK; input reset; output[31:0] Xoutport; output[31:0] Y...
////////////////////////////////////////////////////////////////////// //// //// //// usbSlaveCyc2Wrap.v //// //// //// //// This file is part of the usbhos...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1010; bool z[MAXN] = {0}; void prework() { for (int i = 2; i <= 1000; i++) { if (z[i]) continue; for (int k = i + i; k <= 1000; k += i) z[k] = true; } } struct node { char c; int n; bool operator<(node b) const { ...
/** * 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 nums[200]; int arr[200][200]; int counter; int line; int main() { int n; cin >> n; line = 0; counter = 0; int sum = 0; int nums[200]; int arr[200][200]; memset(arr, 0, sizeof arr); memset(nums, 0, sizeof nums); while (...
#include <bits/stdc++.h> using namespace std; int n, m, x, l, r, i, s, a[10179]; int main() { cin >> n >> m; for (i = 1; i <= n; i++) cin >> a[i]; while (m--) { cin >> l >> r >> x; for (s = 0, i = l; i <= r; i++) if (a[i] < a[x]) s++; if (s + l == x) cout << Yes n ; ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; while (t--) { int n, i; cin >> n; int a[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int ans = min(a[n - 1] - a[1], a[n - 2] - a...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:00:21 05/08/2014 // Design Name: // Module Name: multi_cycle_Cpu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; vector<int> pl; vector<int> sum; int a; int otv = 0; cin >> n; int m = pow(2, n + 1) - 2; pl.push_back(0); for (int i = 1; i <= m; ++i) { cin >> a; pl.push_back(a); ...
#include <bits/stdc++.h> using namespace std; int a[105]; int main() { int n, l, i, j, cnt, area, ans; scanf( %d%d , &n, &l); for (i = 1; i <= n; i++) scanf( %d , &a[i]); ans = 0; for (i = l; i <= 100; i++) { cnt = 0; for (j = 1; j <= n; j++) cnt += a[j] / i; area = cnt * i; ...
////////////////////////////////////////////////////////////////////// //// //// //// or1200_fpu_div //// //// //// //// This file is part of the OpenR...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; vector<int> Pr = { 0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103,...
`default_nettype none module execute_load_data( input wire [3:0] iMASK, input wire [1:0] iSHIFT, input wire [31:0] iDATA, output wire [31:0] oDATA ); assign oDATA = func_load_fairing( iMASK, iSHIFT, iDATA ); function [31:0] func_load_fairing; input [3:0] func_mask; input [1:0] func_shift; i...
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 7; const long long INF = (long long)1e18; int n; int m; vector<pair<int, int>> g[N]; long long dist[N]; int par[N]; int t[N]; int root(int x) { if (t[x] == x) { return x; } else { return t[x] = root(t[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 law...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; long long int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int t = a[n - 1]; a[n - 1] = a[n - 2]; a[n - 2] = t; if (a[0...
#include <bits/stdc++.h> using namespace std; int main() { int n, ans1 = INT_MAX, ans = -198896785; cin >> n; int c = 0, d = 0; for (int i = 0; i < n; i++) { int a; cin >> a; if (a < 0) { c++; ans = max(a, ans); } if (a > 0) { d++; ans1 =...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c = 0, n, t, i, j, flag = 0, sum, f; string s, s1, s2; cin >> t; while (t--) { cin >> n; c = 0, sum = 0, flag = 0, f = 0; int ara[n], ara1[n]; for (i = 0; i < n; i++) { cin >> ara[i]; } f...
#include <bits/stdc++.h> using namespace std; const int N = 5009; struct edge { int to, nxt; } e[N * 2]; int hd[N], tot; void add(int u, int v) { e[++tot] = (edge){v, hd[u]}; hd[u] = tot; } int n, leaf, lcnt[N], l[N]; void dfs1(int u, int fa) { for (int i = hd[u], v; i; i = e[i].nxt) {...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); int runsum = 0; int pen = 0; int k = 0; while (runsum <= 350 && ((runsum + arr[k]) <= 710) && k < n) runsum +...
#include <bits/stdc++.h> using namespace std; vector<int> g[200005]; int par[19][200005]; int depth[200005]; int dp[200005]; char s[200005]; void dfs(int u, int p, int d, int val) { par[0][u] = p; depth[u] = d; dp[u] = val ^ (1 << (s[u] - a )); for (int i = 0; i < g[u].size(); i++) { ...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ // Behavioral model for the register file module RegFileWW (rd1data,rd2data,wrdata,rd1addr,rd2addr,wraddr, rd1en,rd2en,wren,wrbyteen,clk); // Definitions for the constants the advanced register file //...
module Control( input [5:0] opcode, input clk, output reg reg_dst, output reg jump, output reg branch, output reg ctrl_mem_read, output reg mem_to_reg, output reg ctrl_mem_write, output reg alu_src, output reg reg_write, output reg [1:0] alu_op ); // Control signals from...
/** * 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; using ll = long long; void solve() { ll a, b, p; string s; cin >> a >> b >> p >> s; ll n = s.length(); s[n - 1] = s[n - 2]; vector<ll> cost(n, 0); if (s[n - 1] == A ) cost[n - 1] = a; else cost[n - 1] = b; for (int i = ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; const long long INF = 1000000000; void solve() { long long n; string s; cin >> n; vector<long long> p(n); vector<long long> ans(n); for (int i = 0; i < n; i++) { long long x; cin >> x; p[--x]...
#include <bits/stdc++.h> using namespace std; const int n0 = 1 << 17; const long long inf = 1e18; int n, a[n0], q; long long d[n0], gaps; struct Node { int l = 0, r = 0; long long val[3]; Node() { val[0] = val[1] = val[2] = -inf; } void init(int pos) { l = r = pos; if (l < 2 || l...
#include <bits/stdc++.h> using namespace std; const int MAX = 500500, MOD = 1e9 + 7; long long Norm(long long x) { return ((x % MOD + MOD) % MOD); } int n; long long prefsumx[2 * MAX], prefsumy[2 * MAX]; long long prefpov[2 * MAX]; long long prefob[2 * MAX], prefprav[2 * MAX]; pair<int, int> tocke[2 * M...
`include "../include/tune.v" // Pentevo project (c) NedoPC 2010,2011,2012 // // top module for video output. // // // note: the only bandwidths currently in use are 1/8 and 1/4. module video_top( input wire clk, // 28 MHz clock // external video outputs output wire [ 1:0] vred, output wire [ 1:0] vgrn,...
#include <bits/stdc++.h> using namespace std; const double eps(1e-8); long long a[100]; long long f[100]; long long dp[100]; long long l, r; long long calc(long long i) { long long ret = 0; for (long long j = (1); j <= (i - 1); ++j) { if (i % j == 0) ret += f[j]; } return ret; } ...
#include <bits/stdc++.h> using namespace std; int ans = 123422412; int n, a, b, x, y; void dfs(int r, int x, int y, int ret) { if (x < 0 || y < 0) return; if (r < 0) return; if (x == 0 && y == 0) { ans = min(ans, ret); return; } dfs(r - a, x - 1, y, ret); dfs(n - a, x - 1, y,...
//------------------------------------------------------------------------------------------- // // COPYRIGHT (C) 2011, VIPcore Group, Fudan University // // THIS FILE MAY NOT BE MODI...
#include <bits/stdc++.h> using namespace std; long long a[9], aa[9]; int c[9], cc[9]; int n; int ans; void dfs(int u, int cnt, int self) { if (u == n) { ans = min(ans, cnt + (self > 1)); return; } dfs(u + 1, cnt + cc[u] + (c[u] != 1), self + 1); for (int i = u + 1; i < n; i++) ...
module user_design(clk, rst, exception, input_timer, input_rs232_rx, input_ps2, input_i2c, input_switches, input_eth_rx, input_buttons, input_timer_stb, input_rs232_rx_stb, input_ps2_stb, input_i2c_stb, input_switches_stb, input_eth_rx_stb, input_buttons_stb, input_timer_ack, input_rs232_rx_ack, input_ps2_ack, input_i2...
module ok2wbm( // Wishbone master interface input wire wb_clk_i, input wire wb_rst_i, input wire wb_ack_i, input wire wb_int_i, output reg wb_cyc_o, output reg wb_stb_o, output reg wb_we_o, input wire [15:0] wb_data_i, output reg [15:0] wb_data_o, output wire [4:0] wb_addr_o, ...
// // 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...
#include <bits/stdc++.h> using namespace std; inline int nxt() { int x; scanf( %d , &x); return x; } const int N = 55; int a[N][N]; char skdjflfsdj[N][N]; int score[N]; void add(int u, int v, int x) { a[u][v] += x; score[u] += x; } vector<int> all_out(int v, int n) { vector<c...
`include "assert.vh" `include "cpu.vh" module cpu_tb(); reg clk = 0; // // ROM // localparam MEM_ADDR = 4; localparam MEM_EXTRA = 4; reg [ MEM_ADDR :0] mem_addr; reg [ MEM_EXTRA-1:0] mem_extra; reg [ MEM_ADDR :0] rom_lower_bound = 0; reg [ MEM_ADDR :0] rom_upper_bo...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2013 Altera Corporation, San Jose, California, USA. * ...
/** * 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 "../source/alu.v" module testALU; task assert; input cond; begin if (!cond) begin $display("Error!"); $finish; end end; endtask reg[15:0] a; reg[15:0] b; reg[3:0] func; reg ci; wire[3:0] flags; wire[15:0] y; wire[15:0] toA; alu alu1 ( .a (a), .b (b), .func (func), ....
#include <bits/stdc++.h> using namespace std; string s, ans; bool flag = 0; int main() { cin >> s; for (int i = 0; i < s.length(); ++i) { if (s[i] == / ) { if (!flag) { ans += s[i]; flag = 1; } } else { ans += s[i]; flag = 0; } }...
#include <bits/stdc++.h> using namespace std; signed main() { long long t; cin >> t; while (t--) { long long n; cin >> n; char c; cin >> c; string str; cin >> str; long long ctr = 0; long long k = 0; for (long long i = 0; i < n; i++) { if (st...
#include <bits/stdc++.h> using namespace std; int arr[111]; int main() { int n; scanf( %d , &n); for (int i = (0); i < (n); ++i) scanf( %d , &arr[i]); sort(arr, arr + n); int t = 10; int ans = 0; int qts = 0; for (int i = (0); i < (n); ++i) { t += arr[i]; if (t > 720) b...
#include <bits/stdc++.h> using namespace std; int main() { vector<string> strs; int n = 0; int j = 0; int count = 0; cin >> n; for (int i = 0; i < n; i++) { if (i != 0) { string temp = ; cin >> temp; } string str1 = ; string str2 = ; string...
module \$__NX_PDP16K (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN); parameter CFG_ABITS = 9; parameter CFG_DBITS = 36; parameter CFG_ENABLE_A = 4; parameter CLKPOL2 = 1; parameter CLKPOL3 = 1; parameter [18431:0] INIT = 18432'b0; parameter _TECHMAP_BITS_CONNMAP_ = 8; parameter [_TECHMAP_BITS_CONNMA...
#include <bits/stdc++.h> long long cacu(long long l, long long r) { return (r + l) / 2 * ((r - l) / 2 + 1); } int main() { int q, l, r; scanf( %d , &q); while (q--) { long long ans; scanf( %d%d , &l, &r); ans = cacu(l + (l & 1), r - (r & 1)); ans -= cacu(l | 1, r - !(r & 1)...
/* Copyright (c) 2015 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, distribute,...
/* * 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 Board232 ( input mclk, input [3:0] btn, input [7:0] sw, output [7:0] led, output reg [6:0] seg, output reg [3:0] an, output dp, output [2:1] OutBlue, output [2:0] OutGreen, output [2:0] OutRed, output HS, output VS ); assign dp = 1'b1; //assign led[7:2]=0; initial be...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; while (cin >> n) { string s; cin >> s; long long a0 = 0, a1 = 0, a2 = 0; for (long long i = 0; i < s.size(); i++) { if (s[i] == 0 ) { ...
#include <bits/stdc++.h> template <typename T> inline void rd(T& x) { int si = 1; char c = getchar(); x = 0; while (!isdigit(c)) si = c == - ? -1 : si, c = getchar(); while (isdigit(c)) x = x * 10 + c - 48, c = getchar(); x *= si; } template <typename T, typename... Args> inline void...
// megafunction wizard: %LPM_MUX%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: LPM_MUX // ============================================================ // File Name: counterselect.v // Megafunction Name(s): // LPM_MUX // // Simulation Library Files(s): // lpm // ======================================...
#include <bits/stdc++.h> using namespace std; int solve(int t) { int a, b, c, rem = 0, sum = 0; while (t != 0) { rem = t % 10; sum += rem; t /= 10; } if (sum % 4 == 0) return 1; return 0; } int main() { int t, n, flag = 0; cin >> t; while (1) { flag = solv...
/* +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Module | Partition | Slices* | Slice Reg | LUTs | LUTRAM | BRAM/FIFO | DSP48A1 | BUFG | BU...
#include <bits/stdc++.h> using namespace std; const bool debug = false; const int inf = 1000 * 1000 * 1000; const int MAKSN = 1000 + 13; const long long MOD = 123456789LL; int n, m, k, l, x, y, a, b, p; string s; vector<int> v; void readIn() { cin >> n >> m >> p; x = 0; for (int i = 0; i <...
//------------------------------------------------------------------------------ // (c) Copyright 2013-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 propert...
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int N = 2e5 + 5; vector<pair<long long, long long> > v; long long n, m, k; void solve() { sort(v.rbegin(), v.rend()); long long sum = 0; vector<long ...
#include <bits/stdc++.h> using namespace std; struct matrix { long long a[100][100]; void init() { memset(a, 0, sizeof(a)); } friend matrix operator*(matrix x, matrix y) { matrix ans; ans.init(); for (int i = 0; i < 100; i++) for (int j = 0; j < 100; j++) { for (int k...
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018 // Date : Mon Sep 16 06:23:47 2019 // Host : varun-laptop running 64-bit Service Pac...
#include <bits/stdc++.h> using namespace std; const int N = 110; bool ls(string s1, string s2) { for (int i = 0; i < s1.size(); i++) if (s1[i] < s2[i]) return 1; else if (s1[i] > s2[i]) return 0; return 0; } int main() { string s, t, tmp; cin >> s; int pos = s.f...
#include <bits/stdc++.h> using namespace std; double p[210]; int a[210]; double dp[210][210][210]; int main(void) { int N, L, K, i, j, k; cin >> N >> L >> K; for ((i) = 0; (i) < (int)(N); (i)++) cin >> p[i]; for ((i) = 0; (i) < (int)(N); (i)++) cin >> a[i]; for ((i) = 0; (i) < (int)(N); (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; long long grundy[1234]; int main() { long long idx = 1, i, j; for (i = 1; i <= 15; i++) { for (j = 1; j <= (i + 1); j++) { grundy[idx] = i; idx++; } } long long n; cin >> n; long long ans = 0; while (n--) { ...
// (C) 1992-2014 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 simulati...
// (C) 1992-2014 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 simulati...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 200010, LOG = 20; int n, m, k, u, v, x, y, t, a, b; long long A[MAXN]; int par...
#include <bits/stdc++.h> using namespace std; pair<int, int> a[10], b[10]; vector<int> p; bool square(int i, int j) { double len = sqrt((a[j].first - a[i].first) * (a[j].first - a[i].first) + (a[j].second - a[i].second) * (a[j].second - a[i].second)); for (int t = i + 1; t <= j; t+...
#include <bits/stdc++.h> int d, n, m; int deq[200100]; int qs, qe; struct stt { int x, p; bool operator<(const stt& r) const { return x < r.x; } }; stt a[200100]; int main() { int i, j; long long int ans; scanf( %d%d%d , &d, &n, &m); for (i = 0; i < m; i++) { scanf( %d%d , &a...
/** * 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 check(int x, int n, vector<int>& a) { vector<int> temp; int i = 0, j = x; int cnt = 0; bool ok = false; while (cnt < n) { if (ok) temp.push_back(a[i]), i++, ok = false; else temp.push_back(a[j]), j++, ok = true; ...
#include <bits/stdc++.h> int allocator_pos = 0; char allocator_memory[(int)1e5]; inline void *operator new(size_t n) { char *res = allocator_memory + allocator_pos; allocator_pos += n; assert(allocator_pos <= (int)1e5); return (void *)res; } inline void operator delete(void *) noexcept {} te...
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; const int maxn = 1e5 + 10, lg = 18; int n, m, q, cid[maxn], csize = 0, H[maxn], low[maxn], ok[maxn], par[maxn][lg], comp[maxn], c1; bool dp[maxn][lg]; vector<int> G[maxn]; bool mark[maxn]; void dfs1(int a,...
module heap_simulation; // Inputs reg mclk = 0; reg core_stall = 0; reg [31:0] memory_dout = 31'b0; reg [7:0] switch = 7'b0; reg [3:0] button = 4'b0; // Outputs wire memory_read; wire memory_write; wire [31:0] memory_address; wire [31:0] memory_din; wire [7:0] seg; wire [3:0] digit; wire hsync; wire vs...
/* * 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; int cnt[100005]; int cmax[10]; memset(cnt, 0, sizeof(cnt)); memset(cmax, 0, sizeof(cmax)); for (int i = 1; i <= n; i++) { int a; cin >> a; cnt[a]++; if (cnt[a] < 10) cmax[cnt[a]]++; } ...
`timescale 1 ps / 1 ps module myproj_top( inout [14:0]DDR_addr, inout [2:0]DDR_ba, inout DDR_cas_n, inout DDR_ck_n, inout DDR_ck_p, inout DDR_cke, inout DDR_cs_n, inout [3:0]DDR_dm, inout [31:0]DDR_dq, inout [3:0]DDR_dqs_n, inout [3:0]DDR_dqs_p, inout DDR_odt, inout DDR_ras_n, ...
/* * Milkymist VJ SoC * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq * * 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, version 3 of the License. * * This program is distri...
#include <bits/stdc++.h> using namespace std; bool query = 0; struct line { long long m, b; mutable function<const line*()> succ; bool operator<(const line rhs) const { if (!query) return (m < rhs.m); const line* s = succ(); return s ? (b - s->b) < (rhs.m * (s->m - m)) : 0; } }...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 3; int n; int main() { cin >> n; cout << (int)log2(n) + 1; }
#include <bits/stdc++.h> using namespace std; int n, m; char name[2000], part[2000000]; int work() { int p = 0; for (int i = 0; i < m; i++) { if (part[i] == name[p]) p++; if (p == n) return i; } return m; } int main() { scanf( %s , name); scanf( %s , part); n = strlen...
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 10; char scn[N][2]; int l, x, mem; string s; int main() { l = 1; x = 25; cin >> s; for (int i = 1; i <= 10000; i++) { scn[i][1] = . ; } mem = 0; l = 1; for (int i = 0; i < s.size(); i++) { while (m...
module x; always @(posedge piclk) begin if (k_i_reset) begin /*AUTORESET*/ // Beginning of autoreset for uninitialized flops idat_ICErrData_i3 <= 1'h0; // End of automatics end else begin idat_ICErrData_i3 <= idat_way0_i2[1*OPCWID-1:0*OPCWID]; end ...