Posts

Showing posts from March, 2016

Uva 11415 - Count the Factorials

#include<bits/stdc++.h> #define sze 10000010 #define out(s) cout << s << "\n" #define outs(s) cout << s << " " using namespace std; typedef long long LL; bitset<sze+9>bs; LL nod[sze+9], p = sze+9; void sieve() {     LL i,j;     bs.set();     bs[0] = bs[1] = 0;     nod[1] = 0;     for(i=2; i<=p; i++)     {         if(bs[i])         {             nod[i] = 1;             for(j=2*i; j<=p; j+=i)             {                 nod[j] = 1 + nod[j / i];                 bs[j] = 0;             }         }     }     //for(i=2; i<=20 ; i++)cout << i << " " << nod[i] << "\n"; } void cumulative_sum() {     LL i;     for(i=3; i<=p; i++)     {         nod[i] += nod[i-1];     }     //for(i=2; i<=10; i++)outs(nod[i]); } LL bin_srch(LL target) {     LL lo=1,hi=p,mid;     while(lo <= hi)     {         mid = lo + (hi - lo) / 2;         if(nod[mid] == target)         {             return mid

Uva 11032 - Function Overloading

#include<bits/stdc++.h> #define out(s) cout << s << "\n" #define outs(s) cout << s << " " #define sf scanf #define pf printf #define sze 10000019 using namespace std; typedef long long LL; typedef vector<LL> vll; LL digit_arr[sze]; LL sum(LL n) {     LL s=0;     while(n)     {         s+=(n%10);         n/=10;     }     return s; } void digit_sum() {     LL i;     for(i=1; i<10; i++)     {         digit_arr[i] = i;     }     for(i=10; i<=sze; i++)     {         LL cal = sum(i);         if(cal > 9)         {             digit_arr[i] = cal;         }         else         {             digit_arr[i] = digit_arr[cal];         }     }     //for(i=1;i<=20;i++)outs(digit_arr[i]); } LL fun_one(LL a) {     LL i, h = (a/2)+1;     for(i=h; i<=a; i++)     {         if(i+digit_arr[i] == a)         {             return i;         }     }     return -1; } bool flag[sze]; LL keep[sze]; void inti() {     memset(flag, false, sizeof(f

Uva 10579 - Fibonacci Numbers

#include<bits/stdc++.h> using namespace std; string fibo_num[1000+19]; string not_equal(string a, string b) {     int i=a.size()-1,j=b.size()-1, sum=0, carry=0;     string s="";     for(; i>=0; i--)     {         sum = a[i] - 48;         if(j>=0)         {             sum += (b[j] - 48);             j--;         }         sum+=carry;         if(sum > 10)         {             s += (sum % 10) + 48 ;             carry = sum/10;         }         else         {             s += (sum % 10) + 48;             carry = sum / 10;         }     }     if(carry)     {         s+=(carry + 48);     }     reverse(s.begin(), s.end());     return s; } string _equal(string a, string b) {     int i=a.size()-1, j=b.size()-1, sum=0, carry=0;     string s="";     for(; i>=0, j>=0; i--, j--)     {         sum = (a[i]-48) + (b[j]-48);         sum+=carry;         if(sum > 10)         {             s += (sum % 10) + 48;             carry = sum / 10;         }        

Uva 12854 - Automated Checking Machine

#include<bits/stdc++.h> using namespace std; typedef vector<int>vii; int main() {     vii ek;     int x,y,i;     while(cin >> x)     {         ek.clear();         ek.push_back(x);         for(i=1;i<5;i++)         {             cin >> x;             ek.push_back(x);         }         bool f=false;         for(i=0;i<5;i++)         {             cin >> y;             if(y != ek[i])             {                 if(!(y | ek[i]))                 {                     f=true;                 }             }             else             {                 f=true;             }         }         if(f)         {             cout << "N\n";         }         else         {             cout << "Y\n";         }     }     return 0; }

Uva 694 - The Collatz Sequence

