第一问
第二问
思路
直接模拟即可。()
#include<bits/stdc++.h>
using namespace std;
const int N = 100003;
typedef long long ll;
queue<ll> qa;
ll ans[N];
int main()
{
int n, cnt = 0;
cin >> n;
qa.push(1);
qa.push(2);
while(cnt <= n)
{
ll m = qa.front();
qa.pop();
if((m*10) % 7 == 0)
{
ans[++cnt] = m*10;
cout << ans[cnt] << endl;
}
qa.push(m*10);
if((m*10+1) % 7 == 0)
{
ans[++cnt] = (m*10+1);
cout << ans[cnt] << endl;
}
qa.push(m*10+1);
if((m*10+2) % 7 == 0)
{
ans[++cnt] = (m*10+2);
cout << ans[cnt] << endl;
}
qa.push(m*10+2);
}
cout << ans[n] << endl;
return 0;
}很抱歉又浪费了一道好题(bushi)