【CodeForces】[669A]Little Artem and Presents

Problem Description

Loading...

Problem Analysis

The arrangement that maximizes the count must be a pattern like 12121212 so take 12 as a single unit 3 stones are needed to give 2 presents

So divide by 3 to count the groups and check whether there is a remainder

cpp
1
2
3
4
5
6
7
#include<stdio.h>
int main() {
	int n;
	while(scanf("%d",&n)!=EOF)
		printf("%d\n",n/3*2+(n%3?1:0));
	return 0;
}

Problem link: 【CodeForces】[669A]Little Artem and Presents

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...