https://codeforces.com/contest/2043/problem/B
#include<bits/stdc++.h>
#define lc p<<1
#define rc p<<1|1
#define INF 2e9
using namespace std;
#define endl '\n'
using ll = long long;
using pii = pair<ll, ll>;
const double PI = acos(-1);
const int N=1e4+10;
void solve(){
// ll sum=2;
// for(int i=1;i<=16;i++){
// cout<<sum%9<<" ";
// sum=sum*10+2;
// }
ll n,d;cin>>n>>d;
cout<<1<<" ";
ll sum=1;
for(int i=1;i<=min(n,(ll)9);i++)
sum*=i;
sum*=d;
if(n>=3||sum%3==0) cout<<3<<" ";
if(d==5) cout<<5<<" ";
if(n>=3||sum%7==0) cout<<7<<" ";
if(n>=6||sum%9==0) cout<<9<<" ";
cout<<endl;
}
//1 4 6 5 2 0 1 4 6 5 2 0 1 4 6 5
//2 1 5 3 4 0 2 1 5 3 4 0 2 1 5 3
//3 5 4 1 6 0 3 5 4 1 6 0 3 5 4 1
//n!是6的倍数就可以整除7,n>=3
//1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1
//n!是3的倍数就可以整除3 n>=3
//2 4 6 8 1 3 5 7 0 2 4 6 8 1 3 5
//n!是9的倍数就可以整除9 n>=6
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
cin>>T;
while (T--) {
solve();
}
return 0;
}
标签:const,规律,int,nullptr,数学,tie,sum%,cout
From: https://www.cnblogs.com/laileou/p/18666098