// Header file begin #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<string> #include<vector> #include<cmath> #include<cctype> #include<sstream> #include<set> #include<list> #include<stack> #include<utility> #include<queue> #include<algorithm> #include<cstdlib> #include<bitset> // End //.......... // Macro #define sf scanf #define pf printf #define lp1(i,n) for(i=0;i<n;i++) #define lp2(i,n) for(i=1;i<=n;i++) #define mset(c,v) memset(c,v,sizeof(c)) #define cp(a) cout<<" "<<a<<" " #define nl puts("") #define sq(x) ((x)*(x)) #define all(x) x.begin(),x.end() #define reall(x) x.rbegin(),x.rend() #define s_wap(x,y) x^=y;y^=x;x^=y; #define sz size() #define gc getchar() #define psb push_back #define freader freopen("input.txt","r",stdin) // End......... // Size #define mx7 20000100 #define

Printing some primes

#include<bits/stdc++.h> using namespace std; #define mx 100001000 int prime[(mx>>6) + 1] , prm[(mx>>1)+9], plen=1; #define setbit(n) (prime[n>>6] |= (1 << ((n>>1)&31))) #define checkbit(n) (prime[n>>6] & (1 << ((n>>1)&31))) typedef long long LL; LL ans[60000+6]; void sieve() {     LL i,j;     for(i=3;i*i<=mx; i+=2)     {         if(!checkbit(i))         {             for(j=i*i;j<=mx;j+=i+i)             {                 setbit(j);             }         }     }     prm[plen++]=2;     for(i=3;i<=mx;i+=2)     {         if(!checkbit(i))         {             prm[plen++] = i;         }     }     //for(i=0;i<100;i++)cout << prm[i] << " ";     cout << 2 << "\n";     LL trk = 101,cnt=0,len=0;     for(i=2;i<=plen;i++)     {         if(i == trk)         {             ans[len++] = prm[i];             //cout << prm[i] << "\n";             //cnt++;     

Sherlock and Squares

/*  Formula to find number of perfect square between two numbers:  [ floor(sqrt(b)) - ceil(sqrt(a)) + 1;  ]  why floor b ?  ----- Because we have to take before b, i mean <=b.  why ceil a ?  ----- Because we have to take after a, i mean >=a.  [ for(i=a; i<=b;i++)  ]  Therefore, the result will be [ floor and ceil square root difference between two numbers plus 1] */ #include<bits/stdc++.h> using namespace std; typedef long long LL; int main() {     int t;     cin >> t;     while(t--)     {         LL a,b,i,cnt=0;         cin >> a >> b;         LL res = floor(sqrt(b)) - ceil(sqrt(a)) + 1;         cout << res << "\n";     }     return 0; }

Find Digits

#include<bits/stdc++.h> using namespace std; typedef long long LL; void cunt_digit(LL num) {     LL cnt=0,tmp = num;     while(num)     {         LL kp=(num%10);         if(kp)         {             if(!(tmp % kp))             {                 cnt++;             }         }         num/=10;     }     cout << cnt << "\n"; } int main() {     int t;     cin >> t;     while(t--)     {         LL n;         cin >> n;         cunt_digit(n);     }     return 0; }

Angry Professor

#include<bits/stdc++.h> using namespace std; int main() {     int t;     cin >> t;     while(t--)     {         int n,k,cnt=0;         cin >> n >> k;         bool f=false;         while(n--)         {             int x;             cin >> x;             if(x <= 0)             {                 cnt++;             }             if(cnt >= k)             {                 f=true;             }         }         if(f)         {             cout << "NO\n";         }         else         {             cout << "YES\n";         }     }     return 0; }

Identify Smith Numbers

// Header file begin #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<string> #include<vector> #include<cmath> #include<cctype> #include<sstream> #include<set> #include<list> #include<stack> #include<utility> #include<queue> #include<algorithm> #include<cstdlib> #include<bitset> // End //.......... // Macro #define sf scanf #define pf printf #define lp1(i,n) for(i=0;i<n;i++) #define lp2(i,n) for(i=1;i<=n;i++) #define mset(c,v) memset(c,v,sizeof(c)) #define cp(a) cout<<" "<<a<<" " #define nl puts("") #define sq(x) ((x)*(x)) #define all(x) x.begin(),x.end() #define reall(x) x.rbegin(),x.rend() #define s_wap(x,y) x^=y;y^=x;x^=y; #define sz size() #define gc getchar() #define pb push_back #define freader freopen("input.txt","r",stdin) // End......... // Size #define mx7 20000100 #define m

