text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; template <class T, class V> ostream& operator<<(ostream& s, pair<T, V> a) { s << a.first << << a.second; return s; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); long long int T = 1; cin >> T; for (long long int qq = 1; ...
#include <bits/stdc++.h> using namespace std; long long a, b, ans; void gcd(long long a, long long b) { if (a == 0 || b == 0) return; if (a > b) swap(a, b); ans += (b / a); gcd(b % a, a); } int main() { cin >> a >> b; gcd(a, b); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c = 0; cin >> a >> b; int x[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}; for (int i = a; i <= b; i++) { int y = i; while (y != 0) { c += x[y % 10]; y = y / 10; } } cout << c; return 0; }
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19.06.2017 00:42:43 // Design Name: // Module Name: PS2_y_display // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; long long K, N; string A, B; bool valid[1001]; long long dp[100002][2]; int main() { ios::sync_with_stdio(0); cin >> A >> B >> K; N = A.size(); dp[0][0] = 1, dp[0][1] = 0; for (int i = 1; i <= K; ++i) { dp[i][0] = (N - 1) * dp[i - 1][1]...
#include <bits/stdc++.h> using namespace std; long long zero = 0; long long one = 1; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); } long long expo(long long x, long long y) { long l...
# include<bits/stdc++.h> using namespace std; int main() { int a,b,c=0;set<int>s; cin>>a>>b; while(a) { c++; s.insert(a%b); a/=b; } if(c==s.size()) cout<< YES <<endl; else cout<< NO <<endl; return 0; }
//MODULE REFERENCE `define tenv_usb_encoder tenv_usbhost.tenv_usb_encoder `define tenv_usb_decoder tenv_usbhost.tenv_usb_decoder //MODULE INCLUDING `include "tenv_usbhost/tenv_usb_decoder.v" `include "tenv_usbhost/tenv_usb_encoder.v" module tenv_usbhost #(parameter PACKET_MAXSIZE=64, ...
#include <bits/stdc++.h> using namespace std; long long derangements(long long n) { if (n == 0) return 1; if (n == 1) return 0; if (n == 2) return 1; return (n - 1) * (derangements(n - 1) + derangements(n - 2)); } long long nCr(long long n, long long r) { long long res = 1; if (r == 0) r...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long x, a[N], b[N]; long long n, k; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + 1 + n); b[1] = a[1]; int j = 2; for (int i = 2; i <= n; i++) { if (a[i...
#include <bits/stdc++.h> using namespace std; long long int pows[51]; vector<int> base_3(long long int n) { vector<int> f(51); int r = 0; while (n > 0) { f[r++] = (int)n % 3; n /= 3; } return f; } int main() { int q; cin >> q; pows[1] = 3; pows[0] = 1; for (...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of ent_bb // // Generated // by: wig // on: Tue Jul 4 08:39:13 2006 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../../verilog.xls // // !!! Do not edit this file! Autogenerated by MIX !!! // $Author...
#include <bits/stdc++.h> using namespace std; bool check(long long mid, vector<long long> &d, vector<long long> &prep) { long long n = d.size(); long long m = prep.size() - 1; vector<long long> pos(m + 1, -1); for (long long i = 0; i <= mid; i++) pos[d[i]] = i; for (long long i = 1; i <= m; i++)...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, v, cost, i; cin >> n >> v; if (v >= (n - 1)) cout << n - 1; else { cost = v; for (i = 2; i <= n; i++) { v--; if ((n - i) <= v) { ...
/* * MBus Copyright 2015 Regents of the University of Michigan * * 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 ...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2013.4 // Copyright (C) 2013 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
/* 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; double res; long long n, m, k, i, j, x = 1, y, t, a[1000001], b[1000001]; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> t; if (t == 1) { cin >> k >> m; a[k] += m; y += k * m; printf( %.10f , (double)y / ...
#include <bits/stdc++.h> using namespace std; int n,i,j,k,a[5050],x[5050],y[5050]; long long scp(int i, int j, int k) { long long xa=x[i]-x[j]; long long ya=y[i]-y[j]; long long xb=x[k]-x[j]; long long yb=y[k]-y[j]; return xa*xb+ya*yb; } int main() { scanf( %d ,&n); for (i=0; i<n; ...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, l, m, n, ok = 0; char s1[110], s2[110], ans[110]; scanf( %s , s1); scanf( %s , s2); l = strlen(s1); for (i = 0; i < l; i++) { if (s1[i] > s2[i]) { ans[i] = s2[i]; } else if (s1[i] < s2[i]) { o...
/* * 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; map<int, int> mp; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; int a[n + 1]; int ev = 2, od = 1; int tev = 0, tod = 0; int tot = 0; for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]]++; if (a[i] ...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > grafo[212345]; int marc[212345], dp[212345], ans[212345], ansmin = 1e9; void dfs(int x) { marc[x] = 1; for (int i = 0; i < grafo[x].size(); i++) { int viz = grafo[x][i].first; int type = grafo[x][i].second; if (marc[...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int a[MAXN], b[MAXN], pos[MAXN]; map<int, int> zoom; bool vis[MAXN]; int main() { ios::sync_with_stdio(false); int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); b[i] = a[i]; } ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: dram_sstl_pad.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 redistribute it and...
#include <bits/stdc++.h> using namespace std; int ROW[] = {+1, -1, +0, +0}; int COL[] = {+0, +0, +1, -1}; int X[] = {+0, +0, +1, -1, -1, +1, -1, +1}; int Y[] = {-1, +1, +0, +0, +1, +1, -1, -1}; int KX[] = {-2, -2, -1, -1, 1, 1, 2, 2}; int KY[] = {-1, 1, -2, 2, -2, 2, -1, 1}; int basePrime[] = {1009, 101...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2015.4 // Copyright (C) 2015 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1ns/1ps modul...
#include <bits/stdc++.h> using namespace std; template <class htpe, class cmp> using heap = priority_queue<htpe, vector<htpe>, cmp>; template <class htpe> using min_heap = heap<htpe, greater<htpe> >; template <class htpe> using max_heap = heap<htpe, less<htpe> >; const int INF = 1791791791; const long...
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007LL; long long large = 2000000000000000000LL; int main() { int n, m; cin >> n >> m; vector<vector<int> > adj(n, vector<int>()); set<pair<int, int> > s; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; ...
//////////////////////////////////////////////////////////////////////////////// // Original Author: Schuyler Eldridge // Contact Point: Schuyler Eldridge () // sign_extender.v // Created: 5.16.2012 // Modified: 5.16.2012 // // Generic sign extension module // // Copyright (C) 2012 Schuyler Eldridge, Boston University ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 00:15:39 06/10/2015 // Design Name: game_text_top_ya // Module Name: D:/OnGoingProject/Curriculum/ISE/Proj_x/proj_test/test_game_text_top_ya.v // Project Name: proj_...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int c1 = 0, c2 = 0, c3 = 0; for (int i = 0; i < n; i++) { int x, y, z; cin >> x >> y >> z; c1 += x, c2 += y, c3 += z; } if (c1 == 0 && c2 == 0 && c3 == 0) cout << YES ; else cout <<...
#include <bits/stdc++.h> using namespace std; map<string, long long> mp; int main() { int n; cin >> n; mp.clear(); for (int i = 1; i <= n; ++i) { string tmp; cin >> tmp; mp[tmp]++; } cout << (mp[ UL ] + mp[ DR ] + mp[ ULDR ] + 1) * (mp[ UR ] + mp[ DL ] + m...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7, mod2 = 998244353; unsigned long long base = 131; const int w = 1e7 + 5; long long m, n; int main() { long long i, j, k, t, qqq; cin >> n; string a, b; cin >> a >> b; int flag = 0; for (i = a.size() - 1; i >=...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int inf = 0x3f3f3f3f; const ll INF = 0x3f3f3f3f3f3f3f3fLL; const int MAXN = 1e6 + 5; int arr[MAXN], n; ll fun(ll x) { if (x == 1) return INF; ll sum = 0, y = 0; for (int i = 0; i < n; i++) { y += arr[i]; y %=...
// // Copyright 2012 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...
module testbench (); `include "c_functions.v" `include "c_constants.v" parameter num_credits = 8; parameter reset_type = `RESET_TYPE_ASYNC; parameter Tclk = 2; parameter runtime = 1000; parameter rate_in = 50; parameter rate_out = 50; parameter initial_seed = 0; reg clk; reg res...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int mi[n]; for (int i = (0); i < (n); i++) mi[i] = 1e9; int t = 1; int z[1000]; do { t *= 2; vector<int> v; int x = 0; while (x < n) { int f = 0; for (int i = (0); i < (t /...
/* * 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...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
#include <bits/stdc++.h> using namespace std; bool checkC(int n) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) return 1; } return 0; } void per(string s, int i, int &num, string &ans) { if (i == s.length()) { if (num != 0 && checkC(num)) { int x = num; int d = ...
/* * phase_shift_tb.v: Testbench for phase_shift.v * author: Till Mahlburg * year: 2019 * organization: Universität Leipzig * license: ISC * */ `timescale 1 ns / 1 ps `ifndef WAIT_INTERVAL `define WAIT_INTERVAL 1000 `endif module phase_shift_tb (); reg rst; reg PWRDWN; reg clk; reg signed [31:0] shift_10...
// file: clk_wiz_v3_6.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...
#include <bits/stdc++.h> inline int read() { static char ch; while (ch = getchar(), ch < 0 || ch > 9 ) ; int res = ch - 48; while (ch = getchar(), ch >= 0 && ch <= 9 ) res = res * 10 + ch - 48; return res; } inline unsigned int Rand() { static unsigned int x = 998666131; re...
// file: Clock48MHZ_tb.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 discla...
#include <bits/stdc++.h> using namespace std; int a, b, x, y, cnt; void RUL(int); void DLU(int); void LDR(int); void URD(int); void disp_res(int x, int y) { printf( %d %d n , x, y); exit(0); } void RUL(int n) { if (cnt == b) { disp_res(x, y); }; if (n <= 0) return; URD(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 la...
//---------------------------------------------------------------------------- // Copyright (C) 2009 , Olivier Girard // // 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 must re...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 9, N = 1e3 + 9; const int qwer[] = {-1, 0, 1, 0}, asdf[] = {0, 1, 0, -1}; int n, m, a[N][N], arr[MAX], sizee[MAX], number, c[N][N], vv, cnt; long long k; struct node { int id, x, y; } b[MAX]; int root(int x) { return x == arr[x] ? x...
#include <bits/stdc++.h> using namespace std; void solve(); int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t = 1; while (t--) { solve(); cout << n ; } cerr << time taken : << (float)clock() / CLOCKS_PER_SEC << secs << endl; return 0; }...
#include <bits/stdc++.h> const double PI = 3.141592653589793238460; long long int gcd(long long int a, long long int b) { if (a == 0) return b; return gcd(b % a, a); } long long int max(long long int a, long long int b) { if (a > b) return a; else return b; } long long int min(lo...
#include <bits/stdc++.h> using namespace std; struct EDGE { int adj, next; } edge[810000]; int n, m, q, top, gh[510000]; int size[510000], dfn[510000], low[510000], cnt, ind, stop, instack[510000], stck[510000], belong[510000]; void addedge(int x, int y) { edge[++top].adj = y; edge[top].ne...
`timescale 1ns / 1ns module ph_fifo ( input h_rst_b, input h_rd, input h_selectData, input h_phi2, input [7:0] p_data, input p_selectData, input p_phi2, input p_rdnw, ...
// megafunction wizard: %RAM: 2-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: RAM4096x64_2RW.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 law...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const lo...
#include<bits/stdc++.h> #define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define arin(x,n) for(int i=0;i<n;i++)cin>>x[i] #define debug(x,n) for(int i=0;i<n;i++)cout<<x[i]<< #define pb push_back #define all(c) begin(c), end(c) #define isAll(c) (int)(c).size() typedef long long int ll; ...
module control_leer(clk,load_e,efect0,add_1,add_2,reset_1,reset_2,top_1,top_2,load_crt,done_crt,new_col,reset_new,load_led,rst,run_efect); input clk; input load_e; input efect0; input top_1; input top_2; input done_crt; input new_col; input run_efect; output reg rst; output reg add_1; output reg add_2; out...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; int T, n, m; string s; int vis[26]; int pos[maxn][26]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> T; while (T--) { memset(vis, 0, sizeof(...
#include <bits/stdc++.h> using namespace std; const double pi = 3.14159265359; long long max(long long a, long long b) { if (a >= b) return a; else return b; } long long min(long long a, long long b) { if (a <= b) return a; else return b; } bool valid(int i, int j, ...
/* * 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 util_sigma_delta_spi ( input clk, input resetn, input spi_active, input s_sclk, input s_sdo, input s_sdo_t, output s_sdi, input [NUM_CS-1:0] s_cs, output m_sclk, output m_sdo, output m_sdo_t, input m_sdi, output [NUM_CS-1:0] m_cs, output reg data_ready ); parameter NUM_CS = 1; parameter CS_PI...
#include <bits/stdc++.h> using namespace std; using ll = long long; int const N = 100 * 1000 + 16; int const M = 1000 * 1000 * 1000 + 7; int n, k; int a[N]; int c[N]; ll e, v[N]; vector<int> idx[N]; struct wavelet { int L, R; vector<int> b; wavelet* l = 0; wavelet* r = 0; wavelet...
//#pragma comment(linker, /STACK:102400000,102400000 ) #include<bits/stdc++.h> using namespace std; typedef long long ll; #define int ll typedef pair<int,int>pii; #define ff first #define ss second #define debug(x) std:: cerr << #x << = << x << std::endl; const int maxn=2010,inf=0x3f3f3f3f,mod=10...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1605; int n, m, tot; int a[MAXN][MAXN]; int sz[MAXN * MAXN]; int ans[MAXN * MAXN]; int cnt[MAXN * MAXN]; int fa1[MAXN * MAXN]; int fa2[MAXN * MAXN]; double v[MAXN][MAXN]; double t[MAXN][MAXN]; int getroot(int *fa, int u) { return...
#include <bits/stdc++.h> using namespace std; const long long int MAXN = 1e18 + 7; const long long int MAXNN = 300005; long long int int_pow(long long int base, long long int exp) { long long int result = 1; while (exp) { if (exp & 1) result *= base; exp /= 2; base *= base; } r...
// Local Variables: // verilog-library-directories:("." "../../") // End: module resource_table_tb (); localparam CU_ID_WIDTH = 1; localparam NUMBER_CU = 2; localparam WF_SLOT_ID_WIDTH = 4; localparam NUMBER_WF_SLOTS_PER_CU = 4; localparam RES_ID_WIDTH = 4; localparam NUMBER_RES_SLOTS = 16; ...
#include <bits/stdc++.h> inline int read() { int x; char c; while ((c = getchar()) < 0 || c > 9 ) ; for (x = c - 0 ; (c = getchar()) >= 0 && c <= 9 ;) x = x * 10 + c - 0 ; return x; } int a[100000 + 5]; void solve(int n) { for (int i = 20, x; i; --i) if (n & (1 << 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() { float h, l, ans; cin >> h >> l; ans = (l * l - h * h) / (2 * h); cout << setprecision(13) << ans; return 0; }
#include <bits/stdc++.h> using namespace std; long long f[200][200], a[200], x[200], y[200], d; int n; long long dist(int i, int j) { return abs(x[i] - x[j]) + abs(y[i] - y[j]); } int main() { cin >> n >> d; for (int i = 2; i <= n - 1; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> x[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; const int N = 500 + 7; long long mod = 1e9 + 7; bool solve(long long l, long long r, long long mx, long long& ans) { if (r - l + 1 > mx) { return false; } ans = -l + 1; return true; } int main() { ios_base::sync_with_stdio(0), cin.tie(0...
#include <bits/stdc++.h> using namespace std; int main() { long long int p; cin >> p; for (long long int z = 0; z < p; z++) { long long int n; cin >> n; while (1) { break; } string a; cin >> a; long long int re = 0, ro = 0, be = 0, bo = 0; for (lon...
// (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...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; char a[1010], b[1010]; int h = 0; int main() { scanf( %s , a); int l = strlen(a); int j = 0; for (int i = 0; i < l; i++) { b[j++] = a[i]; if (a[i] == > ) { b[j] = 0; if (b[1] == / ) h--; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; double ans; int a[N]; int n, u, p; int main() { scanf( %d%d , &n, &u); ans = 0; for (int i = 1; i <= n; i++) { scanf( %d , a + i); } for (int i = 1; i <= n; i++) { if (i <= n - 2) { p = lower_bound(...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; if (k == 0 || k == n) { cout << 0 0 ; return 0; } cout << min(1LL, n - k) << << min(n - k, k * 2LL); return 0; }
#include <bits/stdc++.h> using namespace std; mt19937_64 rnd(time(NULL)); const int N = 25; const int inf = 1e9; const double MAX_T = 1000; const double MIN_T = 1e-5; const int max_mutations = 10; int n, m; vector<int> A, B; vector<vector<int> > best_ans, cur_ans; int best_cost = 0; inline void ...
// This file has been automatically generated by goFB and should not be edited by hand // Compiler written by Hammond Pearce and available at github.com/kiwih/goFB // Verilog support is EXPERIMENTAL ONLY // This file represents the Composite Function Block for CfbTlNetwork module FB_CfbTlNetwork ( input wire clk,...
#include <bits/stdc++.h> using namespace std; long long int dp[2005][2005]; int main() { int n, i, k1, j, k; cin >> n >> k1; long long int ans = 0; dp[0][1] = 1; for (i = 1; i <= k1; i++) { for (j = 1; j <= n; j++) { for (k = j; k <= n; k += j) { dp[i][k] += dp[i - 1][j...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 300 * 1000 + 10; pair<int, int> c[MAX_N]; int t[MAX_N]; int main() { ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> c[i].first, c[i].second = i; se...
#include <bits/stdc++.h> using namespace std; long long spf[100001]; bool isPrime(long long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; r...
#include <bits/stdc++.h> using namespace std; int n, m, k, dotx, doty; char t[502][502]; int vis[502][502]; int x[4] = {0, -1, 0, 1}; int y[4] = {1, 0, -1, 0}; void dfs(int r, int c) { if (r >= n || r < 0 || c >= m || c < 0 || t[r][c] == # || vis[r][c]) return; vis[r][c] = 1; for (int i = 0;...
/* * 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 run(vector<vector<int>> &sets, int **sum); pair<vector<vector<int>>, int **> precalc(); const int MAXB = 5; const int MOD = 1e9 + 7; int main() { ios::sync_with_stdio(false); cout.tie(0); auto precalc_vals = precalc(); run(precalc_vals.first...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 13:57:07 03/28/2014 // Design Name: alu // Module Name: D:/XilinxProject/CPU/alu_tester.v // Project Name: CPU // Target Device: // Tool versions: // Description...
#include <bits/stdc++.h> struct val { long long x; int y, d; val *p, *l, *r; } g1[100001], g2[100001], *rt1[100001], *rt2[100001], *nil = g1; struct node { long long x; int y; bool operator<(const node &b) const { return x < b.x; } } a[100001]; struct vale { long long x; int y;...
/*============================================================================ This Verilog source file is part of the Berkeley HardFloat IEEE Floating-Point Arithmetic Package, Release 1, by John R. Hauser. Copyright 2019 The Regents of the University of California. All rights reserved. Redistribution an...
#include <bits/stdc++.h> using namespace std; char q[15][15], p[15][15], max_s[15], min_s[15], tmp[15], ans[15]; int np[15]; int main() { int i, j, k, n, carry, t, flag; while (scanf( %d %d , &n, &k) != EOF) { for (i = 0; i < n; ++i) scanf( %s , q + i); for (i = 0; i < k; ++i) { np[i...
#include <bits/stdc++.h> using namespace std; const int MX_N = 3e5 + 5; const int MX_M = 3e5 + 5; int N, M, D[MX_N]; vector<pair<int, int>> al[MX_N]; int vis[MX_N], sumD; vector<int> edges; void dfs(int u, int p = 0, int pe = 0) { vis[u] = 1; for (auto v : al[u]) if (!vis[v.first]) { ...
#include <bits/stdc++.h> using namespace std; int qp(int a, long long b) { int ans = 1; do { if (b & 1) ans = 1ll * ans * a % 1000000007; a = 1ll * a * a % 1000000007; } while (b >>= 1); return ans; } int ans[222222], atot = 0; char s[222222], t[222222]; long long ct[26]; int n...
#include <bits/stdc++.h> using namespace std; bool isprime(int n) { if (n == 1) return false; if (n == 2) return true; for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { return false; } } return true; } void answer(int f) { if (f) { cout << YES ; } else...
////////////////////////////////////////////////////////////////////////////////// // // This file is part of the N64 RGB/YPbPr DAC project. // // Copyright (C) 2016-2018 by Peter Bartmann <> // // N64 RGB/YPbPr DAC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public ...
#include <bits/stdc++.h> using namespace std; const long long Mxn = 1e6 + 7; const long long Mod = 1e9 + 7; const long long Inf = 1e16 + 7; const long long Module = 998244353; int N; long long Ans, A[Mxn], B[Mxn], Val[Mxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int start = 0, end = m; int ans; while (start <= end) { int mid = ...
#include <bits/stdc++.h> const double Pi = acos(-1.0); using namespace std; const int maxN = 100005; const long long mod = 1000000009; int n, m; int par[maxN]; int findpar(int x) { if (par[x] != x) par[x] = findpar(par[x]); return par[x]; } int main(int argc, char** argv) { scanf( %d %d , ...
#include <bits/stdc++.h> int arr[1000]; int main() { int count, i, j, n; scanf( %d , &n); for (i = 0; i < n; i++) scanf( %d , &arr[i]); count = 0; i = 0; while (i < n) { j = i; while ((j < n) && (arr[j] == 1)) j++; if (j > i) count += j - i + 1; i = j + 1; } i...