Задача 1:
using System;
using System.Linq;
namespace t29780843n1
{
internal class Program
{
private static void Main()
{
var value = int.Parse(Console.In.ReadLine());
Console.Out.WriteLine(value ^ ((1 << Enumerable.Range(0, int.MaxValue).First(n => 1 << n > value)) - 1));
}
}
}
Задача 2:
using System;
using System.Linq;
namespace t29780843n2
{
class Program
{
static void Main()
{
var birthdayDate = DateTime.Parse(Console.In.ReadLine() + ".2000");
var nowDate = DateTime.Parse(Console.In.ReadLine());
Console.Out.WriteLine(Enumerable
.Range(0, Int32.MaxValue)
.First(d => nowDate.AddDays(d).Day == birthdayDate.Day &&
nowDate.AddDays(d).Month == birthdayDate.Month));
}
}
}
Задача 3:
using System;
namespace t29780843n3
{
class Program
{
static void Main()
{
var queue = Console.In.ReadLine();
for (int i = 0; i < 2; i++)
queue = queue.Replace("MD", "DM");
Console.Out.WriteLine(queue);
}
}
}
Задача 4:
using System;
using System.Linq;
namespace t29780843n4
{
internal class Program
{
private static void Main()
{
Console.Out.WriteLine(
Enumerable
.Range(2, int.MaxValue - 1)
.Where(number =>
Enumerable.Range(2, (int) Math.Sqrt(number) - 1)
.All(divisor => number % divisor != 0))
.Where(t => t == int.Parse(new string(t.ToString().Reverse().ToArray())))
.Take(101)
.Last());
}
}
}