Uva 11448 - Who said crisis?

import java.util.*; import java.math.*; class Main {     public static void main (String[] args)     {         Scanner in = new Scanner(System.in);                 int t;         t = in.nextInt();         for(int i=0;i<t;i++)         {             BigInteger x,y;             x = in.nextBigInteger();             y = in.nextBigInteger();             System.out.println(x.subtract(y));         }     } }

Uva 11661 - Burger Time?

#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define sf scanf #define pf printf using namespace std; typedef long long LL; char ch[2000000+5]; int main() {     LL t,i;     while(~sf("%lld",&t) and t)     {         getchar();         for(i=1;i<=t;i++)         {             sf("%c",&ch[i]);         }         bool f=false;         LL dist_r=0, dist_d=0, mn=2000000000;         for(i=1;i<=t;i++)         {             if(ch[i] == 'Z')             {                 f=true;                 break;             }             else             {                 if(ch[i] == 'R')                 {                     dist_r=i;                     if(dist_d)                     {                         mn = min(mn, abs(dist_r - dist_d));                     }                 }                 if(ch[i] == 'D')                 {                     dist_d = i;                     if(dist_r)  

Uva 12571 - Brother & Sisters!

// Accepted // Just care about the repeated Numbers.You can do store memories for them #include<cstdio> #include<iostream> #include<vector> #include<algorithm> #include<set> #include<map> #define sf scanf #define pf printf using namespace std; typedef long long LL; typedef set<LL>sll; typedef map<LL,bool>mpbll; LL ar[100100], ans[100100]; int main() {     mpbll mp;     int t;     cin >> t;     while(t--)     {         mp.clear();         LL n,q,i,j,mx;         cin >> n >> q;         for(i=0;i<n;i++)         {             cin >> ar[i];         }         for(i=0;i<q;i++)         {             LL x;             cin >> x;             if(!mp[x])             {                 //cout << x << " ";                 LL mx = -1;                 for(j=0;j<n;j++)                 {                     mx = max(mx, ar[j] & x);                 }                 ans[x] = mx;                

Uva 10334 - Ray Through Glasses

//Verdict :: Accepted //Time :: 0.003 #include<bits/stdc++.h> using namespace std; string ans[1009]; string BuiltIn(string a, string b) {     int i=a.size()-1, j=b.size()-1, res=0,carry=0;     string s="";     if(i > j)     {         for(; i>=0 ; i--)         {             res = a[i] - 48;             if(j>=0)             {                 res+=(b[j]-48);                 j--;             }             res+=carry;             if(res > 10)             {                 s+=((res%10)+48);                 carry=res/10;             }             else             {                 s+=((res%10)+48);                 carry=res/10;             }         }         if(carry)         {             s+=(carry+48);         }     }     else     {         for(; i>=0 and j>=0; i--,j--)         {             res=(a[i]-48) + (b[j]-48);             res+=carry;             if(res > 10)             {                 s+=((res%10)+48);                 carry=res/10;          

Uva 1185 - Big Number

/*  Problem:: Find the number of digits of N! till 10^7.  Verdict :: Accepted  Formula:- D = floor[log10(1)+log10(2)+log10(3)...+log10(N)]; */ #include<bits/stdc++.h> #define sf scanf #define pf printf #define pi acos(-1.0) #define mx 10001000 using namespace std; double ans[mx]; void facto_digits() {     ans[1] = log10(1);     for(int i=2; i<=mx; i++)     {         ans[i] = ans[i-1] + log10(i);     } } int main() {     facto_digits();     int n,t;     sf("%d",&t);     while(t--)     {         sf("%d",&n);         pf("%d\n",(int)(floor(ans[n]) + 1) );     }     return 0; } //===================================================================================================== // Second Solution #include<bits/stdc++.h> #define pi acos(-1.0) using namespace std; int main() {     int t;     cin >> t;     while(t--)     {         int n;         cin >> n;         if(n == 1)         {

Uva 10940 - Throwing cards away II

