Codeforces Round #421 (Div. 2), problem: (E) Mister B and Beacons on Field Solution In C/C++

By |2017-08-05T22:18:19+00:00August 5th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.util.TreeMap; /** * @author Don Li */ public class MisterBBeaconsField { int N = (int) 2e6 + 10; int SQRT = (int) (Math.sqrt(N) + 0.5); int[] f = new [...]

Codeforces Round #421 (Div. 2), problem: (D) Mister B and PR Shifts Solution In C/C++

By |2017-08-05T22:15:33+00:00August 5th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include<stdio.h> #include<stdlib.h> #define LL long long int p[1000005], cur[2000005]; int main(void) { LL ans, sum; int n, L, r, i, temp; scanf("%d", &n); sum = L = r = temp = 0; for(i=1;i<=n;i++) scanf("%d", &p[i]); for(i=1;i<=n;i++) { sum += abs(p[i]-i); if(p[i]>=i) L++, cur[p[i]-i]++; else [...]

Codeforces Round #421 (Div. 2), problem: (C) Mister B and Boring Game Solution In JAVA

By |2017-08-05T22:03:27+00:00August 5th, 2017|Categories: Java, Programming|Tags: , , , |

import java.util.Scanner; public class C { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int a=in.nextInt(); int b=in.nextInt(); int l=in.nextInt(); int r=in.nextInt(); System.out.println(fun(a,b,l,r)); } static int fun(int a,int b,int l,int r){ if ((r-l+1)>2*(a+b)) if (a<=b) return [...]

Codeforces Round #421 (Div. 2), problem: (B) Mister B and Angle in Polygon Solution In C/C++

By |2017-08-05T22:00:46+00:00August 5th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <iostream> using namespace std; int main(){ int n,m,q; cin>>n>>m; q=(n*m+90)/180+2; if(q<n){ n=q; } if(n<3){ n=3; } cout<<"2 1 "<<n; return 0; }

Codeforces Round #421 (Div. 2), problem: (A) Mister B and Book Reading Solution In C/C++

By |2017-08-05T21:57:54+00:00August 5th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include <iostream> using namespace std; int c,v,vl,l,a; int main(){ cin>>c>>v>>vl>>a>>l; int s=1; for(int i=v;i<c;){ v+=a; if(v>vl) v=vl; i-=l; i+=v; s++;} cout<<s<<endl; }