跳到正文

个人记录

DLMY Solution: T728723

Alexlulu约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年2月26日
更新
2026年4月6日
篇幅
约 1 分钟

版本

  1. v1当前

题目传送门:春节特别赛 A+B Problem

个人评价:中位红

本题唯一需要考虑就是 位数计算,用 while 即可实现,由于 N≤3000N\le 3000,所以双层循环秒杀。

AC 代码
C++
#include <bits/stdc++.h>
using namespace std;

int n, k, cht = 100007;

int cal(int x)
{
    int t = x, res = 0;
    while (t) t /= 10, res++;
    return res;
}

int main()
{
	scanf("%d", &n);
    printf("%d=%d+%d\n", n, 1, n-1);
    k = cal(n);
    for (int a = 2; a < n; a++)
    {
        for (int i = 1; i <= k; i++) printf(" ");
        int b = n-a;
        printf("=%d+%d\n", a, b);
    }
	return 0;
}
// Solution By Alexlulu
原文