Posted on 2008-04-11 09:57
superman 阅读(520)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1154 C++ 00:00.24 844K */
2 #include <string>
3 #include <iostream>
4
5 using namespace std;
6
7 int main()
8 {
9 int N;
10 cin >> N;
11 while(N--)
12 {
13 string n; int base;
14 while((cin >> base) && base)
15 {
16 cin >> n;
17
18 int sum = 0, m = 0;
19 for(int i = 0; i < n.size(); i++)
20 {
21 sum += n[i] - '0';
22 m = m * base + n[i] - '0';
23 }
24
25 cout << (m % sum == 0 ? "yes" : "no") << endl;
26 }
27 if(N)
28 cout << endl;
29 }
30
31 return 0;
32 }
33