[Zhengqing] [1765] Lay a pancake!!!

Problem Description

Loading...

Problem Analysis

After the lessons from the previous two problems……
This time I carefully checked the accepted submissions
The code below still gets WA……

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#include<stdio.h>
int main() {
	long int n,x,sum=0;
	scanf("%ld",&n);
	sum=(n/2)*2;
	if(n%2==1)
		sum=sum+2;
	printf("%ld\n",sum);
	return 0;
}

Looks like I didn’t get what “single-instance test” in the statement means
Let me just record it for now
Still don’t get it

————————————————————

Okay……
A senior reminded me…… it’s a brain teaser……

AC code:

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#include<stdio.h>
int main() {
	long long n,x;
	while(scanf("%lld",&n)!=EOF) {
		if(n==1)
			printf("2\n");
		else
			printf("%lld\n",n);
	}
	return 0;
}

For example, three pancakes Pancake 1 2 3
1 front 2 front
2 back 3 front
3 back 1 back

Three minutes is enough……

So except for the first one, which definitely takes 2 minutes
For all the others, just output the number itself

I think I got fooled by this

image.png

WA hint……
Thinking about it, this isn’t the first time I’ve been burned by a WA hint……
Guess I can’t trust these WA hints too much from now on……

Problem link: [ZZULI][1765]Lay a pancake!!!

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...