Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define pb push_back
- #define mp make_pair
- #define sz(x) (int)(x).size()
- #define li long long
- #define ld long double
- #define x first
- #define y second
- #define pt pair<int, int>
- #define pll pair<ll, ll>
- #define forn(i, t) for(int i = 0; i < (t); i++)
- #define fore(i, f, t) for(int i = (f); i < (t); i++)
- #define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
- #define all(x) (x).begin(), (x).end()
- #define ins insert
- using namespace std;
- const int INF = 1e9;
- const int MOD = 1000000007;
- const li INF64 = 1e18;
- const ld EPS = 1e-7;
- mt19937 myrand(time(NULL));
- const int N = 200;
- int d, k;
- bool read(){
- if(scanf("%d%d", &k, &d) != 2)
- return 0;
- return 1;
- }
- void solve(){
- pt dp[N];
- dp[1] = mp(1, 0);
- fore(i, 2, d + 1){
- if (k % i == 0){
- dp[i] = mp(2, 1);
- continue;
- }
- if ((k - 1) % i == 0){
- dp[i] = mp(3, 0);
- continue;
- }
- if ((k + 1) % i == 0){
- dp[i] = mp(11, 0);
- continue;
- }
- dp[i] = mp(7, INF);
- fore(j, 2, i)
- if (i % j == 0){
- if (dp[j].x == 2 && dp[i / j].x == 2)
- dp[i] = mp(2, min(dp[i].y, dp[j].y + dp[i / j].y));
- else if (dp[j].x == 2 && (dp[i / j].x == 3 || dp[i / j].x == 11))
- dp[i] = mp(6, 0);
- else if (dp[i / j].x == 2 && (dp[j].x == 3 || dp[j].x == 11))
- dp[i] = mp(6, 0);
- else if (dp[j].x == 3 && dp[i / j].x == 11 && __gcd(j, i / j) == 1)
- dp[i] = mp(6, 0);
- else if (dp[j].x == 11 && dp[i / j].x == 3 && __gcd(j, i / j) == 1)
- dp[i] = mp(6, 0);
- else if (dp[j].x == 6 && dp[i / j].x != 7)
- dp[i] = mp(6, 0);
- else if (dp[i / j].x == 6 && dp[j].x != 7)
- dp[i] = mp(6, 0);
- }
- }
- /*fore(i, 1, d + 1)
- printf("[%d %d] ", dp[i].x, dp[i].y);
- printf("\n");*/
- bool fl2 = (dp[d].x == 2 ||dp[d].x == 6);
- bool fl3 = (dp[d].x == 3 || dp[d].x == 6);
- bool fl11 = (dp[d].x == 11 || dp[d].x == 6);
- if (fl2 && (fl3 || fl11)){
- printf("6-type\n");
- return;
- }
- if (fl3){
- printf("3-type\n");
- return;
- }
- if (fl11){
- printf("11-type\n");
- return;
- }
- if (fl2){
- printf("2-type\n%d\n", dp[d].y);
- return;
- }
- //printf("%d %d: ", k, d);
- printf("7-type\n");
- }
- int main(){
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- #endif
- while(read())
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement