JXNVCE ALGO-LOG YouJin Jung

BOJ-2460

#include <iostream>

using namespace std;

int main() {
    int a, b;
    int total = 0, big = 0;
    for (int i = 1; i <= 9; i++) {
        cin >> a >> b;
        total += -a + b;
        if (total > big) big = total;
    }
    cout << big;
}

BOJ-2908

#include <iostream>

using namespace std;

int func(int a) {
	int ans = 0;
	for(int i=a;i;i/=10) {
		ans = ans*10 + i%10;
  }	
	return ans;
}

int main() {
	int a,b;
	cin >> a >> b;
	if (a>b) {
    cout << func(a) << endl;
  }
  else {
    cout << func(b) << endl;
  }
  return 0;
}

BOJ-2588

#include <iostream>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    int X, Y, Z, W;
    X = A*(B%10);
    Y = A*((B/10)%10);
    Z = A*(B/100);
    W = X+Y*10+Z*100;
    cout << X << endl << Y << endl << Z << endl << W << endl;
    return 0;
}

GFG MAXIMUM SUM INCREASING SUBSEQUENCE

#include <bits/stdc++.h>

using namespace std;
  
int maxSumIS(int arr[], int n) { 
    int i, j, max = 0; 
    int msis[n]; 
  
    for ( i = 0; i < n; i++ ) {
        msis[i] = arr[i]; 
    }

    for ( i = 1; i < n; i++ ) {
        for ( j = 0; j < i; j++ ) {
            if (arr[i] > arr[j] && msis[i] < msis[j] + arr[i]) msis[i] = msis[j] + arr[i];
         }
    }
  
    for ( i = 0; i < n; i++ ) {
        if ( max < msis[i] ) max = msis[i]; 
    }
  
    return max; 
} 
  
int main()  { 
    int arr[] = {1, 101, 2, 3, 100, 4, 5}; 
    int n = sizeof(arr)/sizeof(arr[0]); 
    cout << "Sum of maximum sum increasing subsequence is " << maxSumIS( arr, n ) << endl; 
    return 0; 
} 

GFG FIND AN ELEMENT THAT APPEARS ONCE

#include <bits/stdc++.h>

using namespace std;
 
int getSingle(int arr[], int n) {
    int ones = 0, twos = 0;
    int common_bit_mask;

    for (int i = 0; i < n; i++) {
        twos = twos | (ones & arr[i]);
        ones = ones ^ arr[i];
        common_bit_mask = ~(ones & twos);
        ones &= common_bit_mask;
        twos &= common_bit_mask;
        printf (" %d %d n", ones, twos);
    }
 
    return ones;
}
 
int main() {
    int arr[] = { 3, 3, 2, 3 };
    int n = sizeof(arr) / sizeof(arr[0]);
    cout << "The element with single occurrence is  " << getSingle(arr, n);
    return 0;
}