直接贴代码。。
#include<bits/stdc++.h> using namespace std; typedef long long LL; int main() { LL a,b,n; while(cin>>a>>b>>n) { LL sum=1e18; LL ans; for(LL i=1;i*i<=n;i++) if(n%i==0) { LL t=a*n/i+b*n*i; if(t<sum) { sum=t; ans=i; } } cout<<ans<<endl; } }
#include<bits/stdc++.h> using namespace std; typedef long long LL; LL x; int vis[1005]; int yes[1005]; int ans[]={1,7,10,13,19,23,28,31,32,44,49,68,70,79,82,86,91,94,97,100,103,109,129,130,133,139,167,176,188,190,192,193,203,208,219,226,230,236,239,262,263,280,291,293,301,302,310,313,319,320,326,329,331,338,356,362,365,367,368,376,379,383,386,391,392,397,404,409,440,446,464,469,478,487,490,496,536,556,563,565,566,608,617,622,623,632,635,637,638,644,649,653,655,656,665,671,673,680,683,694,700,709,716,736,739,748,761,763,784,790,793,802,806,818,820,833,836,847,860,863,874,881,888,899,901,904,907,910,912,913,921,923,931,932,937,940,946,964,970,973,989,998,1000}; void init() { for(int i=0;ans[i]<1000;i++) yes[ans[i]]=1; } LL cal(LL x) { LL ret=0; while(x) { ret+=(x%10)*(x%10); x/=10; } return ret; } bool ok(LL x) { if(x<1000&&yes[x]==1) { return true; } if(x<1000&&vis[x]) return 0; if(x<1000) vis[x]=1; return ok(cal(x)); } int main() { init(); while(cin>>x) { memset(vis,0,sizeof(vis)); if(ok(x)) puts("YES"); else puts("NO"); } }
#include<bits/stdc++.h> using namespace std; typedef long long LL; long double x0,y0,x1,y1,v,vx,vy; //用double wa了。。 struct point { long double x,y; long double operator *(const point &rhs)const { return x*rhs.x+y*rhs.y; } }p0,p1,v0,p; long double dist(point p) { return sqrt(p.x*p.x+p.y*p.y); } int main() { int T; cin>>T; while(T--) { cin>>p0.x>>p0.y; cin>>p1.x>>p1.y; cin>>v0.x>>v0.y; cin>>v; p.x=p1.x-p0.x,p.y=p1.y-p0.y; long double v0_l=dist(v0); long double p_l=dist(p); if(v0*p<=0) { if(v>v0_l) puts("YES"); else puts("NO"); } else { long double v_in_d=v0*p/p_l; if(dist(v0)*dist(v0)-(v_in_d*v_in_d)<=v*v) puts("YES"); else puts("NO"); } } }