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 Viral Kitchen Gadgets...

📢 As an Amazon Associate, I earn from qualifying...

Power bank triggers fire...

A routine afternoon journey turned into a moment of...

The Real Truth About...

📢 As an Amazon Associate, I earn from qualifying...

Can a man kill...

Pop culture and action cinema often feed the dramatic...

7 Reasons This Viral...

📢 As an Amazon Associate, I earn from qualifying...

Can you have just...

Welcoming a pet ferret into your home is an...

Is Viral Kitchen Gadgets Worth Your Money Here Is Our Full Review

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

Power bank triggers fire in Mumbai local train, no injury reported

A routine afternoon journey turned into a moment of acute terror for commuters on Central Railway after a portable power bank abruptly caught fire...

The Real Truth About Viral Kitchen Gadgets Before You Buy

📢 As an Amazon Associate, I earn from qualifying purchases.Most products in this category disappoint within weeks. Cheap materials, vague instructions, and results that...

Can a man kill a bear with his hands?

Pop culture and action cinema often feed the dramatic fantasy of human triumph over apex predators, sparking a persistent debate: can a man kill...

7 Reasons This Viral Kitchen Gadgets Is Worth Every Single Penny

📢 As an Amazon Associate, I earn from qualifying purchases.Most products in this category disappoint within weeks. Cheap materials, vague instructions, and results that...

Can you have just one ferret?

Welcoming a pet ferret into your home is an exciting decision, but it frequently prompts an essential question for prospective owners: can you have...

We Tested Viral Kitchen Gadgets Here Is What You Must Know

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

7 Reasons This Viral Kitchen Gadgets Is Worth Every Single Penny

📢 As an Amazon Associate, I earn from qualifying purchases.After putting the Viral Kitchen Gadgets through a proper 30-day real-world test, I can tell...

Building India’s deep-tech enterprise pipeline: from IP to IPO

India’s startup ecosystem has earned global acclaim for its consumer tech and software-as-a-service (SaaS) platforms. However, the nation’s next major economic frontier lies in...