XJTU Summer Holiday Test 1(Divisibility by Eight-8的倍数)

探讨如何从一个不超过100位的非负整数中移除部分数字,使其保留至少一位数字且结果能被8整除,同时保持原有数字顺序不变。通过检查最后三位数字是否为8的倍数来快速判断。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

C - Divisibility by Eight
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.

Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.

If a solution exists, you should print it.

Input

The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.

Output

Print "NO" (without quotes), if there is no such way to remove some digits from number n.

Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.

If there are multiple possible answers, you may print any of them.

Sample Input

Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO

8*125=1000 故一个数是8的倍数当且仅当它末尾3个数是8的倍数

所以答案最多有3位,暴力即可







#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  
#define Lson (x<<1)
#define Rson ((x<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define MAXN (100000+10)
typedef long long ll;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return (a-b+(a-b)/F*F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
char s[MAXN];
int main()
{
//	freopen("I.in","r",stdin);
//	freopen(".out","w",stdout);
	
	scanf("%s",s);
	char *pch=strstr(s,"AB");
	if (pch!=NULL&&strstr(pch+2,"BA")!=NULL)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	pch=strstr(s,"BA");
	if (pch!=NULL&&strstr(pch+2,"AB")!=NULL)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	
	return 0;
}






### XJTU-SY 数据集介绍与下载信息 XJTU-SY 数据集是由西安交通大学机械工程学院雷亚国教授团队与浙江长兴昇阳科技有限公司合作成立的“机械装备健康监测联合实验室”共同完成的一项滚动轴承加速寿命试验数据集[^1]。该数据集面向全球学者公开发布,旨在为滚动轴承故障诊断、性能退化预测及剩余使用寿命(RUL)估计等研究提供高质量的数据支持。 #### 数据集组成 XJTU-SY 数据集包含以下主要部分: 1. **Data 文件夹**:包含所有滚动轴承的试验数据集,涵盖不同工况和故障类型下的振动信号。 2. **Important References 文件夹**:包含与 XJTU-SY 数据集相关的研究论文和技术文档,供研究人员参考。 3. **Photographs 文件夹**:包含试验平台的照片以及失效轴承的图像,有助于理解试验环境和轴承失效模式。 #### 下载链接 为了获取 XJTU-SY 数据集,用户可以访问以下资源链接: - 原始数据集下载地址:[XJTU-SY-BD 资源02 - 原始数据集](引用链接)[^2]。 **注意**:请确保下载所有文件夹,包括 "Data"、"Important References" 和 "Photographs"。 #### 数据读取与处理示例 以下是基于 Python 的代码示例,展示如何读取和处理 XJTU-SY 数据集中的振动信号数据[^3]: ```python import matplotlib.pyplot as plt def csv_read(condition, bearing_number): # 模拟读取 CSV 文件的函数 # condition: 工况编号 # bearing_number: 轴承组编号 import numpy as np data_path = f"Data/Condition_{condition}/Bearing_{bearing_number}.csv" data = np.loadtxt(data_path, delimiter=",") return data[:, 0], data[:, 1] # 示例:读取第一种工况下第5组轴承的数据 data1, data2 = csv_read(1, 5) # 绘制水平和垂直振动信号 plt.figure(figsize=(12, 6)) plt.subplot(1, 2, 1) plt.title("Horizontal Vibration Signals") plt.ylabel("Amplitude") plt.xlabel("t") plt.plot(data1) plt.subplot(1, 2, 2) plt.title("Vertical Vibration Signals") plt.ylabel("Amplitude") plt.xlabel("t") plt.plot(data2) plt.tight_layout() plt.show() ``` 上述代码展示了如何从指定路径加载振动信号数据,并通过 `matplotlib` 可视化水平和垂直方向的振动信号。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值