結果
問題 | No.1224 I hate Sqrt Inequality |
ユーザー | Rayhan Ahmad |
提出日時 | 2020-09-11 22:24:01 |
言語 | C++17(clang) (17.0.6 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 6,488 bytes |
コンパイル時間 | 4,497 ms |
コンパイル使用メモリ | 166,908 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-06-08 10:59:59 |
合計ジャッジ時間 | 5,571 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
11,776 KB |
testcase_01 | AC | 17 ms
11,776 KB |
testcase_02 | RE | - |
testcase_03 | AC | 20 ms
11,904 KB |
testcase_04 | AC | 18 ms
11,776 KB |
testcase_05 | WA | - |
testcase_06 | AC | 17 ms
11,776 KB |
testcase_07 | WA | - |
testcase_08 | AC | 18 ms
11,776 KB |
testcase_09 | AC | 17 ms
11,776 KB |
testcase_10 | AC | 17 ms
11,776 KB |
testcase_11 | AC | 18 ms
11,904 KB |
testcase_12 | AC | 18 ms
11,776 KB |
testcase_13 | AC | 18 ms
11,904 KB |
testcase_14 | WA | - |
ソースコード
//Bismillahir-Rahmanir-Rahim (In The Name Of ALLAH) //everything is long long #include<bits/stdc++.h> //#include<unordered_map> using namespace std; //... Define Section #define mem(a,val) memset(a,val,sizeof(a)) #define all(a) a.begin(),a.end() #define sz(A) A.size() #define len(A) strlen(A) #define ff first #define ss second #define pb push_back #define PI acos(-1.00) #define ll long long #define pii pair<ll,ll> #define READ freopen("input.txt", "r", stdin) #define WRITE freopen("output.txt", "w", stdout) #define FOR(i,a,b) for(int i=a;i<=b;i++) #define RFOR(i,a,b) for(int i=a;i>=b;i--) #define sfll(a) scanf("%lld",&a) #define sfll2(a,b) scanf("%lld %lld",&a,&b) #define sfll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c) #define cs printf("Case %lld: ",kk++) #define cn printf("Case %lld:\n",kk++) #define pfll(a) printf("%lld",a) #define nl printf("\n") #define done printf("DONE\n") #define EPS 1e-9 #define MOD 1000000007 #define MAX 1e6 #define fast ios_base::sync_with_stdio(false); //BitMask Section #define checkBit(S, j) (S & (1 << j)) #define setBit(S, j) (S |= (1 << j)) #define clearBit(S, j) (S &= ~(1 << j)) #define toggleBit(S, j) (S ^= (1 << j)) #define lowBit(S) (S & (-S)) #define setAll(S, n) (S = (1 << n) - 1) //Default Function template<typename T>inline string Tostring(T a){ostringstream os("");os << a;return os.str();} //number to string template<typename T>inline ll Tolong(T a){ll res;istringstream os(a);os>>res;return res;} //string to number template< class T > inline T Bigmod(T n,T m,T mod){T ans=1,mult=n%mod;while(m){if(m & 1) ans=(ans*mult)%mod;m>>=1;mult=(mult*mult)%mod;}ans%=mod;return ans;}//Big Mod (A^B)%M template< class T > inline T Modinv(T x,T mod){return _bigmod(x,(T) mod-2)%mod;} // Modular Inverse (A/B=A^(-B))%M template<typename T>inline vector<int> Parse(T str){vector<int> res;int s;istringstream os(str);while(os>>s)res.pb(s);return res;}//string to vector template< class T > inline T Lcm(T x,T y){return x*y/__gcd(x,y);}//LCM (a*b)/gcd(a,b) template<typename T> inline T pwr(T b, T p) {T res = 1;while(p > 0) {if(p&1) {res *= b ;}b *= b;p >>= 1;}return res ;}//power a^b template <typename T>inline vector< T > Unique(vector< T > v) {sort(v.begin(), v.end());v.erase(unique(v.begin(), v.end()),v.end());return v;}// 1 2 1 3 = 1 2 3 (vector) //Direction Array //int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction //int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction //int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction //Running Time clock_t begn,ed; double time_spent; #define timestart() begn=clock() #define timestop() ed=clock() void timelimit() {time_spent = (double)(ed - begn) / CLOCKS_PER_SEC;cerr<<"Running Time: "<<time_spent<<" Seconds"<<endl;} // start coding namespace Factor { const int N=2010000; ll C,fac[10010],n,mut,a[1001000]; int T,cnt,i,l,prime[N],p[N],psize,_cnt; ll _e[100],_pr[100]; vector<ll> d; inline ll mul(ll a,ll b,ll p) { if (p<=1000000000) return a*b%p; else if (p<=1000000000000ll) return (((a*(b>>20)%p)<<20)+(a*(b&((1<<20)-1))))%p; else { ll d=(ll)floor(a*(long double)b/p+0.5); ll ret=(a*b-d*p)%p; if (ret<0) ret+=p; return ret; } } void prime_table(){ int i,j,tot,t1; for (i=1;i<=psize;i++) p[i]=i; for (i=2,tot=0;i<=psize;i++){ if (p[i]==i) prime[++tot]=i; for (j=1;j<=tot && (t1=prime[j]*i)<=psize;j++){ p[t1]=prime[j]; if (i%prime[j]==0) break; } } } void init(int ps) { psize=ps; prime_table(); } ll powl(ll a,ll n,ll p) { ll ans=1; for (;n;n>>=1) { if (n&1) ans=mul(ans,a,p); a=mul(a,a,p); } return ans; } bool witness(ll a,ll n) { int t=0; ll u=n-1; for (;~u&1;u>>=1) t++; ll x=powl(a,u,n),_x=0; for (;t;t--) { _x=mul(x,x,n); if (_x==1 && x!=1 && x!=n-1) return 1; x=_x; } return _x!=1; } bool miller(ll n) { if (n<2) return 0; if (n<=psize) return p[n]==n; if (~n&1) return 0; for (int j=0;j<=7;j++) if (witness(rand()%(n-1)+1,n)) return 0; return 1; } ll gcd(ll a,ll b) { ll ret=1; while (a!=0) { if ((~a&1) && (~b&1)) ret<<=1,a>>=1,b>>=1; else if (~a&1) a>>=1; else if (~b&1) b>>=1; else { if (a<b) swap(a,b); a-=b; } } return ret*b; } ll rho(ll n) { for (;;) { ll X=rand()%n,Y,Z,T=1,*lY=a,*lX=lY; int tmp=20; C=rand()%10+3; X=mul(X,X,n)+C;*(lY++)=X;lX++; Y=mul(X,X,n)+C;*(lY++)=Y; for(;X!=Y;) { ll t=X-Y+n; Z=mul(T,t,n); if(Z==0) return gcd(T,n); tmp--; if (tmp==0) { tmp=20; Z=gcd(Z,n); if (Z!=1 && Z!=n) return Z; } T=Z; Y=*(lY++)=mul(Y,Y,n)+C; Y=*(lY++)=mul(Y,Y,n)+C; X=*(lX++); } } } void _factor(ll n) { for (int i=0;i<cnt;i++) { if (n%fac[i]==0) n/=fac[i],fac[cnt++]=fac[i];} if (n<=psize) { for (;n!=1;n/=p[n]) fac[cnt++]=p[n]; return; } if (miller(n)) fac[cnt++]=n; else { ll x=rho(n); _factor(x);_factor(n/x); } } void dfs(ll x,int dep) { if (dep==_cnt) d.pb(x); else { dfs(x,dep+1); for (int i=1;i<=_e[dep];i++) dfs(x*=_pr[dep],dep+1); } } void norm() { sort(fac,fac+cnt); _cnt=0; FOR(i,0,cnt-1) if (i==0||fac[i]!=fac[i-1]) _pr[_cnt]=fac[i],_e[_cnt++]=1; else _e[_cnt-1]++; } vector<ll> getd() { d.clear(); dfs(1,0); return d; } vector<ll> factor(ll n) { cnt=0; _factor(n); norm(); return getd(); } vector<pair<ll,ll> > factorG(ll n) { cnt=0; _factor(n); norm(); vector<pair<ll,ll> > d; FOR(i,0,_cnt-1) d.pb(make_pair(_pr[i],_e[i])); return d; } bool is_primitive(ll a,ll p) { assert(miller(p)); vector<pair<ll,ll> > D=factorG(p-1); FOR(i,0,D.size()-1) if (powl(a,(p-1)/D[i].first,p)==1) return 0; return 1; } } int main() { long long numr,denr; cin >> numr >> denr; Factor::init(2000000); vector<pair<ll,ll> > fact = Factor::factorG(denr); if(fact.size()>2)cout <<"Yes\n"; else { if(fact.size()==1) { if(fact[0].first == 2 || fact[0].first == 5)cout<<"No\n"; else cout<<"Yes\n"; } else { if(fact[0].first == 2 && fact[1].first == 5)cout<<"No\n"; else cout<<"Yes\n"; } } return 0; }