# Author Archives: waprogramming

## 448B

Problem Link View Code #include<bits/stdc++.h> using namespace std; #define all(s) sort(s.begin(),s.end()) string s,t; bool ar() {all(s);all(t); return s==t; } bool autom() { int c=0,sz=0; int l=s.size(); for(int i=0;i<l;i++) { if(s[i]==t[c]) c++,sz++; } return sz==t.size()?1:0; } bool bt() { all(s); … Continue reading

## GSS1

#Problem Link Prerequisites: 1. e-maxx View Code #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll mx = 50010; ll a[mx]; struct data { int sum, pref, suff, ans ; }tree[4*mx] ; data make_data ( ll val … Continue reading

## 126B – Password

This problem is based on Z- algorithm To learn this algorithm – Click here! View Code #include<bits/stdc++.h> using namespace std; void solve(string s) { int l=s.size(); int z[l]; int left,right; left=right=0; for(int k=1;k<l;k++) { if(k>right) { left=right=k; while(right { … Continue reading

## Z algorithm

Today we will try with a new algorithm – Z algorithm This algo is used in pattern matching,there is another algo for pattern matching This algorithm works in O(length of text+length of pattern) complexity and space complexity is similar to … Continue reading

## Lightoj 1414 Feb 29

Problem Link: Hints: if 2nd given month is not feb and january ,i will increment the value by 1 and if the first given month is jan or feb and date is less then 29 then i will decrement the … Continue reading

## 1259: Goldbach`s Conjecture

Problem Link Hints: store prime numbers in an vector; then check the n-*it is prime or not for example 6 2 4 3 3 here 2 is prime but (6-2)=4 is not prime in the case of 3+3 here 3 … Continue reading

## 1067: Combinations

We all know the formula of nCr =n!/(r!*(n-r)!) it’s a general formula,but this problem is about nCr %mod it can be done with Modular multiplicative inverse formula of nCr % mod is (f(n)%mod*(((r)^(mod-2))%mod*((n-r)^(mod-2))%mod)%mod; here we need to calculate the result … Continue reading