Posts

Showing posts from September, 2016

Dev Skill Mr. And Mrs. A

//Next Codeforces Round #354 (Div. 2) #include<bits/stdc++.h> //#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define high 1000003 #define mxhigh 1000000000003 typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef set<LL>sll; LL sze=0; vll v; void fun() {     LL i, j;     sll st;     sll ::iterator it;     for(i=2; i<high; i++)     {         LL p=1;         for(j=2; j<40; j++)      ...

Dev Skill Divided by Whom ?

//Next Codeforces Round #354 (Div. 2) #include<bits/stdc++.h> //#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define high 100005 typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<LL , bool>mpllb; typedef map<LL , LL>mpLLi; typedef map<int, multiset<int> >mmset; typedef multiset<int>mset; typedef pair<int , int>pii; int ar[high]; pii pr[high]; int main() {     int n, k , i , d , t , tc=0 , prlen=0;     scanf("%d", &t);     mmset mp;     mset::iterator it;     while(t--)   ...

Codeforces B. Anatoly and Cockroaches

//Next Codeforces Round #354 (Div. 2) #include<bits/stdc++.h> //#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; string s , s1="" , s2=""; void ek(int len) {     for(int i=0; i<len; i++)     {         s1 += !(i&1) ? 'r' : 'b';     } } void dui(int len) {     for(int i=0; i<len; i++)     {         s2 += !(i&1) ? 'b' : 'r';     } } int main() {     fast;     int n ...

Codefores A. Vitya in the Countryside

//Next Codeforces Round #354 (Div. 2) #include<bits/stdc++.h> //#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; int ar[100]; int main() {     fast;     int n ,  i;     while(cin >> n)     {         if(n == 1)         {             cin >> ar[0];             if(ar[0] == 15) outn("DOWN");     ...

Codeforces A. Counterexample

//Next Codeforces Round #354 (Div. 2) #include<bits/stdc++.h> //#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; LL gcd(LL a , LL b) {     return b != 0 ? gcd(b , a%b) : a; } int main() {     fast;     LL l , r , i , a , b , c , j;     while(cin >> l >> r)     {         if(r - l < 2)         {             cout << "-1\n";     ...

UVa 661 - Blowing Fuses

#include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define high 25 typedef map<int, bool>mpib; int consumtion[high]; int main() {     fast;     int n , m , c , tc=0 , i=0 , x , maxi=-1 , power=0;     mpib mp;     while(cin >> n >> m >> c)     {         if(!n and !m and !c) break;         mp.clear();         maxi = -1;         power = 0;         bool flown = false;         for(i=1; i<=n; i++)         {             cin >> consumtion[i];         }         for(i=0; i<m; i+...

Codeforces Round #244 (Div. 2) A. Police Recruits

#include<bits/stdc++.h> using namespace std; int main() {     ios_base::sync_with_stdio(false);     int n , x , crime=0, police=0 , i , tmp;     while(cin >> n)     {         crime=0;         police=0;         tmp=0;         for(i=0; i<n; i++)         {             cin >> x;             if(x > 0)             {                 crime+=tmp;                 tmp=0;           ...

Codeforces Round #260 (Div. 2) A. Laptops

#include<bits/stdc++.h> //#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define high 100010 typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; struct my {     int price, quality; }; my ar[high]; bool cmp(my a, my b) {     return a.price < b.price; } int main() {     fast;     int n , a , b ,  i;     while(cin >> n)     {         bool happy=false;         for(i=0; i<n; i++)         {    ...

Codeforces Codeforces Beta Round #9 (Div. 2 Only) A. Die Roll

#include<bits/stdc++.h> //#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; void sol(LL n) {     if(n == 1) outn("1/6");     else if(n == 2) outn("1/3");     else if(n == 3) outn("1/2");     else if(n == 4) outn("2/3");     else if(n == 5) outn("5/6");     else if(n == 6) outn("1/1"); } int main() {     fast;     LL a, b , val=0;     while(cin >> a >> b)     {         if...

Codeforces A. Magnets

#include<bits/stdc++.h> //#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; int main() {     fast;     int n , i , cnt=0;     string s, tmp="";     while(cin >> n)     {         tmp="";         cnt=0;         cin >> s;         tmp = s;         for(i=1; i<n; i++)        ...

Codeforces Round #282 (Div. 2) B. Modular Equations

//#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; int main() {     fast;     LL a , b , cnt=0 , ans=0 , i , div=0, tmp=0;     while(cin >> a >> b)     {         cnt=0;         ans = a - b;         if(ans < 0)         {             cout << "0\n";    ...

Codeforces Round #371 (Div. 2) Meeting of Old Friends

//#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; int main() {     LL l1, r1, l2, r2, k , l , r , ans=0;     while(~sf("%I64d %I64d %I64d %I64d %I64d", &l1, &r1, &l2, &r2, &k))     {         if(l1 > l2) l = l1;         else l = l2;         if(r1 > r2) r = r2;         else r = r1;         if(k >...

Codeforces Roma and Lucky Numbers

//#include<cstdio> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; int main() {     fast;     int n,k ;     LL cnt=0, ans=0 , i , len=0;     string s;     while(cin >> n >> k)     {         cnt=0;         ans=0;         while(n--)         {             cin >...

LightOj 1136 - Division by 3

// Solution Link: 1136 - Division by 3 // Accepted // Time: 0.008 /* Analysis: The number which is number%3=0 and number%3=2 is the answer, because look, a=3 and b=5 means 123%3=0 [1+2+3=6%3=0], 1234%3=1 [1+2+3+4=10%3=1, which is not answer] and 12345%3=0 [1+2+3+4+5=15%3=0] now just think about the positive number sequence 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9, 10, 11, 12 , 13, 14 , 15 , 16 , 17 , 18, 19 , 20 , 21, 22 , 23 , 24, 25; now do the digit sum for 1 to N by Gaussian formula, what will happen ? for 1, 1*(1+1)/2=2/2=1%3=1 is not an answer;     for 2, 2*(2+1)/2=6/2=3%3=0 is an answer;     for 3, 3*(3+1)/2=12/2=6%3=0 is an answer;     for 4, 4*(4+1)/2=20/2=10%3=1 is not an answer;     for 5, 5*(5+1)/2=30/2=15%3=0 is an answer;     for 6, 6*(6+1)/2=42/2=21%3=0 is an answer;     and then you will see the 7 is not an answer by above this process     again 8 and ...

AtCoder Be Together

//#include<stdio.h> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; int main() {     fast;     int n;     vii v;     while(cin >> n)     {         v.clear();         int i=0 , x;         for(; i<n; i++)         {             cin >> x;            ...