├── .github └── FUNDING.yml ├── CP Books ├── Art of Programming Contest.pdf ├── Competitive Programmer’s Handbook.pdf ├── Competitive-Programming-3.pdf ├── Concrete_Mathematic_knuth.pdf ├── DP (Tasneem Reza).pdf ├── Dawn of Porgramming Contest (July, 2015).pdf ├── Guide To Competitive Programming (2017).pdf ├── Guide-to-Competitive-Programming-Learning-and-improving-Algorithms-through-Contests.pdf ├── INTRODUCTION TO ALGORITHOMS.pdf ├── Problem Solving Strategies Engel.pdf └── Programming_Challenges.pdf ├── Codeforces Round Problem Solved ├── Codeforces Round #725 (Div-3) │ └── A Stone Game.cpp ├── Codeforces Round #729 (Div-2) │ └── Odd Set.cpp ├── Codeforces Round #730 (Div-2) │ ├── A Shortest Path with Obstacle.cpp │ └── B Alphabetical Strings.cpp ├── Codeforces Round #731 (Div-2) │ └── Codeforces Round 732Div2.cpp ├── Codeforces Round #733 (Div-3) │ ├── B - Putting Plates.cpp │ ├── Binary Decimel.cpp │ └── C - Pursuit.cpp ├── Codeforces Round #756 (Div. 3) │ └── B.cpp ├── Educational Codeforces Round 111 (Rated for Div 2) │ ├── A Find The Array.cpp │ └── B-Maximum Cost Deletion.cpp └── Harbour Space Scholarship Contest 2021 │ ├── A Digits Sum.cpp │ └── B Reverse String.cpp ├── CoderByte Problem Solved └── JavaScript │ └── Find Intersection │ └── FindIntersection.js ├── GUIDE TO COMPETITIVE PROGRAMMING .docx ├── HackerRank Online Judge Problem Solve-Java └── Algorithms │ ├── Sorting │ ├── Big Sorting │ │ └── Main.java │ ├── Closest Numbers │ │ └── Main.java │ ├── Correctness and the Loop Invariant │ │ └── Main.java │ ├── Counting Sort 1 │ │ └── Main.java │ ├── Counting Sort 2 │ │ └── Main.java │ ├── Counting Sort 3 │ │ └── Main.java │ ├── Find the Median │ │ └── Main.java │ ├── Fraudulent Activity Notifications │ │ └── Main.java │ ├── Insertion Sort1 │ │ └── Main.java │ ├── Insertion Sort2 │ │ └── Main.java │ ├── Intro to Tutorial Challenges │ │ └── Main.java │ ├── Lily's Homework │ │ └── Main.java │ ├── Quicksort 1-Partition │ │ └── Main.java │ ├── Quicksort 2 - Sorting │ │ └── Main.java │ ├── Quicksort In-Place │ │ └── Main.java │ ├── Running Time of Algorithms │ │ └── Main.java │ ├── Running Time of Quicksort │ │ └── Main.java │ └── The Full Counting Sort │ │ └── Main.java │ ├── Strings │ ├── Alternating Characters │ │ └── Main.java │ ├── Anagram │ │ └── Main.java │ ├── Beautiful Binary String │ │ └── Main.java │ ├── Caesar Cipher Encryption │ │ └── Main.java │ ├── Caesar Cipher │ │ └── Main.java │ ├── CamelCase │ │ └── Main.java │ ├── Funny String │ │ └── Main.java │ ├── Game of Thrones-I │ │ └── Main.java │ ├── Gemstones │ │ └── Main.java │ ├── HackerRank a String │ │ └── Main.java │ ├── Making Anagrams │ │ └── Main.java │ ├── Mars Exploration │ │ └── Main.java │ ├── Morgan and │ │ └── Main.java │ ├── Palindrome Index │ │ └── Main.java │ ├── Pangrams │ │ └── Main.java │ ├── Richie Rich │ │ └── Main.java │ ├── Separate the Numbers │ │ └── Main.java │ ├── Sherlock and Valid String │ │ └── Main.java │ ├── String Construction │ │ └── String Construction-HackerRank.java │ ├── Strong Password │ │ └── Main.java │ ├── Super Reduced String │ │ └── Main.java │ ├── The Love-Letter Mystery │ │ └── Main.java │ ├── Two Characters │ │ └── Main.java │ ├── Two Strings │ │ └── Main.java │ └── Weighted Uniform Strings │ │ └── Main.java │ └── Warmup │ ├── A Very Big Sum │ └── Main.java │ ├── Birthday Cake Candles │ └── Main.java │ ├── Compare the Triplets │ └── Main.java │ ├── Diagonal Difference │ └── Main.java │ ├── Mini-Max Sum │ └── Main.java │ ├── Plus Minus │ └── Main.java │ ├── Simple Array Sum │ └── Main.java │ ├── Solve Me First │ └── Main.java │ ├── Staircase │ └── Main.java │ └── Time Conversion │ └── Main.java ├── ICPC-Questiom-and-Answer-Using-CPP ├── Asia West Continent Championship - 2019 │ └── Problemset - Asia West Continent Championship - 2019.pdf ├── ICPC Challenge 2021 Marathon (powered by Huawei) │ └── index.txt ├── ICPC Dhaka Regional 2020 Online Preliminary Contest - Hosted by CSE, DU │ └── J. COVID-19.cpp ├── Mock of ICPC Dhaka Regional 2020 Online Preliminary │ ├── A. Almost Forgot to Welcome.cpp │ ├── B. Good Things Come to Those Who Wait.cpp │ ├── C. Triangle.cpp │ └── README.md └── Synapse Collaborative Contest-NCPC Preparation 2021 │ └── Candle.cpp ├── LICENSE ├── README.md └── Virtual-Judge-Problem-Solved-SUB-CONTEST ├── A+B Problem(SUB-CONTEST-01).c ├── Calculate Desired Grade Point.c ├── R2 Problem(SUB-CONTEST-01).c ├── R2 Problem.cpp └── Three Side lengths Triangle.cpp /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: n3o-d4rk3r 2 | patreon: kabirsplanet 3 | ko_fi: kabirsplanet 4 | 5 | -------------------------------------------------------------------------------- /CP Books/Art of Programming Contest.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/Art of Programming Contest.pdf -------------------------------------------------------------------------------- /CP Books/Competitive Programmer’s Handbook.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/Competitive Programmer’s Handbook.pdf -------------------------------------------------------------------------------- /CP Books/Competitive-Programming-3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/Competitive-Programming-3.pdf -------------------------------------------------------------------------------- /CP Books/Concrete_Mathematic_knuth.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/Concrete_Mathematic_knuth.pdf -------------------------------------------------------------------------------- /CP Books/DP (Tasneem Reza).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/DP (Tasneem Reza).pdf -------------------------------------------------------------------------------- /CP Books/Dawn of Porgramming Contest (July, 2015).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/Dawn of Porgramming Contest (July, 2015).pdf -------------------------------------------------------------------------------- /CP Books/Guide To Competitive Programming (2017).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/Guide To Competitive Programming (2017).pdf -------------------------------------------------------------------------------- /CP Books/Guide-to-Competitive-Programming-Learning-and-improving-Algorithms-through-Contests.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/Guide-to-Competitive-Programming-Learning-and-improving-Algorithms-through-Contests.pdf -------------------------------------------------------------------------------- /CP Books/INTRODUCTION TO ALGORITHOMS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/INTRODUCTION TO ALGORITHOMS.pdf -------------------------------------------------------------------------------- /CP Books/Problem Solving Strategies Engel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/Problem Solving Strategies Engel.pdf -------------------------------------------------------------------------------- /CP Books/Programming_Challenges.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/CP Books/Programming_Challenges.pdf -------------------------------------------------------------------------------- /Codeforces Round Problem Solved/Codeforces Round #725 (Div-3)/A Stone Game.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ---------------------------------------------------- 3 | ---------In the name of ALLAH ---------------------- 4 | ---------------------------------------------------- 5 | * Tried by Aryan Kabir 6 | * CSE, SUB, BD 7 | * 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long int li; 16 | 17 | typedef pair pii; 18 | 19 | typedef map msi; 20 | typedef map mss; 21 | 22 | typedef vector vi; 23 | typedef vector vll; 24 | typedef vector vb; 25 | typedef vector vs; 26 | 27 | typedef double dbl; 28 | 29 | 30 | #define pb push_back 31 | 32 | #define MAX 1e30 33 | #define MAX1 10^9+7 34 | #define MAX2 10^9+9 35 | 36 | 37 | #define pf printf 38 | #define sc scanf 39 | 40 | #define s1(n) scanf("%d",&n) 41 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 42 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 43 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 44 | 45 | #define ss1(n) scanf("%lld",&n) 46 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 47 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 48 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 49 | 50 | #define p1(x) printf("%I64d",x) 51 | #define p2(x,y) printf("%I64d %I64d",x,y) 52 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 53 | 54 | #define fi(i,a,b) for(long long i=a;i<=b;i++) 55 | #define fm(i , a) for(long long i=1;i<=a;i++) 56 | #define fd(i,a,b) for(long long i=b;i>=a;i--) 57 | 58 | #define FOR1(i,n) for(int i=0; i=0; i--) 60 | 61 | #define OUT0(x)cout<<(x)<<" " 62 | #define OUT1(x)cout<<(x)<>(x) 69 | #define IN2(x,y) cin>>(x)>>(y) 70 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 71 | 72 | #define clr(x) memset(x,0,sizeof(x)) 73 | #define cln(x) memset(x,-1,sizeof(x)) 74 | 75 | #define HR cout<<"\n-------------------------\n" 76 | #define NL cout<<"\n" 77 | 78 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 79 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 80 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 82 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 83 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 84 | 85 | void pre(){ 86 | int n; 87 | cin>>n; 88 | int a[n], x, y; 89 | for(int i=0; i>a[i]; 91 | if(a[i] == 1)x=i; 92 | else if (a[i]==n) y=i; 93 | } 94 | cout<>t; 99 | while(t--) 100 | pre(); 101 | return 0; 102 | } 103 | 104 | 105 | -------------------------------------------------------------------------------- /Codeforces Round Problem Solved/Codeforces Round #729 (Div-2)/Odd Set.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ---------------------------------------------------- 3 | ---------In the name of ALLAH ---------------------- 4 | ---------------------------------------------------- 5 | * Tried by Aryan Kabir 6 | * CSE, SUB, BD 7 | * 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long double ld; 16 | typedef long int li; 17 | 18 | typedef pair pii; 19 | 20 | typedef map msi; 21 | typedef map mss; 22 | 23 | typedef vector vi; 24 | typedef vector vll; 25 | typedef vector vb; 26 | typedef vector vs; 27 | 28 | typedef double dbl; 29 | 30 | 31 | #define pb push_back 32 | 33 | #define MAX 1e30 34 | #define MAX1 10^9+7 35 | #define MAX2 10^9+9 36 | 37 | 38 | #define pf printf 39 | #define sc scanf 40 | 41 | #define s1(n) scanf("%d",&n) 42 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 43 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 44 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 45 | 46 | #define ss1(n) scanf("%lld",&n) 47 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 48 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 49 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 50 | 51 | #define p1(x) printf("%I64d",x) 52 | #define p2(x,y) printf("%I64d %I64d",x,y) 53 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 54 | 55 | #define fi(i,a,b) for(long long i=a;i<=b;i++) 56 | #define fm(i , a) for(long long i=1;i<=a;i++) 57 | #define fd(i,a,b) for(long long i=b;i>=a;i--) 58 | 59 | #define FOR1(i,n) for(int i=0; i=0; i--) 61 | 62 | #define OUT0(x)cout<<(x)<<" " 63 | #define OUT1(x)cout<<(x)<>(x) 70 | #define IN2(x,y) cin>>(x)>>(y) 71 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 72 | 73 | #define clr(x) memset(x,0,sizeof(x)) 74 | #define cln(x) memset(x,-1,sizeof(x)) 75 | 76 | #define HR cout<<"\n-------------------------\n" 77 | #define NL cout<<"\n" 78 | 79 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 80 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 81 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 83 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 84 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 85 | 86 | 87 | /* amon vabe pair make korbo jno prottekta pair jogler word hoy */ 88 | 89 | void pre(){ 90 | 91 | int n; 92 | cin>>n; 93 | int c = 0; 94 | for (int i = 0; i < 2 * n; i++) { 95 | int a; 96 | cin >> a; 97 | if (a%2 == 1)c++; 98 | } 99 | if (c == n)cout<<"Yes\n"; 100 | else 101 | cout<<"No\n"; 102 | } 103 | 104 | int main() { 105 | cout.precision(5); 106 | int t; 107 | cin>>t; 108 | while(t--) 109 | pre(); 110 | return 0; 111 | } 112 | -------------------------------------------------------------------------------- /Codeforces Round Problem Solved/Codeforces Round #730 (Div-2)/A Shortest Path with Obstacle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ---------------------------------------------------- 3 | ---------In the name of ALLAH ---------------------- 4 | ---------------------------------------------------- 5 | * Tried by Aryan Kabir 6 | * CSE, SUB, BD 7 | * 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long int li; 16 | typedef int ii; 17 | 18 | typedef pair pii; 19 | 20 | typedef map msi; 21 | typedef map mss; 22 | 23 | typedef vector vi; 24 | typedef vector vll; 25 | typedef vector vb; 26 | typedef vector vs; 27 | 28 | #define pb push_back 29 | 30 | #define MAX1 10^9+7 31 | #define MAX2 10^9+9 32 | 33 | #define FOR1(i,n) for(int i=0; i=0; i--) 35 | 36 | #define OUT0(x)cout<<(x)<<" " 37 | #define OUT1(x)cout<<(x)<>(x) 44 | #define IN2(x,y) cin>>(x)>>(y) 45 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 46 | 47 | #define HR cout<<"\n-------------------------\n" 48 | #define NL cout<<"\n" 49 | 50 | 51 | typedef vector vi; 52 | typedef vector vs; 53 | 54 | template void inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 55 | template void inpV(vector &vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 56 | templatevoid outV(vector&vec){for(int i=0; i void sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 58 | template void rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 59 | template bool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 60 | 61 | 62 | void pre(){ 63 | 64 | } 65 | 66 | int main() 67 | { 68 | ii t; 69 | cin>>t; 70 | while(t--){ 71 | 72 | ii xA,yA,xB,yB,xF,yF; 73 | 74 | cin>>xA>>yA>>xB>>yB>>xF>>yF; 75 | 76 | ii ans = abs(xA-xB) + abs(yA-yB); 77 | 78 | if(xA!=xB && yA!=yB){ 79 | cout< 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long int li; 16 | typedef int ii; 17 | 18 | typedef pair pii; 19 | 20 | typedef map msi; 21 | typedef map mss; 22 | 23 | typedef vector vi; 24 | typedef vector vll; 25 | typedef vector vb; 26 | typedef vector vs; 27 | 28 | #define pb push_back 29 | 30 | #define MAX1 10^9+7 31 | #define MAX2 10^9+9 32 | 33 | #define FOR1(i,n) for(int i=0; i=0; i--) 35 | 36 | #define OUT0(x)cout<<(x)<<" " 37 | #define OUT1(x)cout<<(x)<>(x) 44 | #define IN2(x,y) cin>>(x)>>(y) 45 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 46 | 47 | #define HR cout<<"\n-------------------------\n" 48 | #define NL cout<<"\n" 49 | 50 | 51 | typedef vector vi; 52 | typedef vector vs; 53 | 54 | template void inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 55 | template void inpV(vector &vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 56 | templatevoid outV(vector&vec){for(int i=0; i void sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 58 | template void rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 59 | template bool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 60 | 61 | 62 | void pre(){ 63 | 64 | } 65 | int main(){ 66 | 67 | ll t; 68 | string ans; 69 | 70 | string s; 71 | char chars[26] ; 72 | 73 | FOR1(i,26){ 74 | chars[i] = 'a' + i ; 75 | } 76 | 77 | cin>>t ; 78 | while(t--){ 79 | cin >> s ; 80 | ii n = s.size() ; 81 | 82 | vectorcontains(26, 0) ; 83 | ans = "YES" ; 84 | 85 | for(char c : s){ 86 | contains[c-'a'] = 1; 87 | } 88 | 89 | for(ii i=0 ; i s[i-1] && s[i] > s[i+1]){ 96 | ans = "NO" ; 97 | } 98 | } 99 | cout << ans << endl ; 100 | } 101 | 102 | 103 | return 0 ; 104 | 105 | } -------------------------------------------------------------------------------- /Codeforces Round Problem Solved/Codeforces Round #731 (Div-2)/Codeforces Round 732Div2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ---------------------------------------------------- 3 | ---------In the name of ALLAH ---------------------- 4 | ---------------------------------------------------- 5 | * Tried by Aryan Kabir 6 | * CSE, SUB, BD 7 | * 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long int li; 16 | 17 | typedef pair pii; 18 | 19 | typedef map msi; 20 | typedef map mss; 21 | 22 | typedef vector vi; 23 | typedef vector vll; 24 | typedef vector vb; 25 | typedef vector vs; 26 | 27 | typedef double dbl; 28 | 29 | 30 | #define pb push_back 31 | 32 | #define MAX 1e30 33 | #define MAX1 10^9+7 34 | #define MAX2 10^9+9 35 | 36 | 37 | #define pf printf 38 | #define sc scanf 39 | 40 | #define s1(n) scanf("%d",&n) 41 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 42 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 43 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 44 | 45 | #define ss1(n) scanf("%lld",&n) 46 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 47 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 48 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 49 | 50 | #define p1(x) printf("%I64d",x) 51 | #define p2(x,y) printf("%I64d %I64d",x,y) 52 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 53 | 54 | #define fi(i,a,b) for(long long i=a;i<=b;i++) 55 | #define fm(i , a) for(long long i=1;i<=a;i++) 56 | #define fd(i,a,b) for(long long i=b;i>=a;i--) 57 | 58 | #define FOR1(i,n) for(int i=0; i=0; i--) 60 | 61 | #define OUT0(x)cout<<(x)<<" " 62 | #define OUT1(x)cout<<(x)<>(x) 69 | #define IN2(x,y) cin>>(x)>>(y) 70 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 71 | 72 | #define clr(x) memset(x,0,sizeof(x)) 73 | #define cln(x) memset(x,-1,sizeof(x)) 74 | 75 | #define HR cout<<"\n-------------------------\n" 76 | #define NL cout<<"\n" 77 | 78 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 79 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 80 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 82 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 83 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 84 | 85 | 86 | void pre() 87 | { 88 | } 89 | 90 | dbl f(vi s, vi d, dbl t, int n){ 91 | dbl maxA = -MAX; 92 | dbl minA = MAX; 93 | for(int i=0; i>n>>k; 106 | vi s, d; 107 | for(int i=0; i>si>>di; 110 | s.pb(si); 111 | d.pb(di); 112 | } 113 | dbl l = 0; 114 | dbl r = k; 115 | while(r-l>1e-7){ 116 | dbl third = (r-l)/3; 117 | dbl m1 = l + third; 118 | dbl m2 = r - third; 119 | dbl f1 = f(s,d, m1, n); 120 | dbl f2 = f(s,d, m2, n); 121 | if(f1 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long int li; 16 | 17 | typedef pair pii; 18 | 19 | typedef map msi; 20 | typedef map mss; 21 | 22 | typedef vector vi; 23 | typedef vector vll; 24 | typedef vector vb; 25 | typedef vector vs; 26 | 27 | typedef double dbl; 28 | 29 | 30 | #define pb push_back 31 | 32 | #define MAX 1e30 33 | #define MAX1 10^9+7 34 | #define MAX2 10^9+9 35 | 36 | 37 | #define pf printf 38 | #define sc scanf 39 | 40 | #define s1(n) scanf("%d",&n) 41 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 42 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 43 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 44 | 45 | #define ss1(n) scanf("%lld",&n) 46 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 47 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 48 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 49 | 50 | #define p1(x) printf("%I64d",x) 51 | #define p2(x,y) printf("%I64d %I64d",x,y) 52 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 53 | 54 | #define fi(i,a,b) for(long long i=a;i<=b;i++) 55 | #define fm(i , a) for(long long i=1;i<=a;i++) 56 | #define fd(i,a,b) for(long long i=b;i>=a;i--) 57 | 58 | #define FOR1(i,n) for(int i=0; i=0; i--) 60 | 61 | #define OUT0(x)cout<<(x)<<" " 62 | #define OUT1(x)cout<<(x)<>(x) 69 | #define IN2(x,y) cin>>(x)>>(y) 70 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 71 | 72 | #define clr(x) memset(x,0,sizeof(x)) 73 | #define cln(x) memset(x,-1,sizeof(x)) 74 | 75 | #define HR cout<<"\n-------------------------\n" 76 | #define NL cout<<"\n" 77 | 78 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 79 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 80 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 82 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 83 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 84 | 85 | void pre(){ 86 | 87 | int r,c,i,j; 88 | char ch[50][50]; 89 | cin>>r>>c; 90 | for(i=0;i>t; 119 | while(t--){ 120 | pre(); 121 | } 122 | } 123 | 124 | 125 | -------------------------------------------------------------------------------- /Codeforces Round Problem Solved/Codeforces Round #733 (Div-3)/Binary Decimel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ---------------------------------------------------- 3 | ---------In the name of ALLAH ---------------------- 4 | ---------------------------------------------------- 5 | * Tried by Aryan Kabir 6 | * CSE, SUB, BD 7 | * 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long int li; 16 | 17 | typedef pair pii; 18 | 19 | typedef map msi; 20 | typedef map mss; 21 | 22 | typedef vector vi; 23 | typedef vector vll; 24 | typedef vector vb; 25 | typedef vector vs; 26 | 27 | typedef double dbl; 28 | 29 | 30 | #define pb push_back 31 | 32 | #define MAX 1e30 33 | #define MAX1 10^9+7 34 | #define MAX2 10^9+9 35 | 36 | 37 | #define pf printf 38 | #define sc scanf 39 | 40 | #define s1(n) scanf("%d",&n) 41 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 42 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 43 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 44 | 45 | #define ss1(n) scanf("%lld",&n) 46 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 47 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 48 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 49 | 50 | #define p1(x) printf("%I64d",x) 51 | #define p2(x,y) printf("%I64d %I64d",x,y) 52 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 53 | 54 | #define fi(i,a,b) for(long long i=a;i<=b;i++) 55 | #define fm(i , a) for(long long i=1;i<=a;i++) 56 | #define fd(i,a,b) for(long long i=b;i>=a;i--) 57 | 58 | #define FOR1(i,n) for(int i=0; i=0; i--) 60 | 61 | #define OUT0(x)cout<<(x)<<" " 62 | #define OUT1(x)cout<<(x)<>(x) 69 | #define IN2(x,y) cin>>(x)>>(y) 70 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 71 | 72 | #define clr(x) memset(x,0,sizeof(x)) 73 | #define cln(x) memset(x,-1,sizeof(x)) 74 | 75 | #define HR cout<<"\n-------------------------\n" 76 | #define NL cout<<"\n" 77 | 78 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 79 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 80 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 82 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 83 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 84 | 85 | void pre(ll n){ 86 | ll ans = 0; 87 | while(n>0){ 88 | ll temp = n, m=0, p=1; 89 | while(temp){ 90 | ll rem = temp%10; 91 | temp = temp/10; 92 | if(rem != 0) 93 | m+=p; 94 | p*=10; 95 | 96 | } 97 | ans++; 98 | n = n - m; 99 | } 100 | cout<>t; 106 | 107 | while(t--){ 108 | cin>>n; 109 | pre(n); 110 | } 111 | } 112 | 113 | 114 | -------------------------------------------------------------------------------- /Codeforces Round Problem Solved/Codeforces Round #733 (Div-3)/C - Pursuit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ---------------------------------------------------- 3 | ---------In the name of ALLAH ---------------------- 4 | ---------------------------------------------------- 5 | * Tried by Aryan Kabir 6 | * CSE, SUB, BD 7 | * 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long int li; 16 | 17 | typedef pair pii; 18 | 19 | typedef map msi; 20 | typedef map mss; 21 | 22 | typedef vector vi; 23 | typedef vector vll; 24 | typedef vector vb; 25 | typedef vector vs; 26 | 27 | typedef double dbl; 28 | 29 | 30 | #define pb push_back 31 | 32 | #define MAX 1e30 33 | #define MAX1 10^9+7 34 | #define MAX2 10^9+9 35 | 36 | 37 | #define pf printf 38 | #define sc scanf 39 | 40 | #define s1(n) scanf("%d",&n) 41 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 42 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 43 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 44 | 45 | #define ss1(n) scanf("%lld",&n) 46 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 47 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 48 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 49 | 50 | #define p1(x) printf("%I64d",x) 51 | #define p2(x,y) printf("%I64d %I64d",x,y) 52 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 53 | 54 | #define fi(i,a,b) for(long long i=a;i<=b;i++) 55 | #define fm(i , a) for(long long i=1;i<=a;i++) 56 | #define fd(i,a,b) for(long long i=b;i>=a;i--) 57 | 58 | #define FOR1(i,n) for(int i=0; i=0; i--) 60 | 61 | #define OUT0(x)cout<<(x)<<" " 62 | #define OUT1(x)cout<<(x)<>(x) 69 | #define IN2(x,y) cin>>(x)>>(y) 70 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 71 | 72 | #define clr(x) memset(x,0,sizeof(x)) 73 | #define cln(x) memset(x,-1,sizeof(x)) 74 | 75 | #define HR cout<<"\n-------------------------\n" 76 | #define NL cout<<"\n" 77 | 78 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 79 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 80 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 82 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 83 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 84 | 85 | int T,n,a[100003],b[100003]; 86 | 87 | vi v, g; 88 | bool pre(int mid){ 89 | 90 | v.clear(); 91 | g.clear(); 92 | 93 | for(int i=0;i= 0; 102 | } 103 | 104 | int main(){ 105 | cin>>T; 106 | while(T--){ 107 | cin>>n; 108 | for(int i=0;i 11 | using namespace std; 12 | 13 | #define MAX0 1e30 14 | #define MAX1 10^9+7 15 | #define MAX2 10^9+9 16 | 17 | #define fst first 18 | #define sec second 19 | #define pb push_back 20 | #define mp make_pair 21 | #define eb emplace_back 22 | #define pf push_front 23 | #define popb pop_back 24 | #define popf pop_front 25 | #define hashmap unordered_map 26 | #define hashset unordered_set 27 | #define lb lower_bound 28 | #define ub upper_bound 29 | #define ff first 30 | #define ss second 31 | 32 | #define pf printf 33 | #define sc scanf 34 | #define s1(n) scanf("%d",&n) 35 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 36 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 37 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 38 | 39 | #define ss1(n) scanf("%lld",&n) 40 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 41 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 42 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 43 | 44 | #define p1(x) printf("%I64d",x) 45 | #define p2(x,y) printf("%I64d %I64d",x,y) 46 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 47 | #define all(a) (a).begin(), (a).end() 48 | #define rall(a) (a).rbegin(), (a).rend() 49 | 50 | 51 | #define fi(i,a,b) for(ll i=a;i<=b;i++) 52 | #define fm(i , a) for(ll i=1;i<=a;i++) 53 | #define fd(i,a,b) for(ll i=b;i>=a;i--) 54 | 55 | #define foi(n) for(ll i=0;i=a;i--) 60 | #define forrrr(i,a,b,k) for(ll i=a;i=0; i--) 64 | 65 | 66 | #define OUT0(x) cout<<(x)<<" " 67 | #define OUT1(x) cout<<(x)<>(x) 74 | #define IN2(x,y) cin>>(x)>>(y) 75 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 76 | 77 | #define clr(x) memset(x,0,sizeof(x)) 78 | #define cln(x) memset(x,-1,sizeof(x)) 79 | 80 | #define HR cout<<"\n-------------------------\n" 81 | #define NL cout<<"\n" 82 | 83 | typedef unsigned long long int ull; 84 | typedef long long ll; 85 | typedef long long int lli; 86 | typedef long double ld; 87 | typedef long int li; 88 | 89 | typedef pair pii; 90 | 91 | typedef map msi; 92 | typedef map mss; 93 | 94 | typedef vector vi; 95 | typedef vector vll; 96 | typedef vector vb; 97 | typedef vector vs; 98 | 99 | typedef double dbl; 100 | 101 | const int MOD=1e9+7;//998244353; 102 | const int MAX=1e3+2; 103 | 104 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 105 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 106 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end());} 108 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 109 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 110 | 111 | void pre(){ 112 | 113 | int a, b; 114 | s2(a,b); 115 | cout<>t; 121 | while(t--) { 122 | pre(); 123 | } 124 | } -------------------------------------------------------------------------------- /Codeforces Round Problem Solved/Educational Codeforces Round 111 (Rated for Div 2)/A Find The Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ---------------------------------------------------- 3 | ---------In the name of ALLAH ---------------------- 4 | ---------------------------------------------------- 5 | * Tried by Aryan Kabir 6 | * CSE, SUB, BD 7 | * 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long double ld; 16 | typedef long int li; 17 | 18 | typedef pair pii; 19 | 20 | typedef map msi; 21 | typedef map mss; 22 | 23 | typedef vector vi; 24 | typedef vector vll; 25 | typedef vector vb; 26 | typedef vector vs; 27 | 28 | typedef double dbl; 29 | 30 | 31 | #define pb push_back 32 | 33 | #define MAX 1e30 34 | #define MAX1 10^9+7 35 | #define MAX2 10^9+9 36 | 37 | 38 | #define pf printf 39 | #define sc scanf 40 | 41 | #define s1(n) scanf("%d",&n) 42 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 43 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 44 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 45 | 46 | #define ss1(n) scanf("%lld",&n) 47 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 48 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 49 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 50 | 51 | #define p1(x) printf("%I64d",x) 52 | #define p2(x,y) printf("%I64d %I64d",x,y) 53 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 54 | 55 | #define fi(i,a,b) for(long long i=a;i<=b;i++) 56 | #define fm(i , a) for(long long i=1;i<=a;i++) 57 | #define fd(i,a,b) for(long long i=b;i>=a;i--) 58 | 59 | #define FOR1(i,n) for(int i=0; i=0; i--) 61 | 62 | #define OUT0(x)cout<<(x)<<" " 63 | #define OUT1(x)cout<<(x)<>(x) 70 | #define IN2(x,y) cin>>(x)>>(y) 71 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 72 | 73 | #define clr(x) memset(x,0,sizeof(x)) 74 | #define cln(x) memset(x,-1,sizeof(x)) 75 | 76 | #define HR cout<<"\n-------------------------\n" 77 | #define NL cout<<"\n" 78 | 79 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 80 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 81 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 83 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 84 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 85 | 86 | void pre(){ 87 | int n; 88 | int s,cnt=0; 89 | cin>>s; 90 | for(int i=1;i<=100;i++){ 91 | cnt+=(2*i-1); 92 | if(cnt>=s){ 93 | cout<>t; 103 | while(t--) 104 | pre(); 105 | return 0; 106 | } 107 | -------------------------------------------------------------------------------- /Codeforces Round Problem Solved/Educational Codeforces Round 111 (Rated for Div 2)/B-Maximum Cost Deletion.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ---------------------------------------------------- 3 | ---------In the name of ALLAH ---------------------- 4 | ---------------------------------------------------- 5 | * Tried by Aryan Kabir 6 | * CSE, SUB, BD 7 | * 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long double ld; 16 | typedef long int li; 17 | 18 | typedef pair pii; 19 | 20 | typedef map msi; 21 | typedef map mss; 22 | 23 | typedef vector vi; 24 | typedef vector vll; 25 | typedef vector vb; 26 | typedef vector vs; 27 | 28 | typedef double dbl; 29 | 30 | 31 | #define pb push_back 32 | 33 | #define MAX 1e30 34 | #define MAX1 10^9+7 35 | #define MAX2 10^9+9 36 | 37 | 38 | #define pf printf 39 | #define sc scanf 40 | 41 | #define s1(n) scanf("%d",&n) 42 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 43 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 44 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 45 | 46 | #define ss1(n) scanf("%lld",&n) 47 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 48 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 49 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 50 | 51 | #define p1(x) printf("%I64d",x) 52 | #define p2(x,y) printf("%I64d %I64d",x,y) 53 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 54 | 55 | #define fi(i,a,b) for(long long i=a;i<=b;i++) 56 | #define fm(i , a) for(long long i=1;i<=a;i++) 57 | #define fd(i,a,b) for(long long i=b;i>=a;i--) 58 | 59 | #define FOR1(i,n) for(int i=0; i=0; i--) 61 | 62 | #define OUT0(x)cout<<(x)<<" " 63 | #define OUT1(x)cout<<(x)<>(x) 70 | #define IN2(x,y) cin>>(x)>>(y) 71 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 72 | 73 | #define clr(x) memset(x,0,sizeof(x)) 74 | #define cln(x) memset(x,-1,sizeof(x)) 75 | 76 | #define HR cout<<"\n-------------------------\n" 77 | #define NL cout<<"\n" 78 | 79 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 80 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 81 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 83 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 84 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 85 | 86 | void pre(){ 87 | int a, b, n; 88 | cin>>n>>a>>b; 89 | string s; 90 | cin>>s; 91 | int ans=a, cnt=1, CNT=0; 92 | 93 | for(int i=1;i>t; 108 | while(t--) 109 | pre(); 110 | return 0; 111 | } 112 | -------------------------------------------------------------------------------- /Codeforces Round Problem Solved/Harbour Space Scholarship Contest 2021/A Digits Sum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ---------------------------------------------------- 3 | ---------In the name of ALLAH ---------------------- 4 | ---------------------------------------------------- 5 | * Tried by Aryan Kabir 6 | * CSE, SUB, BD 7 | * 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long int li; 16 | 17 | typedef pair pii; 18 | 19 | typedef map msi; 20 | typedef map mss; 21 | 22 | typedef vector vi; 23 | typedef vector vll; 24 | typedef vector vb; 25 | typedef vector vs; 26 | 27 | typedef double dbl; 28 | 29 | 30 | #define pb push_back 31 | 32 | #define MAX 1e30 33 | #define MAX1 10^9+7 34 | #define MAX2 10^9+9 35 | 36 | 37 | #define pf printf 38 | #define sc scanf 39 | 40 | #define s1(n) scanf("%d",&n) 41 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 42 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 43 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 44 | 45 | #define ss1(n) scanf("%lld",&n) 46 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 47 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 48 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 49 | 50 | #define p1(x) printf("%I64d",x) 51 | #define p2(x,y) printf("%I64d %I64d",x,y) 52 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 53 | 54 | #define fi(i,a,b) for(long long i=a;i<=b;i++) 55 | #define fm(i , a) for(long long i=1;i<=a;i++) 56 | #define fd(i,a,b) for(long long i=b;i>=a;i--) 57 | 58 | #define FOR1(i,n) for(int i=0; i=0; i--) 60 | 61 | #define OUT0(x)cout<<(x)<<" " 62 | #define OUT1(x)cout<<(x)<>(x) 69 | #define IN2(x,y) cin>>(x)>>(y) 70 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 71 | 72 | #define clr(x) memset(x,0,sizeof(x)) 73 | #define cln(x) memset(x,-1,sizeof(x)) 74 | 75 | #define HR cout<<"\n-------------------------\n" 76 | #define NL cout<<"\n" 77 | 78 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 79 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 80 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 82 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 83 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 84 | 85 | void pre(){ 86 | string S,T; 87 | cin>>S>>T; 88 | for(int i=0;i0;i--){ 98 | dp[i][0]=(S[i]==c&&dp[i-1][0]); 99 | } 100 | dp[0][0] = 0; 101 | } 102 | for(int i=0;i>T; 114 | while(T--){ 115 | pre(); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /Codeforces Round Problem Solved/Harbour Space Scholarship Contest 2021/B Reverse String.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ---------------------------------------------------- 3 | ---------In the name of ALLAH ---------------------- 4 | ---------------------------------------------------- 5 | * Tried by Aryan Kabir 6 | * CSE, SUB, BD 7 | * 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | typedef unsigned long long int ull; 14 | typedef long long int ll; 15 | typedef long int li; 16 | 17 | typedef pair pii; 18 | 19 | typedef map msi; 20 | typedef map mss; 21 | 22 | typedef vector vi; 23 | typedef vector vll; 24 | typedef vector vb; 25 | typedef vector vs; 26 | 27 | typedef double dbl; 28 | 29 | 30 | #define pb push_back 31 | 32 | #define MAX 1e30 33 | #define MAX1 10^9+7 34 | #define MAX2 10^9+9 35 | 36 | 37 | #define pf printf 38 | #define sc scanf 39 | 40 | #define s1(n) scanf("%d",&n) 41 | #define s2(n1,n2) scanf("%d %d",&n1,&n2) 42 | #define s3(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3) 43 | #define s4(n1,n2,n3,n4) scanf("%d %d %d %d",&n1,&n2,&n3,&n4) 44 | 45 | #define ss1(n) scanf("%lld",&n) 46 | #define ss2(n1,n2) scanf("%lld %lld",&n1,&n2) 47 | #define ss3(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3) 48 | #define ss4(n1,n2,n3,n4) scanf("%lld %lld %lld %lld",&n1,&n2,&n3,&n4) 49 | 50 | #define p1(x) printf("%I64d",x) 51 | #define p2(x,y) printf("%I64d %I64d",x,y) 52 | #define p3(x,y,z) printf("%I64d %I64d %I64d",x,y,z) 53 | 54 | #define fi(i,a,b) for(long long i=a;i<=b;i++) 55 | #define fm(i , a) for(long long i=1;i<=a;i++) 56 | #define fd(i,a,b) for(long long i=b;i>=a;i--) 57 | 58 | #define FOR1(i,n) for(int i=0; i=0; i--) 60 | 61 | #define OUT0(x)cout<<(x)<<" " 62 | #define OUT1(x)cout<<(x)<>(x) 69 | #define IN2(x,y) cin>>(x)>>(y) 70 | #define IN3(x,y,z) cin >>(x)>>(y)>>(z) 71 | 72 | #define clr(x) memset(x,0,sizeof(x)) 73 | #define cln(x) memset(x,-1,sizeof(x)) 74 | 75 | #define HR cout<<"\n-------------------------\n" 76 | #define NL cout<<"\n" 77 | 78 | templatevoid inpA(T arr[], int n){FOR1(i,n){ IN(arr[i]);}} 79 | templatevoid inpV(vector&vec, int n){vec.resize(n);for(int i=0; i>vec[i];} 80 | templatevoid outV(vector&vec){for(int i=0; ivoid sortV(vector&vec){ sort(vec.begin(),vec.end()) ; } 82 | templatevoid rSortV(vector&vec){ sort(vec.begin(),vec.end(), greater());} 83 | templatebool bSearchV(vector&vec,T key){return binary_search(vec.begin(),vec.end(),key);} 84 | 85 | ll arr[500][2]; 86 | void pre(){ 87 | string S,T; 88 | cin>>S>>T; 89 | for(int i=0;i0;i--){ 99 | arr[i][0]=(S[i]==c&&arr[i-1][0]); 100 | } 101 | arr[0][0] = 0; 102 | } 103 | for(int i=0;i>T; 115 | while(T--){ 116 | pre(); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /CoderByte Problem Solved/JavaScript/Find Intersection/FindIntersection.js: -------------------------------------------------------------------------------- 1 | const lines = ["1, 3, 4, 7, 13", "1, 2, 4, 13, 15"]//Input 2 | 3 | const mapArrayToHashTable = items => { 4 | return items.reduce((last, item) => ({...last, [''+item]: item}), {}) 5 | } 6 | 7 | const getHashTable = line => { 8 | const textNumbers = line.split(',') 9 | const numbers = textNumbers.map(number => parseInt(number)) 10 | return mapArrayToHashTable(numbers) 11 | } 12 | 13 | const [firstTable, ...otherTables] = lines.map(getHashTable) 14 | 15 | const result = otherTables.reduce((last, table) => { 16 | const keyObjs = Object.keys(table).map(key => last[key] ? {[key]: last[key]} : {}) 17 | return keyObjs.reduce((last, keyObj) => ({...last, ...keyObj}), {}) 18 | }, firstTable) 19 | 20 | console.log(Object.values(result)) // returns [1,4,13] -------------------------------------------------------------------------------- /GUIDE TO COMPETITIVE PROGRAMMING .docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/GUIDE TO COMPETITIVE PROGRAMMING .docx -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Big Sorting/Main.java: -------------------------------------------------------------------------------- 1 | 2 | import java.io.*; 3 | import java.util.*; 4 | import java.text.*; 5 | import java.math.*; 6 | import java.util.regex.*; 7 | 8 | /* 9 | * ===================== 10 | * => D Y N A M I T E <= 11 | * ===================== 12 | * The Dynamite Group 13 | * By, 14 | * N3o D4rk3r 15 | * https://github.com/n3o-d4rk3r 16 | *====================== 17 | * Java 8 18 | */ 19 | public class Main { 20 | 21 | public static void main(String[] args) { 22 | Scanner in = new Scanner(System.in); 23 | int n = in.nextInt(); 24 | String[] unsorted = new String[n]; 25 | for(int i = 0; i < n; i++) unsorted[i] = in.next(); 26 | 27 | Arrays.sort(unsorted,new Comparator() { 28 | @Override 29 | public int compare(String a, String b) 30 | { 31 | return StringAsIntegerCompare(a,b); 32 | } 33 | }); 34 | 35 | StringBuilder output = new StringBuilder(""); 36 | for(String num : unsorted) 37 | output.append(num+"\n"); 38 | System.out.println(output); 39 | } 40 | 41 | //0 means s1=s2, 1 means s1>s2, -1 means s1 s2.length()) return 1; 45 | if(s1.length() < s2.length()) return -1; 46 | for(int i = 0; i < s1.length(); i++) 47 | { 48 | if((int)s1.charAt(i) > (int)s2.charAt(i)) return 1; 49 | if((int)s1.charAt(i) < (int)s2.charAt(i)) return -1; 50 | } 51 | return 0; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Closest Numbers/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | Scanner input = new Scanner(System.in); 20 | int n = input.nextInt(); 21 | int[] array = new int[n]; 22 | for(int i = 0; i < n; i++) 23 | array[i] = input.nextInt(); 24 | 25 | Arrays.sort(array); 26 | int minAbs = Integer.MAX_VALUE; //Minimum absolute difference 27 | StringBuilder pairs = new StringBuilder(""); 28 | 29 | for(int i = 0; i < n-1; i++) 30 | { 31 | int absDiff; 32 | 33 | if((array[i]<0 && array[i+1]<0)||(array[i]>0 && array[i+1]>0))//both numbers have matching signs 34 | absDiff = Math.abs(array[i] - array[i+1]); //Absolute difference 35 | else 36 | absDiff = Math.abs(array[i]) + Math.abs(array[i+1]); //Absolute difference 37 | 38 | if(absDiff < minAbs)//New minAbs 39 | { 40 | minAbs = absDiff; 41 | pairs = new StringBuilder("");//Empty pairs 42 | pairs.append(array[i]+ " " +array[i+1]+" ");//Add pair 43 | } 44 | else if(absDiff == minAbs)//Multiple minAbs 45 | pairs.append(array[i]+ " " +array[i+1]+" ");//Add pair 46 | } 47 | 48 | System.out.println(pairs); 49 | } 50 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Correctness and the Loop Invariant/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void insertionSort(int[] A){ 19 | for(int i = 1; i < A.length; i++){ 20 | int value = A[i]; 21 | int j = i - 1; 22 | while(j >= 0 && A[j] > value){ 23 | A[j + 1] = A[j]; 24 | j = j - 1; 25 | } 26 | A[j + 1] = value; 27 | } 28 | 29 | printArray(A); 30 | } 31 | 32 | 33 | static void printArray(int[] ar) { 34 | for(int n: ar){ 35 | System.out.print(n+" "); 36 | } 37 | } 38 | public static void main(String[] args) { 39 | Scanner in = new Scanner(System.in); 40 | int n = in.nextInt(); 41 | int[] ar = new int[n]; 42 | for(int i=0;i D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | Scanner input = new Scanner(System.in); 20 | int n = input.nextInt(); 21 | int[] frequencies = new int[100]; 22 | for(int i = 0; i < n; i++) 23 | { 24 | int num = input.nextInt(); 25 | frequencies[num] = frequencies[num] + 1; 26 | } 27 | 28 | for(int i = 0; i < frequencies.length; i++) 29 | { 30 | System.out.print(frequencies[i]+" "); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Counting Sort 2/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | Scanner input = new Scanner(System.in); 20 | int n = input.nextInt(); 21 | int[] frequencies = new int[100]; 22 | for(int i = 0; i < n; i++) 23 | { 24 | int num = input.nextInt(); 25 | frequencies[num] = frequencies[num] + 1; 26 | } 27 | 28 | for(int i = 0; i < frequencies.length; i++) 29 | { 30 | for(int j = 0; j < frequencies[i]; j++) 31 | { 32 | System.out.print(i+" "); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Counting Sort 3/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | Scanner input = new Scanner(System.in); 20 | int n = input.nextInt(); 21 | int[] frequencies = new int[100]; 22 | for(int i = 0; i < n; i++) 23 | { 24 | int num = input.nextInt(); 25 | input.nextLine();//throw away following string 26 | frequencies[num] = frequencies[num] + 1; 27 | } 28 | int sum = 0; 29 | for(int i = 0; i < frequencies.length; i++) 30 | { 31 | sum += frequencies[i]; 32 | System.out.print(sum+" "); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Find the Median/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | Scanner input = new Scanner(System.in); 20 | int n = input.nextInt(); 21 | int[] array = new int[n]; 22 | for(int i = 0; i < n; i++) 23 | array[i] = input.nextInt(); 24 | 25 | Arrays.sort(array); 26 | 27 | System.out.println(array[(n/2)]); 28 | } 29 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Fraudulent Activity Notifications/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | Scanner input = new Scanner(System.in); 20 | int n = input.nextInt(); 21 | int d = input.nextInt(); 22 | int notifications = 0; 23 | Queue queue = new LinkedList<>(); 24 | int[] pastActivity = new int[201]; 25 | 26 | //Wait for d transactions before any notifications 27 | for(int i = 0; i < d; i++) 28 | { 29 | int transaction = input.nextInt(); 30 | queue.offer(transaction); 31 | pastActivity[transaction] = pastActivity[transaction]+1; 32 | } 33 | 34 | for(int i = 0; i < n-d; i++) 35 | { 36 | int newTransaction = input.nextInt(); 37 | 38 | //Check if fraudulent 39 | if(newTransaction >= (2* median(pastActivity, d))) 40 | notifications++; 41 | 42 | int oldestTransaction = queue.poll(); 43 | pastActivity[oldestTransaction] = pastActivity[oldestTransaction]-1; 44 | 45 | //Add the new transaction 46 | queue.offer(newTransaction); 47 | pastActivity[newTransaction] = pastActivity[newTransaction]+1; 48 | } 49 | 50 | System.out.println(notifications); 51 | } 52 | 53 | static double median(int[] array, int elements) 54 | { 55 | int index = 0; 56 | 57 | if(elements % 2 == 0) 58 | { 59 | int counter = (elements / 2); 60 | 61 | while(counter > 0) 62 | { 63 | counter -= array[index]; 64 | index++; 65 | } 66 | index--; 67 | if(counter <= -1) 68 | return index; 69 | else 70 | { 71 | int firstIndex = index; 72 | int secondIndex = index+1; 73 | while(array[secondIndex] == 0) 74 | { 75 | secondIndex++; 76 | } 77 | return (double) (firstIndex + secondIndex) / 2.0; 78 | } 79 | } 80 | else//Find median of odd 81 | { 82 | int counter = (elements / 2); 83 | 84 | while(counter >= 0) 85 | { 86 | counter -= array[index]; index++; 87 | } 88 | return (double) index-1; 89 | } 90 | } 91 | 92 | 93 | static void printArray(int[] array) 94 | { 95 | System.out.println("Array"); 96 | for(int i = 0; i < array.length; i++) 97 | { 98 | if(array[i] > 0) 99 | System.out.println(i+" : "+array[i]); 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Insertion Sort1/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | 8 | /* 9 | * ===================== 10 | * => D Y N A M I T E <= 11 | * ===================== 12 | * The Dynamite Group 13 | * By, 14 | * N3o D4rk3r 15 | * https://github.com/n3o-d4rk3r 16 | *====================== 17 | * Java 8 18 | */ 19 | public class Main { 20 | 21 | 22 | 23 | public static void insertIntoSorted(int[] ar) { 24 | int tmp = ar[ar.length-1]; 25 | for(int i = ar.length-2; i >=0; i--){ 26 | if(tmp >= ar[i]){//Found where it goes 27 | ar[i+1] = tmp; 28 | printArray(ar); 29 | break; 30 | } 31 | ar[i+1] = ar[i];//Shift to the right 32 | printArray(ar); 33 | } 34 | if(tmp < ar[0]){ 35 | ar[0] = tmp; 36 | printArray(ar); 37 | } 38 | 39 | } 40 | 41 | 42 | /* Tail starts here */ 43 | public static void main(String[] args) { 44 | Scanner in = new Scanner(System.in); 45 | int s = in.nextInt(); 46 | int[] ar = new int[s]; 47 | for(int i=0;i D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void insertionSortPart2(int[] ar) 18 | { 19 | for(int i = 1; i < ar.length; i++) 20 | { 21 | for(int j = i; j > 0; j--) 22 | { 23 | if(ar[j-1] <= ar[j])//In the right spot 24 | { 25 | printArray(ar); 26 | break; 27 | } 28 | else//Swap 29 | { 30 | int tmp = ar[j]; 31 | ar[j] = ar[j-1]; 32 | ar[j-1] = tmp; 33 | if(j-1 ==0) printArray(ar); 34 | } 35 | } 36 | } 37 | } 38 | 39 | 40 | 41 | public static void main(String[] args) { 42 | Scanner in = new Scanner(System.in); 43 | int s = in.nextInt(); 44 | int[] ar = new int[s]; 45 | for(int i=0;i D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | 20 | Scanner input = new Scanner(System.in); 21 | int V = input.nextInt(); 22 | int n = input.nextInt(); 23 | 24 | for(int i = 0; i < n; i++) 25 | { 26 | if(input.nextInt() == V) 27 | { 28 | System.out.println(i); 29 | System.exit(0); 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Lily's Homework/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | Scanner input = new Scanner(System.in); 20 | int n = input.nextInt(); 21 | 22 | int sortedSwaps = 0; 23 | int[] homework = new int[n]; 24 | Integer[] homeworkSorted = new Integer[n]; 25 | Map original = new HashMap<>(); 26 | 27 | int sortedReverseSwaps = 0; 28 | int[] homework2ndCopy = new int[n]; 29 | Map original2ndCopy = new HashMap<>(); 30 | 31 | //Initialize our arrays and maps 32 | for(int i = 0; i < n; i++) 33 | { 34 | homeworkSorted[i] = input.nextInt(); 35 | homework[i] = homeworkSorted[i]; 36 | homework2ndCopy[i] = homeworkSorted[i]; 37 | original.put(homework[i],i); 38 | original2ndCopy.put(homework2ndCopy[i],i); 39 | } 40 | 41 | Arrays.sort(homeworkSorted); 42 | 43 | for(int i = 0; i < n; i++) 44 | { 45 | if(homework[i] != homeworkSorted[i]) 46 | { 47 | int tmp = homework[i]; 48 | homework[i] = homework[original.get(homeworkSorted[i])]; 49 | homework[original.get(homeworkSorted[i])] = tmp; 50 | original.put(tmp,original.get(homeworkSorted[i])); 51 | sortedSwaps++; 52 | } 53 | } 54 | 55 | Arrays.sort(homeworkSorted, Collections.reverseOrder()); 56 | 57 | for(int i = 0; i < n; i++) 58 | { 59 | if(homework2ndCopy[i] != homeworkSorted[i]) 60 | { 61 | int tmp = homework2ndCopy[i]; 62 | homework2ndCopy[i] = homework2ndCopy[original.get(homeworkSorted[i])]; 63 | homework2ndCopy[original2ndCopy.get(homeworkSorted[i])] = tmp; 64 | original2ndCopy.put(tmp, original2ndCopy.get(homeworkSorted[i])); 65 | sortedReverseSwaps++; 66 | } 67 | } 68 | System.out.println(Math.min(sortedSwaps,sortedReverseSwaps)); 69 | } 70 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Quicksort 1-Partition/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | Scanner input = new Scanner(System.in); 20 | int n = input.nextInt(); 21 | int pivot = input.nextInt(); 22 | StringBuilder greater = new StringBuilder(""); 23 | for(int i = 1; i < n; i++){ 24 | int num = input.nextInt(); 25 | if(num < pivot) 26 | { 27 | System.out.print(num+" "); 28 | continue; 29 | } 30 | else 31 | greater.append(num+" "); 32 | 33 | } 34 | System.out.print(pivot+" "+greater.toString()); 35 | } 36 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Quicksort 2 - Sorting/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner in = new Scanner(System.in); 19 | int n = in.nextInt(); 20 | int[] ar = new int[n]; 21 | for(int i=0;i= end) 31 | return; 32 | 33 | int wall = partition (array,beg,end); 34 | 35 | quickSort(array,beg,wall-1); 36 | quickSort(array,wall+1,end); 37 | 38 | printArray(array,beg, end); 39 | } 40 | 41 | static int partition(int array[], int beg, int end) 42 | { 43 | int pivot = array[beg]; 44 | List left = new ArrayList<>(); 45 | List right = new ArrayList<>(); 46 | 47 | for(int i = beg+1 ; i <= end; i++) 48 | { 49 | if(array[i] > pivot) 50 | right.add(array[i]); 51 | else 52 | left.add(array[i]); 53 | } 54 | copy(left,array,beg); 55 | int wall = left.size()+beg; 56 | array[wall] = pivot; 57 | copy(right,array,wall+1); 58 | 59 | return beg + left.size(); 60 | } 61 | 62 | static void copy(List list, int array[], int beg) 63 | { 64 | for(int num : list) 65 | { 66 | array[beg++] = num; 67 | } 68 | } 69 | 70 | static void printArray(int[] ar,int beg, int end) 71 | { 72 | for(int i = beg; i <= end;i++) 73 | { 74 | System.out.print(ar[i]+" "); 75 | } 76 | System.out.println(""); 77 | } 78 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Quicksort In-Place/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | Scanner input = new Scanner(System.in); 20 | int n = input.nextInt(); 21 | int ar[] = new int[n]; 22 | for(int i = 0; i < n; i++) 23 | { 24 | ar[i] = input.nextInt(); 25 | } 26 | quicksort(ar,0,ar.length-1); 27 | } 28 | 29 | static void quicksort(int[] array, int beg, int end) 30 | { 31 | if(beg >= end) return; 32 | 33 | int pivot = array[end]; 34 | int wall = beg; 35 | 36 | //Partition with a wall 37 | for(int i = beg; i < end; i++) 38 | { 39 | if(array[i] < pivot) 40 | { 41 | swap(array, i, wall); 42 | wall++; 43 | } 44 | } 45 | 46 | //Place pivot 47 | swap(array, end, wall); 48 | 49 | //Print after partition 50 | printArray(array); 51 | 52 | //Sort left of partition 53 | quicksort(array, beg, wall-1); 54 | 55 | //Sort right of partition 56 | quicksort(array, wall+1, end); 57 | } 58 | 59 | 60 | static void swap(int[] array, int index1, int index2) 61 | { 62 | int tmp = array[index1]; 63 | array[index1] = array[index2]; 64 | array[index2] = tmp; 65 | } 66 | 67 | static void printArray(int[] array) 68 | { 69 | for(int num : array) 70 | { 71 | System.out.print(num+" "); 72 | } 73 | System.out.println(""); 74 | } 75 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/Running Time of Algorithms/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void insertionSort(int[] A){ 19 | int shifts = 0; 20 | for(int i = 1; i < A.length; i++){ 21 | int value = A[i]; 22 | int j = i - 1; 23 | while(j >= 0 && A[j] > value){ 24 | A[j + 1] = A[j]; 25 | j = j - 1; 26 | } 27 | A[j + 1] = value; 28 | shifts += i - (j+1); 29 | } 30 | 31 | //printArray(A); 32 | System.out.println(shifts); 33 | } 34 | 35 | 36 | static void printArray(int[] ar) { 37 | for(int n: ar){ 38 | System.out.print(n+" "); 39 | } 40 | } 41 | public static void main(String[] args) { 42 | Scanner in = new Scanner(System.in); 43 | int n = in.nextInt(); 44 | int[] ar = new int[n]; 45 | for(int i=0;i D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | static int Qswaps = 0; 19 | static int Iswaps = 0; 20 | public static void main(String[] args) { 21 | Scanner input = new Scanner(System.in); 22 | int n = input.nextInt(); 23 | int ar[] = new int[n]; 24 | for(int i = 0; i < n; i++) 25 | { 26 | ar[i] = input.nextInt(); 27 | } 28 | 29 | //Run insertion sort on its own copy 30 | int[] copy = ar.clone(); 31 | insertionSort(copy); 32 | 33 | quicksort(ar,0,ar.length-1); 34 | 35 | System.out.println(Iswaps - Qswaps); 36 | } 37 | 38 | static void quicksort(int[] array, int beg, int end) 39 | { 40 | if(beg >= end) return; 41 | 42 | int pivot = array[end]; 43 | int wall = beg; 44 | 45 | //Partition with a wall 46 | for(int i = beg; i < end; i++) 47 | { 48 | if(array[i] < pivot) 49 | { 50 | swap(array, i, wall); 51 | wall++; 52 | } 53 | } 54 | 55 | //Place pivot 56 | swap(array, end, wall); 57 | 58 | //Sort left of partition 59 | quicksort(array, beg, wall-1); 60 | 61 | //Sort right of partition 62 | quicksort(array, wall+1, end); 63 | } 64 | 65 | 66 | static void swap(int[] array, int index1, int index2) 67 | { 68 | int tmp = array[index1]; 69 | array[index1] = array[index2]; 70 | array[index2] = tmp; 71 | Qswaps++; 72 | } 73 | 74 | static void printArray(int[] array) 75 | { 76 | for(int num : array) 77 | { 78 | System.out.print(num+" "); 79 | } 80 | System.out.println(""); 81 | } 82 | 83 | public static void insertionSort(int[] A){ 84 | for(int i = 0; i < A.length; i++){ 85 | int value = A[i]; 86 | int j = i - 1; 87 | while(j >= 0 && A[j] > value){ 88 | A[j + 1] = A[j]; 89 | j = j - 1; 90 | } 91 | A[j + 1] = value; 92 | Iswaps += i - (j+1); 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Sorting/The Full Counting Sort/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | 18 | public static void main(String[] args) throws IOException { 19 | BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); 20 | int n = Integer.parseInt(in.readLine()); 21 | int[] frequencies = new int[100]; 22 | StringBuilder STDOUTT = new StringBuilder(""); 23 | Map> order = new HashMap<>(); 24 | 25 | for(int i = 0; i < n; i++) 26 | { 27 | String[] tmp = in.readLine().split(" "); 28 | int num = Integer.parseInt(tmp[0]); 29 | 30 | StringBuilder s = new StringBuilder(tmp[1]); 31 | if(i < n/2) s = new StringBuilder("-"); 32 | 33 | if(!order.containsKey(num)) 34 | { 35 | Queue strs = new LinkedList(); 36 | order.put(num, strs); 37 | } 38 | order.get(num).add(s); 39 | 40 | frequencies[num] = frequencies[num] + 1; 41 | } 42 | 43 | for(int i = 0; i < frequencies.length; i++) 44 | { 45 | for(int j = 0; j < frequencies[i]; j++) 46 | { 47 | STDOUTT.append(order.get(i).poll().toString() + " "); 48 | } 49 | } 50 | System.out.print(STDOUTT); 51 | } 52 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Alternating Characters/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int T = input.nextInt(); 20 | input.nextLine(); 21 | 22 | tests: 23 | for(int t = 0; t < T; t++) 24 | { 25 | String s = input.nextLine(); 26 | int deletions = 0; 27 | int currentCount = 1; 28 | for(int i = 1; i < s.length(); i++) 29 | { 30 | if(s.charAt(i) != s.charAt(i-1)) 31 | { 32 | deletions += currentCount - 1; 33 | currentCount = 1; 34 | continue; 35 | } 36 | currentCount++; 37 | } 38 | deletions += currentCount - 1; 39 | System.out.println(deletions); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Anagram/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int T = input.nextInt(); 20 | input.nextLine(); 21 | 22 | tests: 23 | for(int t = 0; t < T; t++) 24 | { 25 | String s = input.nextLine(); 26 | 27 | if(s.length() % 2 == 1) 28 | { 29 | System.out.println(-1); continue tests; 30 | } 31 | 32 | 33 | Map firstHalf = new HashMap<>(); 34 | Map secondHalf = new HashMap<>(); 35 | 36 | for(int i = 0; i < s.length()/2; i++) 37 | { 38 | if(firstHalf.containsKey(s.charAt(i))) 39 | firstHalf.put(s.charAt(i), firstHalf.get(s.charAt(i)) + 1); 40 | else 41 | firstHalf.put(s.charAt(i), 1); 42 | } 43 | 44 | for(int i = s.length()/2; i < s.length(); i++) 45 | { 46 | if(secondHalf.containsKey(s.charAt(i))) 47 | secondHalf.put(s.charAt(i), secondHalf.get(s.charAt(i)) + 1); 48 | else 49 | secondHalf.put(s.charAt(i), 1); 50 | } 51 | int operations = 0; 52 | 53 | for(Map.Entry letter : secondHalf.entrySet()) 54 | { 55 | 56 | int f2 = letter.getValue(); 57 | int f1 = (firstHalf.get(letter.getKey()) != null) ? firstHalf.get(letter.getKey()) : 0; 58 | 59 | if(f2 > f1) 60 | operations += (f2 - f1); 61 | 62 | 63 | } 64 | System.out.println(operations); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Beautiful Binary String/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int n = input.nextInt(); 20 | input.nextLine(); 21 | String s = input.nextLine(); 22 | int switches = 0; 23 | 24 | for(int i = 0; i < s.length()-2; i++) 25 | { 26 | if(s.charAt(i) == '0' && s.charAt(i+1) == '1' && s.charAt(i+2) == '0') 27 | { 28 | switches++; 29 | i += 2; 30 | } 31 | } 32 | System.out.println(switches); 33 | } 34 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Caesar Cipher Encryption/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int n = input.nextInt();input.nextLine(); 20 | String word = input.nextLine(); 21 | int rotation = input.nextInt(); 22 | StringBuilder encryptedWord = new StringBuilder(""); 23 | for(char c : word.toCharArray()) 24 | { 25 | if(c >= 'a' && c <= 'z') 26 | encryptedWord.append((char) ('a'+(((c-'a')+rotation)%26))); 27 | else if(c >= 'A' && c <= 'Z') 28 | encryptedWord.append((char) ('A'+(((c-'A')+rotation)%26))); 29 | else 30 | encryptedWord.append(c); 31 | 32 | } 33 | System.out.println(encryptedWord); 34 | } 35 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Caesar Cipher/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int n = input.nextInt(); 20 | input.nextLine(); 21 | String s = input.nextLine(); 22 | int k = input.nextInt() % 26; 23 | StringBuilder output = new StringBuilder(""); 24 | 25 | for(char letter : s.toCharArray()) 26 | { 27 | if(letter > 64 && letter < 91) 28 | { 29 | char encrypted = (char) (letter+k); 30 | if(encrypted > 90) 31 | { 32 | encrypted = (char) ((encrypted % 90) + 64); 33 | } 34 | output.append(encrypted); 35 | } 36 | else if(letter > 96 && letter < 123) 37 | { 38 | char encrypted = (char) (letter+k); 39 | if(encrypted > 122) 40 | { 41 | encrypted = (char) ((encrypted % 122) + 96); 42 | } 43 | output.append(encrypted); 44 | } 45 | else//Symbol 46 | { 47 | output.append(letter); 48 | } 49 | } 50 | System.out.println(output); 51 | } 52 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/CamelCase/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | /* 8 | * ===================== 9 | * => D Y N A M I T E <= 10 | * ===================== 11 | * The Dynamite Group 12 | * By, 13 | * N3o D4rk3r 14 | * https://github.com/n3o-d4rk3r 15 | *====================== 16 | * Java 8 17 | */ 18 | public class Main { 19 | 20 | public static void main(String[] args) { 21 | Scanner in = new Scanner(System.in); 22 | String s = in.next(); 23 | 24 | if(s.isEmpty()) 25 | { 26 | System.out.println("0"); 27 | System.exit(0); 28 | } 29 | 30 | int words = 1; 31 | 32 | for(char letter : s.toCharArray()) 33 | { 34 | if(letter < 91 && letter > 64 ) 35 | { 36 | words++; 37 | } 38 | } 39 | System.out.println(words); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Funny String/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int T = input.nextInt(); 20 | input.nextLine(); 21 | 22 | tests: 23 | for(int i = 0; i < T; i++) 24 | { 25 | String s = input.nextLine(); 26 | for(int j = 1; j < (s.length()/2)+1; j++) 27 | { 28 | int left = Math.abs(s.charAt(j) - s.charAt(j-1)); 29 | int right = Math.abs(s.charAt(s.length()-1-j) - s.charAt(s.length()-j)); 30 | if( left != right) 31 | { 32 | System.out.println("Not Funny"); 33 | continue tests; 34 | } 35 | } 36 | System.out.println("Funny"); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Game of Thrones-I/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | String s = input.nextLine(); 20 | 21 | Map letters = new HashMap<>(); 22 | for(char c : s.toCharArray()) 23 | { 24 | if(letters.containsKey(c)) 25 | letters.put(c, letters.get(c) + 1); 26 | else 27 | letters.put(c, 1); 28 | } 29 | 30 | int odd = 0; 31 | int even = 0; 32 | for(Integer frequency : letters.values()) 33 | { 34 | if(frequency % 2 == 1) 35 | { 36 | odd++; 37 | continue; 38 | } 39 | 40 | if(frequency % 2 == 0) 41 | even++; 42 | } 43 | 44 | if(odd > 1) 45 | System.out.println("NO"); 46 | else 47 | System.out.println("YES"); 48 | 49 | } 50 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Gemstones/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | public static void main(String[] args) { 17 | Scanner input = new Scanner(System.in); 18 | int n = input.nextInt(); 19 | input.nextLine(); 20 | 21 | Set gemstones = stringToSet(input.nextLine()); 22 | 23 | for(int i=1; i stringToSet(String s) 33 | { 34 | Set set = new HashSet(26); 35 | for (char c : s.toCharArray()) 36 | set.add(Character.valueOf(c)); 37 | return set; 38 | } 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/HackerRank a String/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | /* 8 | * ===================== 9 | * => D Y N A M I T E <= 10 | * ===================== 11 | * The Dynamite Group 12 | * By, 13 | * N3o D4rk3r 14 | * https://github.com/n3o-d4rk3r 15 | *====================== 16 | * Java 8 17 | */ 18 | public class Main { 19 | 20 | public static void main(String[] args) { 21 | Scanner in = new Scanner(System.in); 22 | int q = in.nextInt(); 23 | queries: 24 | for(int a0 = 0; a0 < q; a0++){ 25 | String s = in.next(); 26 | char[] find = "hackerrank".toCharArray(); 27 | int findIndex = 0; 28 | 29 | for(char c : s.toCharArray()) 30 | { 31 | if(find[findIndex] == c) 32 | findIndex++; 33 | 34 | if(findIndex == find.length){ 35 | System.out.println("YES"); 36 | continue queries; 37 | } 38 | 39 | } 40 | System.out.println("NO"); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Making Anagrams/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | String s1 = input.nextLine(); 20 | String s2 = input.nextLine(); 21 | Map s1Frequency = new HashMap<>(); 22 | Map s2Frequency = new HashMap<>(); 23 | int deletions = 0; 24 | 25 | for(int i = 'a'; i <= 'z'; i++) 26 | { 27 | s1Frequency.put((char) i, 0); 28 | s2Frequency.put((char) i, 0); 29 | } 30 | 31 | for(char c : s1.toCharArray()) 32 | s1Frequency.put(c, s1Frequency.get(c) + 1); 33 | 34 | for(char c : s2.toCharArray()) 35 | s2Frequency.put(c, s2Frequency.get(c) + 1); 36 | 37 | for(char letter : s1Frequency.keySet()) 38 | { 39 | int f1 = s1Frequency.get(letter); 40 | int f2 = s2Frequency.get(letter); 41 | 42 | deletions += Math.abs(f1 - f2); 43 | } 44 | 45 | System.out.println(deletions); 46 | } 47 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Mars Exploration/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | /* 8 | * ===================== 9 | * => D Y N A M I T E <= 10 | * ===================== 11 | * The Dynamite Group 12 | * By, 13 | * N3o D4rk3r 14 | * https://github.com/n3o-d4rk3r 15 | *====================== 16 | * Java 8 17 | */ 18 | public class Main { 19 | 20 | public static void main(String[] args) { 21 | Scanner in = new Scanner(System.in); 22 | String S = in.next(); 23 | int count = 0; 24 | int currentPos = 0; 25 | for(char letter : S.toCharArray()) 26 | { 27 | 28 | if(currentPos % 3 == 1) 29 | { 30 | count += (letter != 'O') ? 1 : 0; 31 | } 32 | else 33 | { 34 | count += (letter != 'S') ? 1 : 0; 35 | } 36 | currentPos++; 37 | } 38 | System.out.println(count); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Morgan and/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int t = input.nextInt(); 20 | 21 | for(int a0 = 0; a0 < t; a0++) 22 | { 23 | StringBuilder s1 = new StringBuilder(input.next()); s1.append("z"); 24 | StringBuilder s2 = new StringBuilder(input.next()); s2.append("z"); 25 | StringBuilder output = new StringBuilder(""); 26 | 27 | int i = 0, j = 0; 28 | while(i < s1.length() && j < s2.length()) 29 | { 30 | 31 | if(s1.charAt(i) < s2.charAt(j)) 32 | { 33 | output.append(s1.charAt(i)); 34 | i++; 35 | } 36 | else if(s1.charAt(i) > s2.charAt(j)) 37 | { 38 | output.append(s2.charAt(j)); 39 | j++; 40 | } 41 | 42 | 43 | 44 | 45 | 46 | else 47 | { 48 | if(s1.charAt(i) == 'z'){i++; j++; continue;} 49 | 50 | 51 | int startingI = i; 52 | int startingJ = j; 53 | 54 | while(s1.charAt(i) == s2.charAt(j)) 55 | { 56 | i++; 57 | j++; 58 | if(i >= s1.length() && j >= s2.length()) 59 | { 60 | i = startingI; 61 | j = startingJ; 62 | break; 63 | } 64 | else if(i >= s1.length()) 65 | { 66 | 67 | char prev = s2.charAt(startingJ); 68 | while(s2.charAt(startingJ) <= prev) 69 | { 70 | output.append(s2.charAt(startingJ)); 71 | prev = s2.charAt(startingJ); 72 | startingI++; 73 | } 74 | i = startingI; 75 | j = startingJ; 76 | } 77 | else if(j >= s2.length()) 78 | { 79 | char prev = s1.charAt(startingI); 80 | while(s1.charAt(startingI) <= prev) 81 | { 82 | output.append(s1.charAt(startingI)); 83 | prev = s1.charAt(startingI); 84 | startingI++; 85 | } 86 | i = startingI; 87 | j = startingJ; 88 | } 89 | } 90 | 91 | if(s1.charAt(i) <= s2.charAt(j)) 92 | { 93 | char prev = s1.charAt(startingI); 94 | while(s1.charAt(startingI) <= prev) 95 | { 96 | output.append(s1.charAt(startingI)); 97 | prev = s1.charAt(startingI); 98 | startingI++; 99 | } 100 | i = startingI; 101 | j = startingJ; 102 | } 103 | 104 | 105 | if(s1.charAt(i) > s2.charAt(j)) 106 | { 107 | char prev = s2.charAt(startingJ); 108 | while(s2.charAt(startingJ) <= prev) 109 | { 110 | output.append(s2.charAt(startingJ)); 111 | prev = s2.charAt(startingJ); 112 | startingJ++; 113 | } 114 | i = startingI; 115 | j = startingJ; 116 | } 117 | } 118 | } 119 | 120 | 121 | 122 | while(i < s1.length()) 123 | { 124 | output.append(s1.charAt(i)); 125 | i++; 126 | } 127 | 128 | while(j < s2.length()) 129 | { 130 | output.append(s2.charAt(j)); 131 | j++; 132 | } 133 | 134 | System.out.println(output); 135 | } 136 | } 137 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Palindrome Index/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int n = input.nextInt(); input.nextLine(); 20 | 21 | tests: 22 | for(int t = 0; t < n; t++) 23 | { 24 | 25 | String s = input.nextLine(); 26 | int outputIndex = -1; 27 | boolean removal = false; 28 | 29 | for(int i = 0, j = s.length()-1; i < j; i++, j--) 30 | { 31 | 32 | if(s.charAt(i) != s.charAt(j)) 33 | { 34 | 35 | if(removal) 36 | { 37 | removal = false; 38 | outputIndex = -1; 39 | break; 40 | } 41 | 42 | if(s.charAt(i+1) == s.charAt(j)) 43 | { 44 | removal = true; 45 | outputIndex = i; 46 | i++; 47 | } 48 | else if(s.charAt(i) == s.charAt(j-1)) 49 | { 50 | removal = true; 51 | outputIndex = j; 52 | j--; 53 | } 54 | else 55 | { 56 | removal = false; 57 | outputIndex = -1; 58 | break; 59 | } 60 | } 61 | } 62 | if(outputIndex != -1) 63 | { 64 | System.out.println(outputIndex); continue tests; 65 | } 66 | 67 | 68 | for(int i = 0, j = s.length()-1; i < j; i++, j--) 69 | { 70 | 71 | if(s.charAt(i) != s.charAt(j)) 72 | { 73 | 74 | if(removal) 75 | { 76 | System.out.println(-1); continue tests; 77 | } 78 | 79 | if(s.charAt(i) == s.charAt(j-1)) 80 | { 81 | removal = true; 82 | outputIndex = j; 83 | j--; 84 | } 85 | else if(s.charAt(i+1) == s.charAt(j)) 86 | { 87 | removal = true; 88 | outputIndex = i; 89 | i++; 90 | } 91 | else 92 | { 93 | System.out.println(-1); continue tests; 94 | } 95 | } 96 | } 97 | System.out.println(outputIndex); 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Pangrams/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | String s = input.nextLine(); 20 | 21 | String[] alphabet = new String[]{"A","B","C","D","E", 22 | "F","G","H","I","J", 23 | "K","L","M","N","O", 24 | "P","Q","R","S","T", 25 | "U","V","W","X","Y","Z"}; 26 | Set pangramTracker = new HashSet<>(Arrays.asList(alphabet)); 27 | 28 | for(char letter : s.toCharArray()) 29 | { 30 | if(pangramTracker.contains(Character.toString(letter).toUpperCase())) 31 | { 32 | pangramTracker.remove(Character.toString(letter).toUpperCase()); 33 | } 34 | 35 | if(pangramTracker.isEmpty())//Our tracker is empty meaning we have see every letter 36 | { 37 | System.out.println("pangram"); 38 | System.exit(0); 39 | } 40 | } 41 | 42 | //We never saw every letter of the alphabet 43 | System.out.println("not pangram"); 44 | } 45 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Richie Rich/Main.java: -------------------------------------------------------------------------------- 1 | package hackerrank; 2 | 3 | import java.util.Scanner; 4 | 5 | /* 6 | * ===================== 7 | * => D Y N A M I T E <= 8 | * ===================== 9 | * The Dynamite Group 10 | * By, 11 | * N3o D4rk3r 12 | * https://github.com/n3o-d4rk3r 13 | *====================== 14 | * Java 8 15 | */ 16 | public class Main { 17 | private static String largestPalindrome(String number, int k) { 18 | char[] chars = number.toCharArray(); 19 | int minChange = 0; 20 | for (int i = 0, j = chars.length - 1; i < j; i++, j--) { 21 | if (chars[i] != chars[j]) { 22 | minChange++; 23 | } 24 | } 25 | if (minChange > k) { 26 | return "-1"; 27 | } 28 | int changeBoth = k - minChange; 29 | int i = 0; 30 | int j = chars.length - 1; 31 | for (; i <= j; i++, j--) { 32 | if (chars[i] != chars[j]) { 33 | char maxChar = (char) Math.max(chars[i], chars[j]); 34 | if (maxChar != '9' && changeBoth - 1 >= 0) { 35 | chars[i] = '9'; 36 | chars[j] = '9'; 37 | changeBoth--; 38 | } else { 39 | chars[i] = maxChar; 40 | chars[j] = maxChar; 41 | minChange--; 42 | } 43 | } else { 44 | char maxChar = (char) Math.max(chars[i], chars[j]); 45 | if (maxChar != '9' && changeBoth - 2 >= 0) { 46 | chars[i] = '9'; 47 | chars[j] = '9'; 48 | changeBoth -= 2; 49 | } 50 | } 51 | } 52 | if (changeBoth != 0 && i - 1 == j + 1) { 53 | chars[i - 1] = '9'; 54 | } 55 | String palindrome = new String(chars); 56 | return palindrome; 57 | } 58 | 59 | public static void main(String[] args) { 60 | Scanner in = new Scanner(System.in); 61 | int n = in.nextInt(); 62 | int k = in.nextInt(); 63 | String number = in.next(); 64 | System.out.println(largestPalindrome(number, k)); 65 | } 66 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Separate the Numbers/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | /* 4 | * ===================== 5 | * => D Y N A M I T E <= 6 | * ===================== 7 | * The Dynamite Group 8 | * By, 9 | * N3o D4rk3r 10 | * https://github.com/n3o-d4rk3r 11 | *====================== 12 | * Java 8 13 | */ 14 | public class Main { 15 | public static void main(String[] args) { 16 | Scanner sc = new Scanner(System.in); 17 | 18 | int q = sc.nextInt(); 19 | for (int tc = 0; tc < q; tc++) { 20 | String s = sc.next(); 21 | 22 | long result = solve(s); 23 | System.out.println(result > 0 ? "YES " + result : "NO"); 24 | } 25 | 26 | sc.close(); 27 | } 28 | 29 | static long solve(String s) { 30 | if (s.charAt(0) == '0') { 31 | return -1; 32 | } 33 | 34 | for (int length = 1; length * 2 <= s.length(); length++) { 35 | long firstNumber = Long.parseLong(s.substring(0, length)); 36 | 37 | StringBuilder sequence = new StringBuilder(); 38 | long number = firstNumber; 39 | while (sequence.length() < s.length()) { 40 | sequence.append(number); 41 | number++; 42 | } 43 | if (sequence.toString().equals(s)) { 44 | return firstNumber; 45 | } 46 | } 47 | return -1; 48 | } 49 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Sherlock and Valid String/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | String s = input.nextLine(); 20 | 21 | Map frequencies = new HashMap<>(); 22 | 23 | for(char letter : s.toCharArray()) 24 | { 25 | if(frequencies.containsKey(letter)) 26 | frequencies.put(letter, frequencies.get(letter) + 1); 27 | else 28 | frequencies.put(letter, 1); 29 | } 30 | 31 | 32 | 33 | Set st = new HashSet<>(); 34 | for(int freq : frequencies.values()) 35 | { 36 | st.add(freq); 37 | } 38 | 39 | if(st.size() > 2) 40 | System.out.println("NO"); 41 | else if(st.size() == 1) 42 | System.out.println("YES"); 43 | else 44 | { 45 | int f1 = 0; 46 | int f2 = 0; 47 | int f1Count = 0; 48 | int f2Count = 0; 49 | int i = 0; 50 | for(int n : st) 51 | { 52 | if(i == 0) f1 = n; 53 | else f2 = n; 54 | i++; 55 | } 56 | 57 | for(int freq : frequencies.values()) 58 | { 59 | if(freq == f1) f1Count++; 60 | if(freq == f2) f2Count++; 61 | } 62 | 63 | 64 | 65 | if((f1 == 1 && f1Count == 1 ) || (f2 == 1 && f2Count == 1 )) 66 | System.out.println("YES"); 67 | else if ((Math.abs(f1 - f2) == 1) && (f1Count == 1 || f2Count == 1)) 68 | System.out.println("YES"); 69 | else 70 | System.out.println("NO"); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/String Construction/String Construction-HackerRank.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | /* 8 | * ===================== 9 | * => D Y N A M I T E <= 10 | * ===================== 11 | * The Dynamite Group 12 | * By, 13 | * N3o D4rk3r 14 | * https://github.com/n3o-d4rk3r 15 | *====================== 16 | * Java 8 17 | */ 18 | public class Main { 19 | 20 | public static void main(String[] args) { 21 | Scanner in = new Scanner(System.in); 22 | int n = in.nextInt(); 23 | for(int a0 = 0; a0 < n; a0++){ 24 | String s = in.next(); 25 | 26 | Set uniqueChars = new HashSet<>(); 27 | for(char c : s.toCharArray()) 28 | { 29 | uniqueChars.add(c); 30 | } 31 | System.out.println(uniqueChars.size()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Strong Password/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | /* 4 | * ===================== 5 | * => D Y N A M I T E <= 6 | * ===================== 7 | * The Dynamite Group 8 | * By, 9 | * N3o D4rk3r 10 | * https://github.com/n3o-d4rk3r 11 | *====================== 12 | * Java 8 13 | */ 14 | public class Main { 15 | static final String SPECIAL_CHARACTERS = "!@#$%^&*()-+"; 16 | 17 | public static void main(String[] args) { 18 | Scanner sc = new Scanner(System.in); 19 | 20 | sc.nextInt(); 21 | String password = sc.next(); 22 | System.out.println(solve(password)); 23 | 24 | sc.close(); 25 | } 26 | 27 | static int solve(String password) { 28 | int addNum = 0; 29 | if (!password.chars().anyMatch(Character::isDigit)) { 30 | addNum++; 31 | } 32 | if (!password.chars().anyMatch(Character::isLowerCase)) { 33 | addNum++; 34 | } 35 | if (!password.chars().anyMatch(Character::isUpperCase)) { 36 | addNum++; 37 | } 38 | if (!password.chars().anyMatch(ch -> SPECIAL_CHARACTERS.indexOf((char) ch) >= 0)) { 39 | addNum++; 40 | } 41 | addNum = Math.max(addNum, 6 - password.length()); 42 | 43 | return addNum; 44 | } 45 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Super Reduced String/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | String inputString = input.nextLine(); 20 | StringBuilder lastOutput = new StringBuilder(inputString); 21 | 22 | 23 | while(true) 24 | { 25 | StringBuilder currentOutput = new StringBuilder(""); 26 | String s = lastOutput.toString(); 27 | char past = s.charAt(0); 28 | int count = 0; 29 | for(int i = 0; i < s.length(); i++) 30 | { 31 | char current = s.charAt(i); 32 | 33 | if(past == current) 34 | count += 1; 35 | else if (count == 1) 36 | { 37 | currentOutput.append(past); 38 | count = 1; 39 | } 40 | else 41 | count = 1; 42 | 43 | if(count == 2) 44 | count = 0; 45 | 46 | past = current; 47 | } 48 | 49 | if(count == 1) 50 | currentOutput.append(s.charAt(s.length()-1)); 51 | 52 | 53 | if(currentOutput.toString().equals("")) 54 | { 55 | System.out.println("Empty String"); 56 | System.exit(0); 57 | } 58 | 59 | 60 | if(currentOutput.toString().equals(lastOutput.toString())) 61 | break; 62 | else 63 | lastOutput = new StringBuilder(currentOutput.toString()); 64 | } 65 | 66 | System.out.println(lastOutput); 67 | } 68 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/The Love-Letter Mystery/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | /* 4 | * ===================== 5 | * => D Y N A M I T E <= 6 | * ===================== 7 | * The Dynamite Group 8 | * By, 9 | * N3o D4rk3r 10 | * https://github.com/n3o-d4rk3r 11 | *====================== 12 | * Java 8 13 | */ 14 | public class Main { 15 | 16 | public static void main(String[] args) { 17 | Scanner input = new Scanner(System.in); 18 | int T = input.nextInt(); 19 | input.nextLine(); 20 | 21 | tests: 22 | for(int t = 0; t < T; t++) 23 | { 24 | String s = input.nextLine(); 25 | int operationsPerformed = 0; 26 | int i = 0; 27 | int j = s.length() - 1; 28 | while(i < j) 29 | { 30 | operationsPerformed += Math.abs(s.charAt(i) - s.charAt(j)); 31 | i++; 32 | j--; 33 | } 34 | System.out.println(operationsPerformed); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Two Characters/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | /* 8 | * ===================== 9 | * => D Y N A M I T E <= 10 | * ===================== 11 | * The Dynamite Group 12 | * By, 13 | * N3o D4rk3r 14 | * https://github.com/n3o-d4rk3r 15 | *====================== 16 | * Java 8 17 | */ 18 | public class Main { 19 | 20 | public static void main(String[] args) { 21 | Scanner in = new Scanner(System.in); 22 | int len = in.nextInt(); 23 | String s = in.next(); 24 | int maxPattern = 0; 25 | 26 | if(s.length() == 1) 27 | { 28 | System.out.println(maxPattern); 29 | System.exit(0); 30 | } 31 | 32 | //Loop through all letter pairs 33 | for(int i = 0; i < 26; i++) 34 | { 35 | nextLetter: 36 | for(int j = i + 1; j < 26; j++) 37 | { 38 | char one = (char) ('a' + i); 39 | char two = (char) ('a' + j); 40 | char lastSeen = '\u0000'; 41 | int patternLength = 0; 42 | 43 | for(char letter : s.toCharArray()) 44 | { 45 | if(letter == one || letter == two) 46 | { 47 | if(letter == lastSeen) 48 | { 49 | continue nextLetter; 50 | } 51 | //Not a duplicate 52 | patternLength++; 53 | lastSeen = letter; 54 | } 55 | } 56 | 57 | maxPattern = (patternLength > maxPattern) ? patternLength : maxPattern; 58 | 59 | } 60 | } 61 | 62 | System.out.println(maxPattern); 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Two Strings/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int pairs = input.nextInt(); input.nextLine(); 20 | 21 | tests: 22 | for(int t = 0; t < pairs; t++) 23 | { 24 | String a = input.nextLine(); 25 | String b = input.nextLine(); 26 | 27 | Set aLetterSet = new HashSet<>(); 28 | Set bLetterSet = new HashSet<>(); 29 | 30 | for(int i = 0; i < a.length(); i++) 31 | aLetterSet.add(a.charAt(i)); 32 | 33 | for(int i = 0; i < b.length(); i++) 34 | bLetterSet.add(b.charAt(i)); 35 | aLetterSet.retainAll(bLetterSet); 36 | 37 | if(aLetterSet.size() > 0) 38 | System.out.println("YES"); 39 | else 40 | System.out.println("NO"); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Strings/Weighted Uniform Strings/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | /* 7 | * ===================== 8 | * => D Y N A M I T E <= 9 | * ===================== 10 | * The Dynamite Group 11 | * By, 12 | * N3o D4rk3r 13 | * https://github.com/n3o-d4rk3r 14 | *====================== 15 | * Java 8 16 | */ 17 | public class Main { 18 | 19 | public static void main(String[] args) { 20 | Scanner in = new Scanner(System.in); 21 | String s = in.next(); 22 | int n = in.nextInt(); 23 | 24 | Set weights = new HashSet<>(); 25 | 26 | int currentWeight = 0; 27 | char prevLetter = ' '; 28 | for(char letter : s.toCharArray()) 29 | { 30 | if(letter != prevLetter) 31 | currentWeight = letter - 'a' + 1; 32 | else 33 | currentWeight += letter - 'a' + 1; 34 | 35 | prevLetter = letter; 36 | weights.add(currentWeight); 37 | } 38 | 39 | for(int a0 = 0; a0 < n; a0++){ 40 | int x = in.nextInt(); 41 | 42 | if(weights.contains(x)) 43 | System.out.println("Yes"); 44 | else 45 | System.out.println("No"); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Warmup/A Very Big Sum/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int n = input.nextInt(); 20 | long sum = 0; 21 | for(int i = n; i>0; i--) 22 | { 23 | sum += input.nextInt(); 24 | } 25 | System.out.println(sum); 26 | } 27 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Warmup/Birthday Cake Candles/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | /* 8 | * ===================== 9 | * => D Y N A M I T E <= 10 | * ===================== 11 | * The Dynamite Group 12 | * By, 13 | * N3o D4rk3r 14 | * https://github.com/n3o-d4rk3r 15 | *====================== 16 | * Java 8 17 | */ 18 | public class Main { 19 | 20 | public static void main(String[] args) { 21 | Scanner in = new Scanner(System.in); 22 | int n = in.nextInt(); 23 | int tallest = 0; 24 | int frequency = 0; 25 | 26 | 27 | for(int i=0; i < n; i++){ 28 | int height = in.nextInt(); 29 | 30 | if(height > tallest){ 31 | tallest = height; 32 | frequency = 1; 33 | } 34 | else if(height == tallest) frequency++; 35 | } 36 | System.out.println(frequency); 37 | } 38 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Warmup/Compare the Triplets/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | /* 8 | * ===================== 9 | * => D Y N A M I T E <= 10 | * ===================== 11 | * The Dynamite Group 12 | * By, 13 | * N3o D4rk3r 14 | * https://github.com/n3o-d4rk3r 15 | *====================== 16 | * Java 8 17 | */ 18 | public class Main { 19 | 20 | public static void main(String[] args) { 21 | Scanner in = new Scanner(System.in); 22 | int a0 = in.nextInt(); 23 | int a1 = in.nextInt(); 24 | int a2 = in.nextInt(); 25 | int b0 = in.nextInt(); 26 | int b1 = in.nextInt(); 27 | int b2 = in.nextInt(); 28 | 29 | int alice = ((a0 > b0)?1:0) + ((a1 > b1)?1:0) + ((a2 > b2)?1:0); 30 | int bob = ((b0 > a0)?1:0) + ((b1 > a1)?1:0) + ((b2 > a2)?1:0); 31 | 32 | 33 | System.out.println(alice + " " + bob); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Warmup/Diagonal Difference/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int n = input.nextInt(); 20 | 21 | int leftDiagonal = input.nextInt(); 22 | int rightDiagonal = 0; 23 | 24 | for(int i = 1; i D Y N A M I T E <= 10 | * ===================== 11 | * The Dynamite Group 12 | * By, 13 | * N3o D4rk3r 14 | * https://github.com/n3o-d4rk3r 15 | *====================== 16 | * Java 8 17 | */ 18 | public class Main { 19 | 20 | public static void main(String[] args) { 21 | Scanner in = new Scanner(System.in); 22 | 23 | long min = Long.MAX_VALUE; 24 | long max = 0; 25 | long sum = 0; 26 | for(int i=0; i<5; i++) 27 | { 28 | long curr = in.nextLong(); 29 | if(max < curr) 30 | { 31 | max = curr; 32 | } 33 | if(min > curr) 34 | { 35 | min = curr; 36 | } 37 | 38 | sum += curr; 39 | } 40 | long minSum = sum - max; 41 | long maxSum = sum - min; 42 | System.out.println(minSum + " " + maxSum); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Warmup/Plus Minus/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int n = input.nextInt(); 20 | 21 | double positive = 0; 22 | double negative = 0; 23 | double zero = 0; 24 | 25 | for(int i = 0; i0 ? 1:0; 29 | negative += value<0 ? 1:0; 30 | zero += value==0 ? 1:0; 31 | } 32 | System.out.println(positive/n); 33 | System.out.println(negative/n); 34 | System.out.println(zero/n); 35 | } 36 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Warmup/Simple Array Sum/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | /* 7 | * ===================== 8 | * => D Y N A M I T E <= 9 | * ===================== 10 | * The Dynamite Group 11 | * By, 12 | * N3o D4rk3r 13 | * https://github.com/n3o-d4rk3r 14 | *====================== 15 | * Java 7 16 | */ 17 | public class Main { 18 | 19 | public static void main(String[] args) { 20 | Scanner in = new Scanner(System.in); 21 | int n = in.nextInt(); 22 | int sum = 0; 23 | for(int arr_i=0; arr_i < n; arr_i++){ 24 | sum += in.nextInt(); 25 | } 26 | System.out.println(sum); 27 | } 28 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Warmup/Solve Me First/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | /* 8 | * ===================== 9 | * => D Y N A M I T E <= 10 | * ===================== 11 | * The Dynamite Group 12 | * By, 13 | * N3o D4rk3r 14 | * https://github.com/n3o-d4rk3r 15 | *====================== 16 | * Java 7 17 | */ 18 | public class Main { 19 | 20 | 21 | static int solveMeFirst(int a, int b) { 22 | 23 | return a+b; 24 | } 25 | 26 | 27 | public static void main(String[] args) { 28 | Scanner in = new Scanner(System.in); 29 | int a; 30 | a = in.nextInt(); 31 | int b; 32 | b = in.nextInt(); 33 | int sum; 34 | sum = solveMeFirst(a, b); 35 | System.out.println(sum); 36 | } 37 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Warmup/Staircase/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | int n = input.nextInt(); 20 | 21 | StringBuilder stair = new StringBuilder(""); 22 | 23 | for(int i = 0; i < n; i++) 24 | { 25 | stair.append(" "); 26 | } 27 | 28 | for(int i = 1; i< n+1; i++) 29 | { 30 | stair.setCharAt(n-i,'#'); 31 | System.out.println(stair); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /HackerRank Online Judge Problem Solve-Java/Algorithms/Warmup/Time Conversion/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | /* 5 | * ===================== 6 | * => D Y N A M I T E <= 7 | * ===================== 8 | * The Dynamite Group 9 | * By, 10 | * N3o D4rk3r 11 | * https://github.com/n3o-d4rk3r 12 | *====================== 13 | * Java 8 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | Scanner input = new Scanner(System.in); 19 | String time = input.nextLine(); 20 | int hour = Integer.parseInt(time.substring(0,2)); 21 | int minute = Integer.parseInt(time.substring(3,5)); 22 | int second = Integer.parseInt(time.substring(6,8)); 23 | String meridiem = time.substring(8,10); 24 | 25 | hour += ((meridiem.equals("PM") && hour != 12)?12:0); 26 | hour -= ((meridiem.equals("AM") && hour == 12)?12:0); 27 | 28 | System.out.println(String.format("%02d",hour) + ":" + String.format("%02d",minute) + ":" + String.format("%02d",second)); 29 | } 30 | } -------------------------------------------------------------------------------- /ICPC-Questiom-and-Answer-Using-CPP/Asia West Continent Championship - 2019/Problemset - Asia West Continent Championship - 2019.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n3o-d4rk3r/Competitive-Programming-Reference-Bangla/3a1655eeb4490f64db7fe691c93fa123cf72b9d7/ICPC-Questiom-and-Answer-Using-CPP/Asia West Continent Championship - 2019/Problemset - Asia West Continent Championship - 2019.pdf -------------------------------------------------------------------------------- /ICPC-Questiom-and-Answer-Using-CPP/ICPC Challenge 2021 Marathon (powered by Huawei)/index.txt: -------------------------------------------------------------------------------- 1 | Hello -------------------------------------------------------------------------------- /ICPC-Questiom-and-Answer-Using-CPP/ICPC Dhaka Regional 2020 Online Preliminary Contest - Hosted by CSE, DU/J. COVID-19.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | /// Moon 8 | /// Kabir 9 | /// Mazharul 10 | 11 | long long n, x, people = 1; 12 | 13 | 14 | cin>>n; 15 | 16 | x = n / 6; 17 | 18 | cout< 2 | using namespace std; 3 | /* 4 | * SUB-Subsequence 5 | * Team Member: 6 | * Aryan Kabir 7 | * Nymul Islam Moon 8 | * Majharul Islam 9 | * 10 | */ 11 | int main() 12 | { 13 | 14 | cout<<"Welcome to ICPC Dhaka Regional Online Preliminary Contest, 2019\n"; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /ICPC-Questiom-and-Answer-Using-CPP/Mock of ICPC Dhaka Regional 2020 Online Preliminary/B. Good Things Come to Those Who Wait.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | /* 5 | * SUB-Subsequence 6 | * Team Member: 7 | * Aryan Kabir 8 | * Nymul Islam Moon 9 | * Majharul Islam 10 | * 11 | */ 12 | int main() 13 | { 14 | long long n, t, x; 15 | 16 | 17 | cin>>t; 18 | long long j = 1; 19 | while(t--){ 20 | cin>>n; 21 | vector arr; 22 | for(long long i = 0; i < n; i++){ 23 | cin>>x; 24 | arr.push_back(x); 25 | } 26 | 27 | if(n == 1){ 28 | cout<<"Case "< 2 | using namespace std; 3 | 4 | /* 5 | * SUB-Subsequence 6 | * Team Member: 7 | * Aryan Kabir 8 | * Nymul Islam Moon 9 | * Majharul Islam 10 | * 11 | */ 12 | int main() 13 | { 14 | int sidea, sideb, sidec; 15 | 16 | cin>>sidea>>sideb>>sidec; 17 | 18 | if(sidea==sideb && sideb==sidec) 19 | { 20 | cout<<"Equilateral Triangle"< 2 | using namespace std; 3 | 4 | /* 5 | Team: SUB-SUBSequence 6 | Aryan Kabir 7 | */ 8 | 9 | int main() 10 | { 11 | int d, r, t, cndls = 0, crt = 0; 12 | cin>>d>>r>>t; 13 | for(int age=1;age<=2000;age++) 14 | { 15 | if(age >= 4) cndls+=age, crt += age; 16 | if(age-d >= 3) cndls+=age-d; 17 | if(r+t == cndls) { 18 | 19 | cout< 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Virtual-Judge-Problem-Solved-SUB-CONTEST/A+B Problem(SUB-CONTEST-01).c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Antineo 4 | // https://facebook.com/ictd.kabir 5 | 6 | int main() 7 | { 8 | int a, b; 9 | scanf("%d%d", &a,&b); 10 | printf("%d\n",a+b); 11 | 12 | 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Virtual-Judge-Problem-Solved-SUB-CONTEST/Calculate Desired Grade Point.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | Author: Aryan Kabir 5 | Id : UG02-53-20-001 6 | 7 | Step by Step: 8 | 9 | Include the required headers in the answer program. 10 | Declare the main function in the program. 11 | Declare variables of appropriate datatypes. 12 | Prompt the user to enter the desired CGPA. 13 | Accept the input and store it in a variable. 14 | Prompt the user to enter the total number of courses. 15 | Accept the input and store it in a variable. 16 | Prompt the user to enter the credit per course. 17 | Accept the input and store it in a variable. 18 | Calculate the total credits. 19 | Calculate the grade point by multiplying CGPA with total credits. 20 | Display the output to the user. 21 | */ 22 | 23 | 24 | int main() 25 | { 26 | float grade_point=0.0f ; 27 | int number_of_courses; 28 | int credits; 29 | int total_credits; 30 | float cgpa=0.0f; 31 | printf("Enter the Required CGPA:"); 32 | scanf("%f", &cgpa); 33 | printf("Enter the Total Number of Courses:"); 34 | scanf("%d", &number_of_courses); 35 | printf("Enter the Credit Per Course:"); 36 | 37 | scanf("%d", &credits); 38 | total_credits = number_of_courses*credits; 39 | printf("Total Credits = %d\n", total_credits); 40 | grade_point = cgpa*total_credits; 41 | printf("Desired Grade Point = %f", grade_point); 42 | 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /Virtual-Judge-Problem-Solved-SUB-CONTEST/R2 Problem(SUB-CONTEST-01).c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Aryan Kabir 4 | // https://facebook.com/ictd.kabir 5 | 6 | int main() 7 | 8 | { 9 | int r1,r2,S; 10 | scanf("%d%d",&r1,&S); 11 | r2=((2*S)-r1); 12 | printf("%d\n",r2 ); 13 | return 0; 14 | 15 | 16 | } -------------------------------------------------------------------------------- /Virtual-Judge-Problem-Solved-SUB-CONTEST/R2 Problem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Aryan Kabir 5 | // https://facebook.com/ictd.kabir 6 | 7 | int main() 8 | 9 | { 10 | int r1,r2,S; 11 | cin>>r1>>S; 12 | 13 | r2=((2*S)-r1); 14 | cout< 2 | using namespace std; 3 | 4 | /* 5 | * SUB-Subsequence 6 | * Team Member: 7 | * Aryan Kabir 8 | * Nymul Islam Moon 9 | * Majharul Islam 10 | */ 11 | int main() 12 | { 13 | int sidea, sideb, sidec; 14 | cin>>sidea>>sideb>>sidec; 15 | 16 | if(sidea==sideb && sideb==sidec) 17 | { 18 | cout<<"Equilateral Triangle"<