text
stringlengths
59
71.4k
// WARNING: Do NOT edit the input and output ports in this file in a text // editor if you plan to continue editing the block that represents it in // the Block Editor! File corruption is VERY likely to occur. // Copyright (C) 1991-2013 Altera Corporation // Your use of Altera Corporation's design tools, logic fu...
// Q: пограничные условия - входы выходы триггеров, // значения регисторов // ch2. module mult8( output [7:0] product, input [7:0] A, input [7:0] B, input clk ); reg [15:0] prod16; assign product = prod16[15:8]; always @(posedge clk) begin prod16 <= A * B; end endmodule module mult8_rollup( output reg [7...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; int m; cin >> n >> m >> k; set<long long> removal; for (int i = 0; i < m; i++) { long long x; cin >> x; removal.insert(x); } long long total = 0; long long offset = 0; set<long long>::ite...
#include <bits/stdc++.h> using namespace std; const int N = 1000005, md = 998244353; int n, i, j, k, e, p[N], lmt, len, rt[N], ome[N], rome[N], g[N], h[N], w1[N], w2[N], inv[N]; long long a[N], b[N], w, xxj[65]; inline void Read(long long &x) { char c; while ((c = getchar()) < 0 || c > 9 ) ...
// OPED.v - OpenCPI PCIe Endpoint with DMA // Copyright (c) 2010,2011 Atomic Rules LLC - ALL RIGHTS RESERVED // // This is the top-level port signature of the OPED sub-system // The signals are grouped functionally as indicated by their prefix // + The PCIE_ signals must connect directly to their IOBs with no intermed...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
`timescale 1ns/10ps `define CYCLE_PERIOD 4.0 module PATTERN( input [10:0] out, input out_valid, output reg [3:0] in, output reg [1:0] mode, output reg in_valid, output reg clk, output reg rst_n ); parameter CYCLE = `CYCLE_PERIOD; parameter PATTERN_NUM = 1000; reg [7:0] times[0:8]; reg [2:0] m...
#include <bits/stdc++.h> using namespace std; bool used[10000001]; int n, m, second = 0, ds[1000001], ans[1000001], str[1000001], sv[1000001]; struct o { int x, i, j; }; o d[1000001]; vector<vector<int> > a; bool comp(o a, o b) { if (a.x == b.x) return a.i < b.i; return a.x < b.x; } bool...
#include <bits/stdc++.h> using namespace std; long long power(long long b, long long e) { long long p = 1; while (e > 0) { if (e & 1) { p = (p * b) % 1000000007; } e = e >> 1; b = (b * b) % 1000000007; } return p; } vector<string> num; string s, s1; int main()...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(); cin.tie(); cout.tie(); int n; cin >> n; int weight[n]; for (int i = 0; i < n; ++i) cin >> weight[i]; int p; cin >> p; vector<pair<pair<int, int>, int> > data; for (int i = 0; i < p; ++...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> a(n); int prev = -1; bool invalid = false; for (int i = 0; i < n; i++) { cin >> a[i]; invalid = (prev > a[i]) || (a[i] > i + 1); prev = a[i]; } if (invalid) { cout << -1 ...
#include <bits/stdc++.h> using namespace std; long long fac[100001]; long long inv_fac[100001]; int val[100001]; vector<int> cnt(53, 0); int l[100001]; int r[100001]; long long keep[53][53]; long long dp[54][100001]; long long dp1[54][100001]; long long mod = 1e9 + 7; inline void add(long long &...
#include <bits/stdc++.h> using namespace std; long long arr[500005]; map<long long, int> mm; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %lld , &arr[i]); for (int i = 1; i <= n - 1; i++) arr[i] += arr[i - 1]; for (int i = 0; i < n; i++) mm[arr[i]]++; int mx = ...
#include <bits/stdc++.h> using namespace std; double px[1005], py[1005]; double tx, ty; int sum; int pnpoly(int nvert, double *vertx, double *verty, double testx, double testy) { int i, j, c = 0; for (i = 0, j = nvert - 1; i < nvert; j = i++) { if (((verty[i] > testy) != (verty[j] >...
#include<bits/stdc++.h> using namespace std; typedef double db; typedef uint32_t u32; typedef uint64_t u64; typedef pair<int, int> pii; typedef pair<int, int> point; #define fi first #define se second #define pb(x) push_back(x) #define SZ(x) ((int) (x).size()) #define all(x) (x).begin(), (x).end()...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009 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 distributed in ...
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; #define lli long long int #define llu unsigned long long int #define pb push_back #define rt return 0 #define endln n #define all(x) x.b...
`timescale 1ns / 1ps module spi_trx_t; // ins reg clk; parameter TCLK = 20; initial clk = 0; always #(TCLK/2) clk = ~clk; reg sck; parameter TCLK_SCK = 55; reg mosi; reg ss; reg [7:0] data_i; reg ack_i; spi_trx uut( .clk(clk), .sck(sck), .mosi(mosi), .ss(ss), .data_i(data_i), .ack_i(ack_i...
module ALU_bit_tb; reg [8:0]test_vector; // all input signals will be mapped to the test_vector reg // thus the DUT input signals themselves will just be wires wire [4:0]FS; wire A, B, C_in, A_from_next_bit; wire not_A, not_B; // not_A and not_B required for arithmetic functions because behavioral Verilog...
#include <bits/stdc++.h> int II() { int n; scanf( %d , &n); return n; } void II(int n) { printf( %d , n); } void IIn(int n) { printf( %d n , n); } void IIb(int n) { printf( %d , n); } long long int LL() { long long int n; scanf( %lld , &n); return n; } void LL(long long int n) {...
#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-- > 0) { long long n, k; cin >> n >> k; int m; for (m = 2; m <= n; m++) { if (n % m == 0) break; } ...
#include <bits/stdc++.h> using namespace std; inline long long in() { int32_t x; scanf( %d , &x); return x; } inline long long lin() { long long x; scanf( %lld , &x); return x; } inline string get() { char ch[2000010]; scanf( %s , ch); return ch; } inline void read(lo...
/* ----------------------------------------------------------------------- * * Copyright 2004,2007 Tommy Thorn - All Rights Reserved * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundatio...
#include <bits/stdc++.h> using namespace std; int i, j, k, n, m, an; int f[(1 << 20)], h[(1 << 20)]; int main() { scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &k), f[k]++; m = (1 << 20) - 1; for (i = 0; i <= 19; i++) for (j = 0; j <= m; j++) if (!(j & (1 << i))) f[j] += f[...
#include <bits/stdc++.h> using namespace std; int main() { char arr[4][4], a; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cin >> a; arr[i][j] = a; } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (arr[i][j] == # && arr[i][...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long INF = 9e18; const int inf = 2147483647; long long phi(long long n) { long long ans = n; for (long long i = 2; i * i <= n; i++) { if (n % i == 0) { ans = ans / i * (i - 1); while (n % i ==...
// ---------------------------------------------------------------------- // Copyright (c) 2015, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
// Single-bit clock-domain crossing synchronizer // // Notes: // A synchronizer is a device that takes an asynchronous // input and produces an output signal that transitions // synchronous to a sample clock // // The single-bit clock domain synchronizer safely // transfers the output from clock domain A to // clock ...
`timescale 1ns/1ps `default_nettype none module test; localparam NUM_FF = 4; `include "../../../../library/tbassert.v" reg clk = 0; reg rx = 1; reg [13:0] sw = 0; reg ce = 0; reg sr = 0; wire tx; wire [15:0] led; // clock generation always #1 clk=~clk; top unt( .clk(clk), .rx(rx), .tx(tx), .sw({...
#include <bits/stdc++.h> using namespace std; long long int dig(long long int n) { long long int r = 0; while (n) { ++r; n = n / 10; } return (r - 1); } long long int func(long long int n) { if (n <= 9) return (n + 1); long long int lt = dig(n); lt = pow(10, lt); long...
`timescale 1ns / 1ps module pixelGeneration(clk, rst, push, switch, pixel_x, pixel_y, video_on, rgb); input clk, rst; input [3:0] push; input [2:0] switch; input [9:0] pixel_x, pixel_y; input video_on; output reg [2:0] rgb; wire square_on, refr_tick; //define screen size max values. localparam MAX_X = 640; localpar...
/** * 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 INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const int MOD = (int)1e9 + 7; const int N = (int)1e6 + 7; int n, k; int a[N], bit[N]; map<int, int> cnt[11]; long long dp[N][11]; void Init() { for (int i = (1); i < (11); ++i) cn...
#include <bits/stdc++.h> using namespace std; int tree[500000]; int a[100000], pos[100001]; void update(int node, int l, int r, int pos, int u) { if (l == r) { tree[node] += u; return; } int mid = (l + r) / 2; if (pos <= mid) update(2 * node, l, mid, pos, u); else upd...
/** * 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 long long maxn = 2 * 1e6 + 10; long long a[maxn], b[maxn], q[maxn], sz[maxn], n; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int n, t, sz[200010], cen; vector<int> g[200010], v; bool mark[200010]; int dfs(int pos, int par) { sz[pos] = (int)mark[pos]; bool ok = true; for (int i = 0; i < g[pos].size(); i++) if (g[pos][i] != par) { ...
#include <bits/stdc++.h> using namespace std; int main() { int t, s, q, nr = 0; scanf( %d%d%d , &t, &s, &q); while (s < t) { nr++; s += s * (q - 1); } printf( %d , nr); return 0; }
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/06/11 11:25:26 // Design Name: // Module Name: lab5_2_1_tb // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // R...
/** * bsg_lru_pseudo_tree_encode.v * * Pseudo-Tree-LRU encode unit. * Given the LRU bits, traverses the pseudo-LRU tree and returns the * LRU way_id. * Only for power-of-2 ways. * * -------------------- * Example (ways_p=8) * -------------------- * lru_i way_id_o * ----- ...
#include <bits/stdc++.h> using namespace std; signed main() { long long V; cin >> V; while (V--) { double a[250]; for (long long i = 0; i < 250; i++) cin >> a[i]; double exp = 0; for (long long i = 0; i < 250; i++) exp += a[i]; exp /= 250; double var = 0; for (l...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; vector<vector<int>> a(n, vector<int>(m)); map<int, vector<int>> raws; for (int i = 0; i ...
/** * Embedded System in Soongsil University * Author : Namyun Kim, Hanter Jung * Date : 19. June. 2014 **/ module ElevatorSimulator(clk,push_btns,motor_out,dot_col,dot_row); input clk; input [8:0] push_btns; output [3:0] motor_out; output [11:0] dot_col, dot_row; reg [3:0] motor_out; reg motor_count; reg...
/* Title: seven_seg_decoder.v * Author: Sergiy Kolodyazhnyy <> * Date: March 9, 2017 * Purpose: Data-flow code for simple binary to hex display driver * Developed on: Ubuntu 16.04 LTS , Quartus Prime Lite 16.1 * Tested on: DE1-SoC , Cyclone V , 5CSEMA5F31 */ module seven_seg_decoder(led_out,bin_in); output ...
/* * 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; double PI = 3.141592653589793238462643383279; const double EPS = 1e-9; const long long MOD = 1000000007; const int inf = 1 << 30; const long long linf = 1LL << 60; int n; int a[100]; vector<pair<vector<int>, int> > v1, v2; int main() { scanf( %d , &n...
#include <bits/stdc++.h> using namespace std; const int N = (int)1e6 + 5; const int MACX = (int)1e9 + 7; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; long long n, a[N], b[N], c[N]; multiset<long long> ms, ms2; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.ti...
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 10; long long n, a, d[MAXN], v[MAXN], P[MAXN]; vector<pair<int, long long> > vc; long long ans; int main() { cin >> n >> a; vc.push_back({0, 0}); P[0] = -1e18; for (int i = 0; i < n; i++) { cin >> d[i] >> v[i]; ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> a(n), b(n); pair<int, int> p; vector<pair<int, int> > v; for (int i = 0; i < n; i++) { cin >> a[i]; } iota(b.begin(), b.end(), 0); sort(b.begin(), b.end(), [&](int x, int y) { if...
/* * 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 edge { int to, next; } e[400005]; int n, k, num, head[200005], a[200005], f[200005], g[200005], h[200005], g_node[200005], ans, maxa, size[200005]; bool ok[200005]; inline void insert(int u, int v) { e[++num].to = v; e[num].next = head[u...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; scanf( %d%d , &a, &b); if (b > a) { printf( -1 n ); } else if (a == b) { printf( %d.000000000 n , a); } else { int k((a - b) / b); if (k & 1) { k--; } double ans1(1. * (a - b) / k); ...
// file: main_pll.v // // (c) Copyright 2008 - 2011 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 l...
/******************************************************************************* * (c) Copyright 1995 - 2010 Xilinx, Inc. All rights reserved. * * * * This file contains confidential and proprietary information ...
#include <bits/stdc++.h> using namespace std; void solve() { int i, j, n, m; cin >> n; vector<int> vec(n); vector<int> ans; int count = 1; for (int i = 0; i < n; i++) { cin >> vec[i]; } for (int i = 0; i < n; i++) { count = 1; for (int j = 0; j < n; j++) { i...
#include <bits/stdc++.h> using namespace std; vector<long long> v; int main() { long long n, res = 0, i; cin >> n; long long ans = (n * (n + 1)) / 2; if (ans % 2 == 0) cout << 0 << endl; else cout << 1 << endl; ans = ans / 2; for (i = n; i >= 1; i--) { res += i; ...
// // Copyright (c) 1999 Steven Wilson () // // This source code is free software; you can redistribute it // and/or modify it in source code form under the terms of the GNU // General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) // ...
#include <bits/stdc++.h> using namespace std; int T; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> T; for (int i = 0; i < T; i++) { int n, oneCnt = 0, zeroCnt = 0; cin >> n; string str; for (int j = 0; j < n; j++) { char ch; cin >> ch; ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int R[N], czy[N], dp[N], siz[N]; pair<int, int> E[N], E2[N]; int M; pair<int, int> Find(int x) { if (x == R[x]) return {x, 0}; pair<int, int> a = Find(R[x]); a.second ^= czy[x]; return a; } void Union(int a, int b) { ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; const int LG = 27; const int INF = 1e9 + 7; pair<int, int> seg[LG][N]; int mx[LG][N]; int r[N], a[N], sol[N]; pair<int, int> p[N]; int n, k; void build(int l = 0, int r = n, int d = 0) { if (r - l == 1) { seg[d][l] = make...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; int maxim = 0, sum = 0, a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; maxim = max(maxim, a[i]); ...
#include <bits/stdc++.h> int main() { int a, b, r; scanf( %d %d %d , &a, &b, &r); r *= 2; if (r > a || r > b) { printf( Second n ); return 0; } printf( First n ); return 0; }
#include <bits/stdc++.h> using namespace std; int a[5]; int kiemtra(int x, int y, int z) { if (x < y + z && y < z + x && z < x + y) return 1; if (x == y + z || y == x + z || z == x + y) return 2; return 0; } void solve() { int i, j, k, x, gan; gan = 0; for (i = 0; i < 4; i++) for...
//Legal Notice: (C)2019 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; int scan() { return getchar(); } void scan(int& a) { cin >> a; } void scan(long long& a) { cin >> a; } vo...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAXN = 1000010; int prime[5005]; long long f[MAXN][22]; void getPrime() { for (int i = 2; i <= 5000; i++) { if (!prime[i]) prime[++prime[0]] = i; for (int j = 1; j <= prime[0] && prime[j] <= 5000 / i; j++) { ...
#include<stdio.h> #include<bits/stdc++.h> typedef long long ll; using namespace std; int main() { ll deva; cin>>deva; for(ll ol=0;ol<deva;ol++) { int n; cin>>n; string s; cin>>s; int a[26]={0}; int flag=1; ...
// // Copyright (c) 1999 Thomas Coonan () // // This source code is free software; you can redistribute it // and/or modify it in source code form under the terms of the GNU // General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) // ...
#include <bits/stdc++.h> using namespace std; string str; int ss; int par[10001]; int ans[2][10001]; int root(int x) { if (par[x] != x) par[x] = root(par[x]); return par[x]; } map<string, int> m; int main() { while (getline(cin, str)) { char ty = str[0]; int k = 2; int z ...
`timescale 1 ns/1 ps module someTwoPortVendorMem_128_8_0 (QA, CLKA, CENA, WENA, AA, DA, OENA, QB, CLKB, CENB, WENB, AB, DB, OENB); output [7:0] QA; ...
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, ans = 0; const long long maxn = 1e6 + 5; long long p[maxn]; int main() { cin >> a >> b >> c >> d; long long mx = min(b - a, c - b) + 1; for (long long i = a + b, t = 1; i <= b + c; ++i) { p[i] = t; t = min(t + 1, mx); ...
#include <bits/stdc++.h> char a[200005], b[200005], c[200005]; int v[200005], n, m; bool verif(int poz) { int i, j; for (i = 1; i <= n; i++) c[i] = a[i]; for (i = 1; i <= poz; i++) c[v[i]] = 0; for (i = 1, j = 1; i <= n && j <= m; i++) if (c[i] == b[j]) j++; if (j == m + 1) return true; ...
#include <bits/stdc++.h> int main() { long n(0); scanf( %ld , &n); long currentDiv = 2, total = 1; while (n > 1) { if (currentDiv * currentDiv > n) { total += n; break; } else if (n % currentDiv == 0) { total += n; n /= currentDiv; } else { ++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; char buf[1 << 21], *p1 = buf, *p2 = buf; inline long long qread() { register char c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++); register long long x = 0, f = 1; while (c < 0 ...
`timescale 1ns/10ps module usb_121pll_0002( // interface 'refclk' input wire refclk, // interface 'reset' input wire rst, // interface 'outclk0' output wire outclk_0, // interface 'outclk1' output wire outclk_1, // interface 'locked' output wire locked ); altera_pll #( .fractiona...
#include <bits/stdc++.h> using namespace std; const int kN = 1e5 + 10; const int MOD = 1e9 + 7; int N, M; int power(int d, int k) { int ret = 1, tmp = d; while (k) { if (k & 1) { ret = 1ll * ret * tmp % MOD; } tmp = 1ll * tmp * tmp % MOD; k >>= 1; } return ret; ...
#include <bits/stdc++.h> using namespace std; int n, cnt = 0; long long sum = 0; bool flag = false; struct Node { int num; int pos; } a[200005]; bool cmp(const Node &a, const Node &b) { return a.num < b.num; } vector<int> v; int main() { cin >> n; for (int i = 1; i <= n; i++) { c...
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 7; template <class T> void dbs(string str, T t) { cerr << str << : << t << n ; } template <class T, class... second> void dbs(string str, T t, second... s) { int idx = str.find( , ); cerr << str.substr(0, idx) << : <...
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const long long MOD = 1e9 + 7; const long long MODD = 1e9 + 1; const long long MODL = 998244353; const long long N = 200005; const long long INF = 1e18; const long long mx = 1e5 + 1; long long Power(long long x, long long y)...
//...START BY DOING WHAT IS NECESSARY, THEN WHAT IS POSSIBLE AND SUDDENLY YOU ARE DOING THE IMPOSSIBLE... #include <bits/stdc++.h> using namespace std; #define FAST_FURIER ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define pb push_back #define mk make_pair #define rep(i,a,N) for(ll i=a;i<N;...
//----------------------------------------------------------------------------- // File : TestInitializer.v // Creation date : 10.05.2017 // Creation time : 16:20:32 // Description : A bare bones verilog test bench, which is used to assert reset, generate clock, give start signal and finally check after WAIT...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; set<int> s; while (1) { int k = s.size(); s.insert(n); int m = s.size(); if (k == m) break; n = n + 1; while (n % 10 == 0...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a, b; double gia[n]; for (int i = 0; i < n; i++) { cin >> a >> b; gia[i] = (double)a / b; } double kq = gia[0]; for (int i = 1; i < n; i++) { if (kq > gia[i]) kq = gia[i]; } ...
#include <bits/stdc++.h> using namespace std; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } bool prime(long long c) { for (long long i = 2; i * i <= c; i++) { if (c % i == 0) return 0; } return 1; } int32_t main() { c_p_c(); long long n; ci...
#include <bits/stdc++.h> long long int n, m; long long int pow(long long int k) { long long int a = 1, t = 3; for (; k; k /= 2) { if (k & 1) a = (a * t) % m; t = t * t % m; } return a; } void suru() { scanf( %I64d %I64d , &n, &m); } void truli() {} void sutru() { printf( %I64d n ...
#include <bits/stdc++.h> const int INF = 0x3f3f3f3f; using namespace std; int a[105], n, dp[105][105][2], cnt = 0; int main() { scanf( %d , &n); cnt = (n + 1) / 2; for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); if (a[i]) { if (a[i] & 1) --cnt; } } memset(dp, INF...
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long int n, sum = 0, pos = 0, ans1 = 0, ans2 = 0; cin >> n; vector<unsigned long long int> vect; vect.resize(n); for (unsigned long long int i = 0; i < n; i++) { cin >> vect[i]; sum += vect[i]; } if (sum...
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); long long n; cin >> n; vector<int> v(n); for (int i = (0); i < (n); ++i) cin >> v[i]; sort(v.begin(), v.end()); vector<int> res = {v[0]}; for (int i = (0); i < (n); ++i) ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:01:52 06/07/2015 // Design Name: // Module Name: UART_LOOPBACK // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; bool valid(string s) { int start = 0, end = s.length() - 1; while (start < end) { if (s[start] == a && s[end] == a ) { start++; end--; } else if (s[start] == a && s[end] == z ) { return false; } else if (s[start] =...
#include <bits/stdc++.h> using namespace std; const int N = (int)15e4 + 10, M = 310; int n, m, d; long long a[N], b[N], t[N], tmp[N], dp[2][N]; inline void f(int j) { long long k = 1ll * (t[j] - t[j - 1]) * d; int r = j % 2; deque<int> deq; for (int i = 0; i < n; i++) { while (deq.size()...
#include <bits/stdc++.h> using std::cin; using std::string; string x; int a, b, c; int main() { cin >> x; switch (x[0]) { case r : a = 0; break; case s : a = 2; break; case p : a = 5; break; } cin >> x; switch (x[0]) { ...
#include <bits/stdc++.h> using namespace std; multiset<pair<int, int> > st; int main() { int n, k; cin >> n >> k; int cnt = 0; for (int i = 0; i < n; i++) { int num; cin >> num; cnt += num / 10; if (num < 100) st.insert(make_pair(num % 10, num)); } while (st.size() ...
/* * 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 a, b, aa, bb; cin >> a >> b; a += 100; b += 100; cin >> aa >> bb; aa += 100; bb += 100; if (aa != a && bb != b) { int tmp = (abs(a - aa)); int tmp2 = (abs(b - bb)); cout << 2 * abs(tmp2 + tmp) + 4; }...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; while (a > 0) { if (2 * a <= b && 4 * a <= c) { cout << 7 * a; return 0; } else { a--; } } cout << 0 ; return 0; }