Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 – Final Round Div. 2 Edition), problem: (F) Bacterial Melee Solution in C/C++

By | 2017-04-07T22:10:17+00:00 January 23rd, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include <bits/stdc++.h> using namespace std; const int mod = 1e9+7; long long t[20000]; long long binpow(long long a, long long n){ long long ans = 1; while(n){ if(n&1) ans = ans*a % mod; a = a*a % mod; n >>= 1; } return ans; [...]

Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 – Final Round Div. 2 Edition), problem: (E) Nikita and stack Solution in C/C++

By | 2017-04-07T22:10:18+00:00 January 23rd, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include <bits/stdc++.h> using namespace std; const int maxn = 1e5; int a[maxn]; struct segtree{ int lb, rb; int mx = 0, d = 0; segtree *l, *r; segtree(int _lb, int _rb){ lb = _lb, rb = _rb; if(lb != rb){ int t = (lb [...]

Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 – Final Round Div. 2 Edition), problem: (D) Travel Card Solution in C/C++

By | 2017-04-07T22:10:18+00:00 January 23rd, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include <stdio.h> #define SIZE 100010 struct ride { int cost, t; } r[SIZE]; int main() { int i, j, n; scanf("%d", &n); r[0].t = r[0].cost = 0; for (i = 1; i <= n; i++) { scanf("%d", &r[i].t); r[i].cost = r[i - 1].cost + [...]

Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 – Final Round Div. 2 Edition), problem: (C) Pavel and barbecue Solution in C/C++

By | 2017-04-07T22:10:18+00:00 January 23rd, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <stdio.h> #define N 200000 int pp[N], used[N]; void dfs(int i) { if (used[i]) return; used[i] = 1; dfs(pp[i]); } int main() { int n, i, sum, cnt; static int bb[N]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &pp[i]); [...]

Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 – Final Round Div. 2 Edition), problem: (B) Frodo and pillows Solution in C/C++

By | 2017-04-07T22:10:18+00:00 January 23rd, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include <stdio.h> int main() { int n, m, k, h, l, r; scanf("%d %d %d", &n, &m, &k); l = r = k; h = 1; m -= n; while (m - (r - l + 1) >= 0 && !(l == 1 && [...]

Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 – Final Round Div. 2 Edition), problem: (A) Petr and a calendar Solution in C/C++

By | 2017-04-07T22:10:18+00:00 January 23rd, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include<stdio.h> int main() { int a[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int i,m,d,k,n,p; scanf("%d %d",&m,&d); k=7-d+1; i=m-1; n=a[i]-k; p=n/7; if(p*7!=n) p++; printf("%d",p+1); }