Codeforces Round #231 (Div. 2)
Problems # Name A Counting Sticks standard input/output 1 s, 256 MB x2326 B Very Beautiful Number standard input/output 1 s, 256 MB x856 C Dominoes standard input/output 2 s, 256 MB x803 D Physical Education and Buns standard input/output
Problems
# | Name | ||
---|---|---|---|
A |
Counting Sticks
standard input/output 1 s, 256 MB |
![]() ![]() |
![]() |
B |
Very Beautiful Number
standard input/output 1 s, 256 MB |
![]() ![]() |
![]() |
C |
Dominoes
standard input/output 2 s, 256 MB |
![]() ![]() |
![]() |
D |
Physical Education and Buns
standard input/output 2 s, 256 MB |
![]() ![]() |
![]() |
E |
Lightbulb for Minister
standard input/output 1 s, 256 MB |
![]() ![]() |
![]() |
A题:先处理字符串把3个位置的数字保存下来,在去判断相等或者差值为2,去移动即可。
B题:枚举最后一位数字,模拟往前推数字,推到第一位判断是不是和一开始枚举的数字相同。
C题:贪心,10和01其实是一样的,所以先保存下11,10和01的总数,00的个数,先从左往右放11,放完之后,在从右边往左边去放10,01,每行交替着放即可,剩下的就是00。
D题:从小到大排序后,先枚举公差d,先变化后的序列A1是0,然后求出整个需要去向上移动的最大值和最小值(可能是负的),那么变化后的序列其实可以看成一条斜率k是d,b是A1的直线,然后这条直线无论上移下移,那么对于最大值和最小值肯定还是原来那2个位置,那么只要保证移动到最大值和最小值中的最大值尽可能小,那么就是去中间肯定是最优的,为(up + down + 1)/2 (要向上取整所以+1),最后维护ans的最小值即可。
D题:还有一种解法,二分答案,然后去判断,判断的方式先枚举公差,在用O(n)的方法去维护每个上下区间从大到小。
代码:
A题:
#include <stdio.h> #include <string.h> char c; int main() { int num[3], s = 0; memset(num, 0, sizeof(num)); while ((c = getchar()) != EOF && c != '\n') { if (c == '+' || c == '=') s++; else num[s]++; } if (num[0] - 1 + num[1] == num[2] + 1) { if (num[0] == 1) num[1]--; else if (num[1] == 1) num[0]--; else if (num[0] != 1 && num[1] != 1) num[0]--; num[2]++; } else if (num[0] + num[1] == num[2]) { } else if (num[0] + 1 + num[1] == num[2] - 1) { if (num[2] == 1) { printf("Impossible\n"); return 0; } num[2]--; num[0]++; } else { printf("Impossible\n"); return 0; } int i; for (i = 0; i <br> B题: <pre class="brush:php;toolbar:false">#include <stdio.h> #include <string.h> int p, x, ans[1000005]; int main() { scanf("%d%d", &p, &x); int yu = 0; for (int i = 0; i = 0; j--) printf("%d", ans[j]); printf("\n"); return 0; } } printf("Impossible\n"); return 0; }</string.h></stdio.h>
C题:
#include <stdio.h> #include <string.h> int n, m, i, j; int num10, num00, num11; char str[10], ans[1005][1005][4]; int main() { num10 = num00 = num11 = 0; scanf("%d%d", &n, &m); for (i = 0; i <br> D题1: <pre class="brush:php;toolbar:false">#include <stdio.h> #include <string.h> #include <algorithm> #define INF 0x3f3f3f3f #define max(a,b) ((a)>(b)?(a):(b)) #define min(a,b) ((a) res) { ans = res; start = -up + res; dd = d; } } printf("%d\n%d %d\n", ans, start, dd); } int main() { scanf("%d", &n); for (int i = 0; i <br> D题2:<br> <pre class="brush:php;toolbar:false">#include <stdio.h> #include <string.h> #include <algorithm> #define INF 0x3f3f3f3f #define max(a,b) ((a)>(b)?(a):(b)) #define min(a,b) ((a)= 0; i--) { up = min(num[i] + Max, up - d); down = max(num[i] - Max, down - d); } if (down <br> <br> </algorithm></string.h></stdio.h>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



iPhone 15 Pro vs. iPhone 14 Pro: Specs Comparison Here is a spec comparison between iPhone 15 Pro Max and iPhone 14 Pro Max: iPhone 15 Pro Max iPhone 14 Pro Max Display size 6.7 inches 6.7 inches Display technology Super Retina 2,000 nits Dimensions 6.29x3.02x0.32 inches 6.33x3.06x0.31 inches Weight 221 grams 240 grams

