#CF 723 B
链接: link.
题意:
T组测试样例,每次给一个n,问你能否用11,111,1111,11111…等通过任意相加零次或多次,凑出n。
题解:
我们发现11111 可以有 111 * 100 + 11凑出,类比也就是这些的基本元素只有11和111,相当于一个偶的一个奇的就可以把所有的凑数来了,进而继续推导。
a
×
11
+
b
×
111
=
n
a \times 11 + b \times 111 = n
a×11+b×111=n
11
×
(
a
+
b
×
10
)
+
b
=
n
11 \times (a + b \times 10) + b = n
11×(a+b×10)+b=n
b
≡
n
(
m
o
d
11
)
b \equiv n \pmod{11}
b≡n(mod11)
a
=
n
−
b
/
11
+
10
×
b
≥
0
a = n - b/11 + 10 \times b\ge 0
a=n−b/11+10×b≥0
当a大于等于零即可因为最少一个不取
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <stack>
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef unsigned long long ULL;
const int N = 100010, M = 1100, INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
int n, m, x, y, k, cnt, t;
int a[N];
int main() {
cin >> t;
while (t --) {
cin >> n;
int b = n % 11;
if ((n - b) / 11 >= 10 * b) puts("YES");
else puts("NO");
}
return 0;
}