You are on page 1of 3

super reduced string:

import java.util.Scanner; public class RemoveDuplicateLetters { public static void


main(String[] args) { Scanner scanner = new Scanner(System.in); String str =
scanner.next(); for (int i = 1; i < str.length(); i++) { if (str.charAt(i) ==
str.charAt(i-1)) { str = str.substring(0, i-1) + str.substring(i+1); i = 0; } } if
(str.length() == 0) { System.out.println("Empty String"); } else
{ System.out.println (str); } } }

sum of 3&5 multiples

#include <iostream>

using namespace std;

int main(){
int t;
cin >> t;
for(int a0 = 0; a0 < t; a0++){
int n;
cin >> n;

long a=0, b=0, d=0;


a = (n - 1) / 3;
b = (n - 1) / 5;
d = (n - 1) / 15;

long c = 3 * a * (a + 1)/2 + 5 * b * (b + 1)/2 - 15 * d * (d + 1)/2;

cout << c << endl;


}
return 0;
}

binary 1's:

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {

/* Enter your code here. Read input from STDIN. Print output to STDOUT */
long int n=0,a[100],c=0,i=0;
int count=0;
scanf("%li",&n);
if(n>0)
{
for(i=0;n!=0;i++)
{
a[i]=n%2;
n=n/2;
}
}
c=i;
for(i=c-1;i>=0;i--)
{
if(a[i]==1)
{
count++;
}
}
printf("%d\n",count);
return 0;
}

is binary:
n=input()
n1=n.replace('0',"")
n2=n1.replace('1',"")
if(n2==""):
print("Yes")
else:
print("No")

hello ACM:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
switch(printf("Hello ACM ICPC !!!\n"))
{
}
switch(printf("Hello ACM ICPC !!!\n"))
{
}
switch(printf("Hello ACM ICPC !!!\n"))
{
}

/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}

number subtraction:

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {

int n,a,b,c,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d",&a,&b);
c=a-b;
printf("%d\n",c);
}
return 0;
}

number addition:

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {

int n,a,b,c,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d",&a,&b);
c=a+b;
printf("%d\n",c);
}
return 0;
}

special series sum:

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main()
{
long int n,a[10000],i,j,t,sum=0,k;
scanf("%ld",&n);
a[0]=1;
for(i=2,j=1,t=0;i<=n,j<=n,t<n;i++,j++,t++)
{
a[j]=a[t]+i;
sum=sum+a[t];
}
printf("%ld\n",sum);
return 0;
}

You might also like