Codeforces Round #381 (Div. 2), problem: (A) Alyona and copybooks Solution in C/C++

Hi guys , I just solved the first problem of round 381 , Hope you like it , feel free to comment any better solution .

#include<stdio.h>

int main() {
int n,a[5]={0};
scanf(“%d %d %d %d”,&n,&a[1],&a[2],&a[3]);
if (a[3]+a[3]<a[1]-a[3]) a[1]=a[3]+a[3]+a[3];
if (a[3]+a[2]<a[1]) a[1]=a[3]+a[2];
if (a[3]+a[3]<a[2]) a[2]=a[3]+a[3];
if (a[1]+a[1]<a[2]) a[2]=a[1]+a[1];
if (a[1]+a[2]<a[3]) a[3]=a[1]+a[2];
a[4]=0;
printf(“%d\n”,a[4-n%4]);
return 0;
}

Advertisement

spot_img

Is the Keurig K-Mini...

Keurig K-Mini Long-Term Review: 12 Months of Daily Brewing First-impression...

Can You Make Iced...

How to Brew Refreshing Iced Coffee with the Keurig...

Keurig K-Mini vs Keurig...

Keurig K-Mini vs Keurig K-Slim: Comparing Keurig’s Slimmest Brewers Keurig’s...

Best K-Cup Coffee Pods...

Top Rated K-Cup Coffee Pods for the Keurig K-Mini The...

How to Fix a...

How to Clear Needle Clogs and Fix Slow Flow...

Keurig K-Mini Auto-Off Feature...

Keurig K-Mini Energy Efficiency & Power Consumption Analysis As electricity...

Is the Keurig K-Mini Worth It Long Term? 1-Year Reliability, Durability & Value

Keurig K-Mini Long-Term Review: 12 Months of Daily Brewing First-impression reviews written after three days of testing can tell you how an appliance looks on...

Can You Make Iced Coffee with the Keurig K-Mini? Brew Temperature & Iced Recipes

How to Brew Refreshing Iced Coffee with the Keurig K-Mini During warm summer months, nothing satisfies quite like a tall glass of refreshing iced coffee....

Keurig K-Mini vs Keurig K-Slim: Multi-Cup Reservoir vs Ultra-Compact Brewer

Keurig K-Mini vs Keurig K-Slim: Comparing Keurig’s Slimmest Brewers Keurig’s product catalog features two popular models specifically marketed to space-conscious consumers: the ultra-compact Keurig K-Mini...

Best K-Cup Coffee Pods for Keurig K-Mini: Dark, Medium, Flavored & Decaf Roasts

Top Rated K-Cup Coffee Pods for the Keurig K-Mini The beauty of owning a Keurig K-Mini Single Serve Coffee Maker is universal pod compatibility. Unlike...

How to Fix a Clogged Keurig K-Mini: Exit Needle Cleaning & Troubleshooting Guide

How to Clear Needle Clogs and Fix Slow Flow on the Keurig K-Mini If your Keurig K-Mini suddenly dispenses half a cup of coffee, drips...

Keurig K-Mini Auto-Off Feature and Power Consumption: Energy Efficiency Tested

Keurig K-Mini Energy Efficiency & Power Consumption Analysis As electricity costs rise and consumers increasingly prioritize eco-conscious household appliances, power consumption has become an important...

Keurig K-Mini Dimensions and Cord Storage: Best Compact Coffee Maker for Dorms & RVs

Keurig K-Mini Dimensions & Space-Saving Ergonomics Countertop real estate in modern living spaces has never been tighter. In college dormitories, studio micro-apartments, home office workstations,...

How to Use Reusable K-Cup Coffee Filters with the Keurig K-Mini: Universal Pod Guide

How to Brew Fresh Ground Coffee in Your Keurig K-Mini While pre-packaged K-Cup pods deliver unbeatable morning convenience, they come with two distinct trade-offs: ongoing...

Keurig K-Mini vs Nespresso Vertuo Pop: Compact Coffee Maker Comparison

Keurig K-Mini vs Nespresso Vertuo Pop: The Battle of Compact Brewers Single-serve coffee has evolved into two dominant, competing ecosystems: the versatile, drip-style Keurig K-Cup...