Many users are not sure which one is worth buying, Xiaomi Mi Pad 6 or Mi Pad 6. From the configuration point of view, the higher configuration of Pro is definitely recommended, but it also depends on the price and their own budget, and the different product positioning groups are also different. Which one is worth buying, Xiaomi Mi Pad 6 or Pro? Answer: Xiaomi Mi Pad 6 Pro will be better, both in terms of performance and camera battery life. 1. Processor Xiaomi Pad 6: Snapdragon 870 Xiaomi Mi Pad 6 Pro: more powerful first-generation Snapdragon 8+ processor 2. Battery size Xiaomi Mi Pad 6: 8840mAh, 67W second charge Xiaomi Mi Pad 6 Pro: 8600mAh, 33W The fast-charging Xiaomi Mi Pad 6 will have better battery life, but charging will be slower. 3. Take photos with Xiaomi Mi Pad 6

Many users don’t know how to turn on the Xiaomi Mi Band 8 when they first come into contact with it. In fact, the method is very simple. We only need to find the USB data cable and connect the watch to the power supply, and then charge it for a while. You can press the button to turn on. How to turn on Xiaomi Mi Band 8pro 1. First install the watch, that is, connect the theme and the strap on both sides. 2. Then when we turn on the watch for the first time, we need to connect the charging cable. The connection method is at the bottom of the watch. 3. Wait for the watch to vibrate to power on, and then connect to your phone. >>>

MacBook Air is an Apple laptop. Many users are curious about the differences between MacBook Air and Pro. These two notebooks have some differences in processor core, main frequency and graphics card type. The differences between MacBook Air and Pro: 1. Different processor cores and threads: MacBook Air's processor has dual cores and four threads. The Pro is more powerful than the MacBook Air, with four cores and eight threads. 2. The main frequency of the processor is different: the processor of MacBook Air has a main frequency of 1.6GHz. The main frequency of the pro's processor is 1.4GHz, which is slightly lower than that of the macbook air. 3. Different graphics cards: macbookair adopts

Xiaomi pro14 is already on the market, and its configuration is very good for a business office notebook. There are three processor configurations to choose from, and the price is not particularly high. Many friends don’t know the specific launch time of Xiaomi Pro14. Xiaomi Pro14 launch time A: Xiaomi Pro14 Ryzen Edition will be available for pre-order on November 10, 2021, with an initial price starting from 5,299 yuan. Xiaomi Notebook Pro 14 will be released on July 4, 2022, and will officially go on sale at midnight on July 8. Xiaomi pro14 introduction 1. The screen is equipped with a 14-inch 2.5K Super Retina screen with a resolution of 2560x1600, a screen-to-body ratio of up to 88%, a 100% sRGB color gamut, and a refresh rate of 120Hz. 2. Appearance adopts 6 series

Have you installed cameras in your home? In recent years, home camera products have suddenly become a hit. I asked my friends around me, and boy, every house has one, and some even have more than one. However, with the popularity of the product, it has also brought some complaints during use. For example, you can only see one place at the same time, and if you want to see other places, you have to adjust the pan/tilt and rotate the camera back and forth. There is a certain blind spot and time difference when viewing the picture; or when you want to take a closer look at a certain location in your home, you find that the picture is blurry and you cannot see it at all. Clarity; etc... The experience is greatly compromised. Honor Select and Xiaopai Technology jointly launched the Honor Select Xiaopai Smart Camera Pro featuring "three lenses and dual images". Provides new solutions to industry and user pain points

Apple continues to push the boundaries of technology, and the latest proof of its innovation is the launch of the Apple A17 Pro GPU. This cutting-edge component features a completely redesigned GPU that promises significant improvements in performance, graphics, and user experience. The Apple A17 Pro GPU, launched alongside the iPhone 15 Pro, is a marvel of semiconductor engineering. It's manufactured using a 3nm process, which represents a major leap in miniaturization, packing more transistors into a single chip than ever before. This technical feat translates into greater power efficiency and computing power. Apple A17 Pro GPU delivers stunning graphics One of the standout features of the A17 Pro chip is its redesigned GPU. Apple has invested heavily in optimizing graphics performance, making it

Although Apple will launch the iPhone's video playback time to let users know that the iPhone battery is almost available. But normal users don't use their iPhone to view videos all day long. 7 iPhones tested for endurance in daily applications. Includes 7 models including iPhone15ProMax, iPhone15Pro, iPhone15Plus, iPhone15, iPhone14ProMax, iPhone14 and iPhone13ProMax. Running through some daily applications, such as Spotify, Zoom, Tiktok, Headspace, think about Apps, games, etc., we can see the battery life of different iPhones. this
