Posts

Showing posts from December, 2016

Codeforces Whose sentence is it?

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef vector<string>vs; const int mod = 1000007; const int high = 100; class out { public:     void noregonize()     {         cout << "OMG>.< I don't know!\n";     }     void lala()     {         cout << "Freda's\n";     }     void miao()     {         cout << "Rainbow's\n";     } }; int main() {     fast;     out obj;     int n , i , len ,

Codeforces New Year Table

#include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back #define pi acos(-1.0) typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100; const double eps = 1e-9; class newYear { public:     void solution(double n , double R , double r)     {         if(n == 1.0)         {             if(R >= r) pf("YES\n");             else pf("NO\n");             //continue;         }         else         {             double theta = pi / n;             double total_raddi_r = sin(theta) * (R - r);             total_raddi_r+= eps;             if(total_raddi_r >= r) pf("YES\n");             else pf("NO\n");         }     } }; int main

Codeforces Nineteen

Link: http://codeforces.com/problemset/problem/393/A /* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<char, int>mpci; const int mod = 1000007; const int high = 100; mpci mp; char ch[10]={'e' , 'i' , 'n' , 't'}; class nineteen {     int len , i , ans=100003; public:     void solution(string s)     {         mp.clear();         ans = 1000005;         //ans = -1;         len = s.length();         for(i=0; i<len

Codeforces Appleman and Card Game

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<char, int>mpci; const int mod = 1000007; const int high = 100; LL ar[256]; bool cmp(LL a, LL b) {      return a > b; } int main() {     fast;     LL n , k , i , ans=0;     string s;     while(cin >> n >> k)     {         ans=0;         memset(ar , 0, sizeof ar);         cin >> s;         int len = s.length();         for(i=0; i<len; i++) ar[s[i]]++;         sort(ar , ar+25

Codeforces Sort the Array

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; const int mod = 1000007; const int high = 100003; const int inf = 1000005; int ar[high] , br[high] , up[high]; int main() {     fast;     int n , i , j , x , y;     while(cin >> n)     {         for(i=0; i<n; i++)         {             cin >> ar[i];             br[i] = ar[i];         }         sort(br , br+n);         bool f=false;         x = y = 0;         for(i=0;

Codeforces Little Girl and Game

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<char, int>mpci; const int mod = 1000007; const int high = 100; int main() {     fast;     string s ;     int i , len , cnt=0;     mpci mp;     while(cin >> s)     {         mp.clear();         len = s.length();         cnt=0;         for(i=0; i<len; i++)         {             mp[s[i]]++;         }         for(char c='a'; c<='z'; c++)         {             cnt+=(mp[c] %

Codeforces Santa Claus and a Place in a Class

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #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 #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100; int main() {     fast;     int n , m , i=1 , j;     LL k , tmp;     while(cin >> n >> m)     {         i = 0;         cin >> k;         tmp = 0;         while(tmp < k)         {             tmp+=(m * 2);             if(tmp < k) i++;         }         //cout << i << "\n";         i+=1;         //cout << tmp <&l

Codeforces Vanya and Lanterns

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #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 #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 1003; int ar[high]; int main() {     fast;     int n , l , i , mxdist=0;     double ans;     while(~sf("%d %d", &n , &l))     {         for(i=0; i<n; i++)         {             sf("%d", &ar[i]);         }         sort(ar , ar+n);         mxdist = -1;         for(i=0; i<n-1; i++)         {             int def = ar[i+1] - ar[i];     

Codeforces Taxi

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #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 #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100003; int ar[high]; int main() {     fast;     int n , x , i , j , cnt=0;     while(cin >> n)     {         for(i=0; i<n; i++)         {             cin >> ar[i];         }         sort(ar , ar+n);         i=0;         j=n-1;         cnt=0;         for(i=0, j=n-1; i<=j;)         {             if(i == j)             {                 cnt++;          

Codeforces Comparing Strings

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #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 #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int , int>mpci; const int mod = 1000007; const int high = 100; int main() {     fast;     int i;     mpci fr , se;     string first, second;     while(cin >> first >> second)     {         if(first.length() == second.length())         {             int in=0;             fr.clear();             for(i=0; i<second.length(); i++)             {                 if(first[i] != second[

Codeforces Mammoth's Genome Decoding

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #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 #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<char, int>mpci; const int mod = 1000007; const int high = 300; //struct my //{ //    char ch; //    int wieght; //}ar[high]; int main() {     fast;     int n , len , i , j;     char ch[]={'A' , 'C' , 'G' , 'T'};     string s , ans;     mpci mp;     while(cin >> n)     {         mp.clear();         cin >> s;         ans=s;         len = s.length();  

Codeforces Hongcow Learns the Cyclic Shift

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #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 #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100; int main() {     fast;     string s , tmp , parmanent;     int len , i , j , cnt=0;     while(cin >> s)     {         cnt=1;         parmanent = s;         len = s.length();         i = len-1;         tmp = s[i];         for(j=0; j<i; j++)         {             tmp+=s[j];         }         while(tmp != parmanent)         {             cnt+=1;            

Codeforces Chloe and the sequence

//I am Just Not Good at it #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 #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100; int main() {     fast;     int n;     LL k;     while(cin >> n >> k)     {         int cnt=0;         while(k%2!=1)         {             cnt++;             k/=2;         }         cout << cnt+1 << "\n";     }     return 0; }

Codeforces Vladik and fractions

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A piece of Greatness in this World. */ #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 #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100; int main() {     fast;     LL n;     while(cin >> n)     {         if(n == 1)         {             cout << "-1\n";             continue;         }         cout << n << " " << (n+1) << " " << n * (n+1) << "\n";     }     return 0; }

Codeforces Arpa’s obvious problem and Mehrdad’s terrible solution

//I am struggling //Just Not Good at it #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 #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; const int mod = 1000007; const int high = 100003; int ar[high]; int main() {     fast;     int n , x , i , j ;     LL p , res=0;     mpii mp;     while(cin >> n >> x)     {         mp.clear();         for(i=1; i<=n; i++)         {             cin >> ar[i];             mp[ar[i]]++;         } //        for(i=1; i<=n-1; i++) //        { //            for(j=i+1; j<=n; j++) //            { //                if((ar[i] ^ ar[j]) == x) //                { //                    cout << ar[i] <&

Code chef Train Partner

//I am struggling //Just Not Good at it #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 #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; typedef map<int, string>mpsi; const int mod = 1000007; const int high = 600; mpii mp; mpsi ms; void partner() {     int i , cnt=0;     for(i=8; i<=high; i+=8)     {         mp[i] = i-1;         ms[i] = "SU";         mp[i-1] = i;         ms[i-1] = "SL";     }     for(i=1; i<=high; i++)     {         if(!mp[i])         {             mp[i] = i+3;             mp[i+3] = i;             cnt++;             if(cnt == 1)             {                 ms[i] = "LB";                 ms[i+3]