Solution
#include <stdio.h>
const double pi=3.141;
int main ()
{
int r,s;
scanf ("%d%d",&r,&s);
if ((pi*r*r)>(s*s))
{
printf ("I prefer centre 1");
}
else
{
printf ("I prefer centre 2");
}
return 0;
}
For python program visit the link given below.This blog is to help for the programmers to learn the programs and not to demotivate any people .Our intention is to make the learners to learn the code easily.
4 4
I prefer centre 1
4 8
I prefer centre 2
2
4
5
25
t28lkj
tlkj
p2r66o@gram84iz./@@@@@@@@@@@
programiz
welcome
7
input
5
Input:
2
2
1 2
0 0
3
3 3
0 0
0 3
Output:
3
0
Solution:
#include<stdio.h>
int main()
{
int T,i,j;
scanf("%d",&T);
int p[40][2];
int N;
int out[T];
for(i=0;i<T;i++)
{
out[i] = 0;
scanf("%d",&N);
for(j=0;j<N;j++)
{
scanf("%d %d",&p[j][0],&p[j][1]);
out[i] = (out[i]^(j+1));
}
}
for(i=0;i<T;i++)
printf("%d\n",out[i]);
return 0;
}
Input:
5
4 3 5 1 2
Output:
11
Solution
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <time.h>
#include <limits.h>
int comparison_count;
void debug_array(int *array, int array_size) {
printf("\n");
printf("[");
int i;
for (i = 0; i < array_size; i++) {
printf("%3d", array[i]);
}
printf("]");
printf("\n");
}
unsigned long long bigrand() {
unsigned long long big_rand = 0;
big_rand = rand();
big_rand = big_rand << 32;
big_rand |= rand();
return big_rand;
}
int randint(int start_range, int end_range) {
return (bigrand() % ((end_range + 1) - start_range)) + start_range;
}
void concatenate(int *concatenated,
int concatenated_size,
int *less,
int less_size,
int pivot,
int *greater,
int greater_size) {
int concatenated_idx = 0;
int i;
for (i = 0; i < less_size; i++) {
concatenated[concatenated_idx++] = less[i];
}
concatenated[concatenated_idx++] = pivot;
for (i = 0; i < greater_size; i++) {
concatenated[concatenated_idx++] = greater[i];
}
}
int *sort(int *array, int array_size) {
if (array_size <= 1) {
return array;
}
int pivot = array[(array_size - 1) / 2];
int *less = calloc(array_size, sizeof(int));
int less_idx = 0;
int *greater = calloc(array_size, sizeof(int));
int greater_idx = 0;
memset(less, -1, array_size * sizeof(int));
memset(greater, -1, array_size * sizeof(int));
int i;
for (i = 0; i < array_size; i++) {
comparison_count++;
if(array[i] < pivot) {
less[less_idx++] = array[i];
} else if (array[i] > pivot) {
greater[greater_idx++] = array[i];
}
}
int concatenated_size = less_idx + greater_idx + 1;
int *concatenated = calloc(concatenated_size, sizeof(int));
concatenate(concatenated,
concatenated_size,
sort(less, less_idx),
less_idx,
pivot,
sort(greater, greater_idx),
greater_idx);
return concatenated;
}
float calc_elapsed_time(clock_t time_s, clock_t time_e) {
return (((float)time_e - (float)time_s) / CLOCKS_PER_SEC) * 1000;
}
int main(int argc, const char * argv[])
{
int N;
scanf("%d", &N);
int *A = calloc(N, sizeof(int));
int i;
for (i = 0; i < N; i++) {
scanf("%d", &A[i]);
}
comparison_count = 0;
int *sorted = sort(A, N);
free(sorted);
printf("%d\n", comparison_count);
return 0;
}
Input:8
2
4 5
RGRGR
GRGRG
RGRGR
GRGRG
2 3
RRG
GGR
Output:
0
6 3
0
1
3
4
7
10
3 2
2 <= N <= 1000000
1 <= M <= 1000
a_1 < a_2 < .. < a_N
Solution
#include<stdio.h>
#include<stdlib.h>
#define MOD 1000000007
#define BUF 4096
int arr[1000000];
int temp1[1000000];
int temp2[1000000];
char ibuf[BUF];
int ipt = BUF;
int readInt()
{
while (ipt < BUF && ibuf[ipt] < '0')
ipt++;
if (ipt == BUF)
{
fread(ibuf, 1, BUF, stdin);
ipt = 0;
while (ipt < BUF && ibuf[ipt] < '0')
ipt++;
}
int n = 0;
while (ipt < BUF && ibuf[ipt] >= '0')
n = (n*10)+(ibuf[ipt++]-'0');
if (ipt == BUF)
{
fread(ibuf, 1, BUF, stdin);
ipt = 0;
while (ipt < BUF && ibuf[ipt] >= '0')
n = (n*10)+(ibuf[ipt++]-'0');
}
return n;
}
int main()
{
int m,n,i,j,min,k;
long long count=0;
n=readInt();
m=readInt();
for(i=0;i<n;i++)
arr[i]=readInt();
temp2[0]=1;
j=k=count=0;
for(i=1;i<n;i++)
{
while(arr[i]-arr[j] > m)
count-=temp2[j++];
temp1[i]=temp1[j]+1;
while(temp1[k]==temp1[j])
count+=temp2[k++];
temp2[i]=count%MOD;
}
printf("%d %d\n",temp1[n-1]-1,temp2[n-1]);
return 0;
}6
10 20 30 10 50 60
10
2
3
1 2 3
3
1
23 8.6
34 2.4
Sum of distances=57 feet and 11.00 inches
25 11.9
34 2.5
Sum of distances=59 feet and 14.40 inches
12 33
13 4
The distance between two points is=29.02 units
7 6
2 3
The distance between two points is=5.83 units
Problem Description Ram and Sita playing the parity game. Two types of parity are there. One is odd parity and next is even parity. Ram will...