#include<cstdio> #include<iostream> #include<cmath> #define sf scanf #define pf printf using namespace std; long ans[500050]; void remaining_cards() {     ans[1] = ans[2] = 1;     ans[3] = 2;     for(int i=4; i<=500050; i++)     {         ans[i] = ans[i-1] + 2;         if(ans[i] > i)         {             ans[i] = 2;         }     }     //for(int i=4;i<=19;i++)pf("%d ",ans[i]); } int main() {     remaining_cards();     int n;     while(~sf("%d",&n) and n)     {         pf("%d\n",ans[n]);     }     return 0; }

Uva 10879 - Code Refactoring

#include<cstdio> #include<iostream> #include<cmath> #define sf scanf #define pf printf using namespace std; typedef long long LL; LL ar[5+2]; void soln(LL n) {     int chk=2,len=0;     for(LL i=2; i*i<=n; i++)     {         if(!(n % i))         {             if(chk < 5)             {                 if( (n/i) != i)                 {                     chk+=2;                     //pf("%lld  %lld\n", i, n/i);                     ar[len++]=i;                     ar[len++]=n/i;                 }             }         }     }     pf("%lld = ",n);     if(len < 4)     {         pf("%lld * %lld = %lld * %lld\n",ar[0],ar[1],ar[1],ar[0]);     }     else     {         bool f=false;         for(int i=0;i<len;i++)         {             if(i == 2)             {                 pf(" = %lld",ar[i]);                 continue;             }             if(!f)             {                 pf("%lld",ar[i]);                

Uva 11970 - Lucky Numbers

/* It is very interesting problem ever :). Just need a good problem analysis. Look, We have a equation x / sqrt(n - x), we have to find out the value of x, where x is an integer and must x>0 otherwise it will be undefined; At first, think with Brute force... sqrt(n - x) = 2; => n - x = 4; => - x = 4 - n; => x = n - 4; if n=16, then     x = 16 - 4 = 12;     now check weather x / sqrt(n - x) is an integer or not !     Note: a number may be an integer if has Modulus is 0;     So, 12 / sqrt(16 - 12) = 12 / sqrt(4) = 12 / 2 = 6; That means 12 % 2 = 0; It is an integer.     So, Answer is 12..     On that Brute Force system I have carried that problem to till sqrt(n); */ // Header file begin #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<string> #include<vector> #include<cmath> #include<cctype> #include<sstream> #include<set> #include<list> #include<stack> #include<utility>

HackerRank Sherlock and Divisors

// Accepted #include<iostream> #include<cstdio> #include<cmath> #define sf scanf #define pf printf using namespace std; typedef long long LL; LL div_two(LL num) {     LL cnt=1;     for(LL i=2; i*i<=num; i++)     {         if(!(num % i))         {             if(!(i & 1))             {                 cnt+=1;             }             LL nm = num / i;             if(!(nm & 1))             {                 if(nm != i)                 {                     cnt+=1;                 }             }         }     }     return cnt; } int main() {     int t;     sf("%d",&t);     while(t--)     {         LL n;         sf("%lld",&n);         if(n&1)         {             pf("0\n");         }         else         {             pf("%lld\n",div_two(n));         }     }     return 0; }

Uva 12992 - Huatuo's Medicine

// Ad-hoc DP // Accepted #include<bits/stdc++.h> using namespace std; long ar[205]; void bottles() {     ar[1]=1;     for(int i=2;i<=125;i++)     {         ar[i] = ar[i-1] + 2;     } } int main() {     bottles();     int t,tc=0;     cin >> t;     while(t--)     {         int n;         cin >> n;         cout << "Case #" << ++tc << ": " << ar[n] << endl;     }     return 0; }

Uva 11344 - The Huge One

#include<bits/stdc++.h> using namespace std; typedef long long LL; LL checkDivisibility(string x, LL mod) {     LL i,num=0;     for(i=0;i<x.size();i++)     {         // Modular Arithmetic [ ( (a*10) + digit ) % mod ] = ( ( (a*10) % mod ) + (digit % mod) ) % mod         num = (( num % mod) * (10 % mod)) % mod; // ( (a*10) % mod )         num = num + ((x[i] - 48) % mod); // (digit % mod)         num %= mod; // (digit % mod) % mod     }     return num; } int main() {     string s;     int t;     cin >> t;     while(t--)     {         bool fl=false;         cin >> s;         int n;         cin >> n;         while(n--)         {             int x;             cin >> x;             if(checkDivisibility(s,x))             {                 fl=true;             }         }         if(fl)         {             cout << s << " - " << "Simple." << endl;         }         else         {             cout << s <<

