Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3), problem: (F) Perishable Roads Solution In JAVA

By |2017-07-24T02:40:45+00:00July 24th, 2017|Categories: Java, Programming|Tags: , , , , , , , , , , |

import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class Div2_412F { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int numV = Integer.parseInt(reader.readLine()); long[][] [...]

Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3), problem: (E) Prairie Partition Solution In C/C++

By |2017-07-24T02:37:16+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include<bits/stdc++.h> using namespace std; int n; long long a[100005]; int check(int x){ int i,j,res,ress,t,sum; long long A,AA; i=0;ress=0; for(j=0;j<60;j++){ A=(1LL<<j); res=0; for(;i<n;i++){ if(a[i]==A){ res++; } else if(a[i]<A){ ress++; } else break; } if(ress>x) return 0; if(x>res){ ress-=(x-res); if(ress<0) ress=0; x=res; } if(res>x) ress+=(res-x); } [...]

Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3), problem: (D) Dynamic Problem Scoring Solution In C/C++

By |2017-07-24T02:35:23+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include<bits/stdc++.h> using namespace std; int a[150][150]; int cnt[10]; int n; int getsc(int id, bool f, int s) { if(a[f][id]==-1) return 0; int sum; if(a[0][id] == -1 || a[1][id] == -1 || a[0][id]<a[1][id]) sum = cnt[id]; else sum = cnt[id]+s; int sc = 500; for(int [...]

Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3), problem: (B) T-Shirt Hunt Solution In C/C++

By |2017-07-24T02:31:32+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include <bits/stdc++.h> using namespace std; int p,x,y,i; int luc(int s){ s = (s/50)%475; for (int i=0;i<25;i++) if((s=(s*96+42)%475)+26==p)return 1; return 0; } int main(){ cin>>p>>x>>y; for(i=x%50;!luc(i)||i<y;i+=50){} return cout<<(i<=x?0:(i-x+99)/100),0; }

Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3), problem: (A) Is it rated? Solution In C/C++

By |2017-07-24T02:30:01+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include <iostream> using namespace std; int n,i,a,a1,b,f; string s[3]={"maybe","unrated","rated"}; int main(){ cin>>n; for(;i<n;i++){ cin>>a>>b; if(a!=b){f=2;break;} if(i>0&&a>a1)f=1; a1=a; } cout<<s[f]; }

Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2), problem: (E) Vulnerable Kerbals Solution in JAVA

By |2017-07-24T01:31:20+00:00July 24th, 2017|Categories: Java, Programming|Tags: , , , , , , |

import java.util.ArrayList; import java.util.Scanner; /* 4 10 2 4 6 8 4 10 2 9 1 0 */ public class e { static ArrayList<Integer>[] gcdLists; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(),m=in.nextInt(); boolean[] forbid = new [...]

Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2), problem: (D) Volatile Kite Solution In C/C++

By |2017-07-24T01:29:06+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include<cstdio> #include<cstdlib> #include<cmath> #include<algorithm> #include<cstring> using namespace std; #define maxn 1005 int x[maxn],y[maxn]; int n; long long area(int i) { int j=(i-1+n)%n,k=(i+1)%n; long long x1=x[i]-x[j],y1=y[i]-y[j], x2=x[i]-x[k],y2=y[i]-y[k]; return abs(x1*y2-x2*y1); } double length(int i) { int j=(i-1+n)%n,k=(i+1)%n; long long dx=x[j]-x[k],dy=y[j]-y[k]; return sqrt(dx*dx+dy*dy); } int main() { [...]

Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2), problem: (C) Voltage Keepsake Solution In C/C++

By |2017-07-24T01:24:34+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include <bits/stdc++.h> using namespace std; struct Time { int i; double v; }; const int MAXN = 1e5; int a[MAXN], b[MAXN]; Time t[MAXN+1]; int main() { int n, p; cin >> n >> p; for (int i = 0; i < n; ++i) { [...]

Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2), problem: (B) Valued Keys Solution In C/C++

By |2017-07-24T01:21:54+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include<bits/stdc++.h> using namespace std; int main() { string a,b; cin>>a>>b; int l=a.length(); for(int i=0;i<l;i++) { if(a[i]<b[i]) { cout<<"-1"; return 0; } } cout<<b; }

Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2), problem: (A) Vicious Keyboard Solution In C/C++

By |2017-07-24T01:19:26+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , , |

#include <stdio.h> int ans,l,i; int main() { char ch[110]; scanf("%s",ch); for( ; ch[i+1]; i++) { l++; if(ch[i]=='V' && ch[i+1]=='K') ans++,ch[i]='#',ch[i+1]='#',i++; } l++; for(i=0; ch[i+1]; i++) { if((ch[i]=='V' && ch[i+1]=='V') || (ch[i]=='K'&&ch[i+1]=='K')) { ans++; break; } } printf("%d",ans); }