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;
}

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;
}

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

How do birds know when you put out bird seed?

If you have ever refilled your backyard bird feeder, you have likely noticed a curious phenomenon: within minutes of setting out fresh seeds, a...

7 Reasons This Viral Kitchen Gadgets Is Worth Every Single Penny

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

Hong kong banks back student housing property boom

In an evolving commercial real estate landscape, Hong Kong banks are increasingly shifting their focus toward a rapidly growing asset class: student housing. Driven...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!