Codeforces Round #392 (Div. 2), problem: (F) Geometrical Progression Solution in C/C++

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

#include<stdio.h> #include<stdlib.h> #define N 10000001 #define SN 3163 typedef long long unsigned llu; typedef unsigned u; int F(const void*x,const void*y) { if(*(llu*)x>*(llu*)y)return 1; if(*(llu*)y>*(llu*)x)return-1; return 0; } u D[N],Ga[N],Gi[N];llu *G[N]; int main() { u a,b,c,i,j,k,n,x,y,lo,hi,mi;llu e;llu r=0; for(i=0;++i<SN;)for(k=i*i,j=0;(j+=k)<N;)D[j]=i; scanf("%u%u%u",&n,&x,&y); if(n<3) { r=y-x+1; if(n==0)r=1; if(n==2)r=r*(r-1); [...]

Codeforces Round #392 (Div. 2), problem: (E) Broken Tree Solution in C/C++

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

#include <bits/stdc++.h> #define mk make_pair using namespace std; typedef long long ll; const int N=1e6+5; struct edge { int x,y,w,p; edge(){} void input() { scanf("%d%d%d%d",&x,&y,&w,&p); } }E[N],EE[N]; int n; vector<int> G[N]; ll W[N],WW[N]; void dfs(int x,int y,int id,int mi) { if(id) { int tmp=EE[id].p-E[id].p; [...]

Codeforces Round #392 (Div. 2), problem: (D) Ability To Convert Solution in C/C++

By |2017-04-07T22:10:19+00:00January 20th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include <stdio.h> #include <string.h> int main() { static char s[128]; static long long dp[128]; int n, i, j, l; long long a, b; scanf("%d", &n); scanf("%s", s); l = strlen(s); for (i = 0; i < l; i++) dp[i] = 1e18 + 1; for [...]

Codeforces Round #392 (Div. 2), problem: (C) Unfair Poll Solution in C/C++

By |2017-04-07T22:10:19+00:00January 20th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include <stdio.h> int n,m,X,Y; long long K; long long ans[110][110]; int main() { int i,j,t; long long mn = 1e18, mx = 0; scanf("%d%d%I64d%d%d",&n,&m,&K,&X,&Y); t = (n > 1 ? (2*n-2)*m : m); for(i=2;i<n;i++) for(j=1;j<=m;j++) ans[i][j] = K/t*2; for(j=1;j<=m;j++) ans[1][j] = ans[n][j] = K/t; [...]

Codeforces Round #392 (Div. 2), problem: (B) Blown Garland Solution in C/C++

By |2017-04-08T14:08:28+00:00January 20th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

[amazon_link asins='0789751984,0321563840,0321776410,B00EJ4SQ36,0262162091,0321563840,0789751984,1534679707,0131103628,0321776410' template='ProductCarousel' store='eblogarithm-20' marketplace='US' link_id='79c02f8c-1c32-11e7-b0b4-817d87f7d431']   #include <stdio.h> #include <string.h> int cnt(char *s, char c) { int l, i, j, k; l = strlen(s); j = -1; for (i = 0; i < l; i++) if (s[i] == c) { j = i [...]

Codeforces Round #392 (Div. 2), problem: (A) Holiday Of Equality Solution in C/C++

By |2017-04-07T22:10:19+00:00January 20th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include <stdio.h> int main() { int i, n, x, s=0, max=0; scanf("%d", &n); for (i=0; i<n; i++) { scanf("%d", &x); if (x>max) max=x; s+=x; } printf("%d", n*max-s); return 0; }