当前位置: 代码迷 >> 综合 >> F. Guess Divisors Count(数论构造)
  详细解决方案

F. Guess Divisors Count(数论构造)

热度:96   发布时间:2024-02-06 12:33:54.0
ll ju = 1e9,ju2=1e18;
int p[1050], cnt;
bool vis[1050];
vector<ll> v,v2;
const ll mp[22] = { 53,89,131,167,199,//每次询问最大的质数的后面一个 241,281,331,373,409,443,479,521,569,601,641 };
void x_x()
{f(i, 2, 1000){if (!vis[i])p[++cnt] = i;for (int j = 1;p[j] <= 1000 / i;j++){vis[p[j] * i] = true;if (i%p[j] == 0)break;}}int j = 1;while(j<=cnt){ll res = 1;while(j<=cnt){if (ju2 / p[j] < res)break;res *= p[j];j++;}v2.emplace_back(res);}f(i, 1, 168){ll now = p[i];while (now < ju/p[i])now *= p[i];v.emplace_back(now);}
}
ll query(ll now)
{printf("? %lld", now);cout << endl;ll ans;scanf("%lld", &ans);return ans;
}
void print(ll ans)
{printf("! %lld", ans);cout << endl;
}
void work()
{ll ans = 1, remain = 1e9, fg = 22;for(int i=0;i<22&&fg>0;i++){fg--;if (fg<=0)break;ll tmp = query(v2[i]);vector<int> have;f(j, 1, 168){if (tmp%p[j] == 0)have.emplace_back(j);}for (auto I : have){fg--;ll now = query(v[I - 1]);remain /= now;	int cot = 0;while (now%p[I] == 0){now /= p[I];cot++;}ans *= (cot + 1);if (fg <= 0)break;}if (fg<=0)break;if (remain < (mp[i] * mp[i] * mp[i]))break;}print(ans * 2);
}
int main()
{//freopen("in.txt", "r", stdin);x_x();int t;cin >> t;while (t--){work();}return 0;
}
  相关解决方案