help me
查看原帖
help me
1549214
liuheqinghans0106楼主2024/11/28 20:09
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n * 2];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int i = 0;
	while (i < n) {
		if (a[i] < 10) {
			if (a[i] % 7 == 0) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
		} else if (a[i] < 100) {
			int b = a[i] % 10;
			int c = a[i] / 10;
			if ((b + c) % 7 == 0) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
		} else if (a[i] < 1000) {
			int b = a[i] % 1000 % 100 % 10;
			int c = a[i] % 1000 % 100 / 10;
			int d = a[i] % 1000 / 100;
			int e = a[i] / 1000;
			if ((b + c + d + e) % 7 == 0) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
		} else if (a[i] < 10000) {
			int b = a[i] % 10000 % 1000 % 100 % 10;
			int c = a[i] % 10000 % 1000 % 100 / 10;
			int d = a[i] % 10000 % 1000 / 100;
			int e = a[i] % 10000 / 1000;
			int f = a[i] / 10000;
			if ((b + c + d + e + f) % 7 == 0) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
		}
		i++;
	}
	return 0;
}

2024/11/28 20:09
加载中...