Uva 12602 - Nice Licence Plates

#include<bits/stdc++.h> #define pf printf #define sf scanf using namespace std; int ar[30+5]; void keep() {     for(int i=65, j=0; i<91; i++,j++)     {         ar[i] = j;     }     //for(int i=65;i<=90;i++)cout << ar[i] << " "; } int getnum(char x[]) {     int len=3, sum=0;     int p=2;     for(int i=0; i<3; i++)     {         sum += ar[x[i]] * powl(26,p);         p--;     }     //cout << sum;     return sum; } int main() {     keep();     int t;     char ch[9+5], s[5],c;     sf("%d",&t);     while(t--)     {         getchar();         int n;         for(int i=0;i<3;i++)         {             sf("%c",&s[i]);         }         sf("%c",&c);         sf("%d",&n);//cout << n;         if(abs(getnum(s) - n) < 101)         {             cout << "nice" << endl;         }         else         {             cout << "not nice" << endl;        

Uva 530 - Binomial Showdown

/*  if n=10 and k=7 , then my program works as below:     mx = (n-k, k) = (3, 7) = 7;     mn = (n-k, k) = (3,7) = 3;     so, we got from the nCr formula like that : n! / r! * (n-r)! ;     so, 1*2*3*4*5*6*7*8*9*10 / 1*2*3*4*5*6*7*1*2*3 = 8*9*10 / 1*2*3;     that means multiplication of (n-k)+1 to n divided by multiplication of 1 to (n-k);     therefore, i=8,j=1,ans=1 and 8%1==0 so, ans=1; but ans%j!=0 when j=2 so, break, then ans=1*i=1*8=8;                i=9, j=2,ans=8 and 8%2==0 so, ans=4; but ans%j!=0 when j=3 so, break then ans=4*i=4*9=36;                i=10, j=3,ans=36 and ans%j==0 so, ans=12. finally ans=ans*i=12*10=120;                **** My Solution is 10C7=120; */ #include<bits/stdc++.h> using namespace std; typedef long long LL; int main() {     LL n,k;     while(cin >> n >> k)     {         if(!n and !k) break;         LL ans=1,j=1,mx=max(n-k, k) , mn=min(n-k,k),i;         for(i=mx+1; i<=n; i++)         {             for(; j<=mn ; j++)             {

Uva 10190 - Divide, But Not Quite Conquer!

// Verdict :: Accepted // Time : 0.000 // Header file begin #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<string> #include<vector> #include<cmath> #include<cctype> #include<sstream> #include<set> #include<list> #include<stack> #include<utility> #include<queue> #include<algorithm> #include<cstdlib> #include<bitset> // End //.......... // Macro #define sf scanf #define pf printf #define lp1(i,n) for(i=0;i<n;i++) #define lp2(i,n) for(i=1;i<=n;i++) #define mset(c,v) memset(c,v,sizeof(c)) #define cp(a) cout<<" "<<a<<" " #define nl puts("") #define sq(x) ((x)*(x)) #define all(x) x.begin(),x.end() #define reall(x) x.rbegin(),x.rend() #define s_wap(x,y) x^=y;y^=x;x^=y; #define sz size() #define gc getchar() #define pb push_back #define freader freopen("input.txt","r",stdin) // End.........

Uva 10489 - Boxes of Chocolates

// Be Careful about Big data and data type. :) #include<bits/stdc++.h> using namespace std; typedef long long LL; int main() {     int t;     cin >> t;     while(t--)     {         int frnd,box,k,i;         int ans=0, temp;         cin >> frnd >> box;         while(box--)         {             cin >> k;             temp=1;             for(i=0;i<k;i++)             {                 int x;                 cin >> x;                 temp = (temp % frnd) * (x % frnd) % frnd; // Modular Arithmetic             }             //cout << "temp = " << temp << endl;             ans = (ans + temp) % frnd;             //cout << "ans = " << ans << endl;         }         cout << ans << endl;     }     return 0; }

Uva 11362 - Phone List

