1,首先就是 (13%3=((1×10)%3+3)%3)
#include <algorithm>
#include <stdio.h>
#include <stack>
#include <istream>
#include <map>
#include <math.h>
#include <vector>
#include <iostream>
#include <queue>
#include <string.h>
#include <set>
#include <cstdio>
#define MAX 2005
using namespace std;
const int maxn = 20000007;
int vis[maxn];
struct cnm{
vector <char> inof;
int weishu;
}temp,now;
queue <cnm> lb;
int main() {
int n;
scanf("%d", &n);
if (n == 1) {
printf("1
"); return 0;
}
bool ans = 1;
memset(vis, 0, sizeof(vis));
vis[1] = 1;
now.weishu = 1;
now.inof.push_back('1');
lb.push(now);
while (true) {
now = lb.front(); lb.pop();
int a = now.weishu * 10;
for (int i = 0; i < 2; i++) {
int b = (a + i) % n;
if (vis[b])continue;
if (b == 0) {
for (int j = 0; j < now.inof.size(); j++) {
printf("%c", now.inof[j]);
}
printf("%d
", i);
ans = 0;
}
vis[b] = 1;
temp = now;
temp.inof.push_back(i+'0');
temp.weishu = b;
lb.push(temp);
}
if (!ans)break;
}
return 0;
}