链接:
https://codeforces.com/problemset/problem/1526/B
题意:
判断x能不能被11,111,1111.....组成。
本题,除了11和111以外,其他的数字都可以通过11和111组成,所以只要判断x-i*111,能否整除11,即可知道x能不能被组成。
代码如下:
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<algorithm>
#include<string>
#include<string.h>
#include<random>
using namespace std;
typedef long long ll;
int main() {
int T;
cin >> T;
while (T--) {
int x;
cin >> x;
bool f = false;
for (int i = 0; i * 111 <= x; i++) {
if ((x - i * 111) % 11 == 0) {
f = true;
break;
}
}
if (f) {
cout << "YES";
}
else {
cout << "NO";
}
cout << endl;
}
return 0;
}