Time Limit is big which is unnecessary. I think, 3 sec Time Limit may be a good Time Limit for that Problem :) #include<bits/stdc++.h> using namespace std; typedef vector<string>vs; bool Ischeck(string x, string y) {     int i,len=x.size();     bool fl=false;     for(i=0;i<len;i++)     {         if(x[i] != y[i])         {             return true;         }     }     return false; } int main() {     int t;     vs v;     cin >> t;     while(t--)     {         v.clear();         int n;         cin >> n;         getchar();         string s;         int i;         for(i=0;i<n;i++)         {             cin >> s;             v.push_back(s);         }         sort(v.begin(),v.end());         //for(i=0;i<n;i++)cout << v[i] << " ";         if(n==1)         {             cout << "YES" << endl;             continue;         }         bool f=false;         for(i=0;i<n-1;i++)         {             if(Ischeck(v[

Uva 10935 - Throwing cards away I

#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef long L; typedef vector<LL>vll; typedef queue<LL>qll; int main() {     qll Q;     LL n,i;     while(cin >> n and n)     {         for(i=1;i<=n;i++)         {             //LL x;             //cin >> x;             //v.push_back(i);             Q.push(i);         }         LL rem;         cout << "Discarded cards:";         while(Q.size() > 1)         {             cout << " " << Q.front();             Q.pop();             rem=Q.front();             Q.push(rem);             Q.pop();             if(Q.size()>1)             {                 cout << ",";             }         }         cout << endl << "Remaining card: " << Q.front() << endl;         Q.pop();     }     return 0; }

Uva 10820 - Send a Table

  // Header file begin #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<string> #include<vector> #include<cmath> #include<cctype> #include<sstream> #include<set> #include<list> #include<stack> #include<utility> #include<queue> #include<algorithm> #include<cstdlib> #include<bitset> #include<iomanip> // End //.......... // Macro #define sf scanf #define pf printf #define lp1(i,n) for(i=0;i<n;i++) #define lp2(i,n) for(i=1;i<=n;i++) #define mset(c,v) memset(c,v,sizeof(c)) #define cp(a) cout<<" "<<a<<" " #define nl puts("") #define sq(x) ((x)*(x)) #define all(x) x.begin(),x.end() #define reall(x) x.rbegin(),x.rend() #define s_wap(x,y) x^=y;y^=x;x^=y; #define sz size() #define gc getchar() #define pb push_back #define freader freopen("input.txt","r",stdin) // End......... // Size #

URI Head or Tail

#include<bits/stdc++.h> using namespace std; int main() {     int n;     while(cin >> n)     {         if(!n)break;         int mary=0,john=0;         for(int i=0;i<n;i++)         {             int x;             cin >> x;             if(!x)             {                 mary++;             }             else             {                 john++;             }         }         cout << "Mary won " << mary << " times and John won " << john << " times" << endl;     }     return 0; }

URI Collectable Cards

#include<bits/stdc++.h> using namespace std; int main() {     int t;     cin >> t;     while(t--)     {         int a,b,r=1;         cin >> a >> b;         if(a > b)         {             swap(a,b);         }         // gcd         while(r)         {             r = b % a;             b = a;             a = r;         }         cout << b << endl;     }     return 0; }

Uva 10006 - Carmichael Numbers

 // Accepted---Time::0.139   // Carmichael number হচ্ছে সেইসব নাম্বার যাদের ক্ষেত্রে a^n mod n = a ;(Fermat's Little Theorem) সত্য হবে  // কেবল 2 থেকে n-1 পর্যন্ত ।  // একবার যদি a^n mod n = a ;(Fermat's Little Theorem) মিথ্যা হয় তাহলে  // সেটা Carmichael number নাম্বার নয় ।   // Header file begin #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<string> #include<vector> #include<cmath> #include<cctype> #include<sstream> #include<set> #include<list> #include<stack> #include<utility> #include<queue> #include<algorithm> #include<cstdlib> #include<bitset> #include<iomanip> #include<ctime> #include <time.h> // End //.......... // Macro #define sf scanf #define pf printf #define lp1(i,n) for(i=0;i<n;i++) #define lp2(i,n) for(i=1;i<=n;i++) #define mset(c,v) memset(c,v,sizeof(c)) #define cp(a) cout<<" "<&l