记录编号 | 200811 | 评测结果 | AAAAAAAAAAAAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | [ZLXOI 2015]殉国 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.005 s | ||
提交时间 | 2015-10-29 16:12:06 | 内存使用 | 0.31 MiB | ||
#include<cstdio> #include<iostream> using namespace std; typedef long long LL; LL a,b,c,G; void read() { scanf("%lld%lld%lld",&a,&b,&c); } class miku { public: LL x,y; }; miku gcd(LL x,LL y) { miku tem; if(y==0) { tem.x=1,tem.y=0; G=x; return tem; } miku now=gcd(y,x%y); tem.x=now.y; tem.y=now.x-(x/y)*now.y; return tem; } int na,nb; miku sp; bool check() { if(sp.x<0) { LL k=(0-sp.x-1)/nb+1; sp.x+=k*nb; sp.y-=k*na; if(sp.y<0) return 0; } return 1; } void work() { sp=gcd(a,b); LL k=c/G; sp.x*=k;sp.y*=k; na=a/G,nb=b/G; if(sp.x>sp.y) { swap(sp.x,sp.y); swap(na,nb); } if(!check()||c%G!=0) { printf("-1 -1\n"); printf("0"); return; } LL mi=0,ma=0; if(nb>na) mi=sp.x+sp.y; else ma=sp.x+sp.y; LL ans=sp.y/na; sp.x+=ans*nb; sp.y-=ans*na; ans++; if(mi==0) mi=sp.x+sp.y; else ma=sp.x+sp.y; printf("%lld %lld\n",mi,ma); printf("%lld",ans); //cout<<ans<<endl; } int main() { freopen("BlackHawk.in","r",stdin); freopen("BlackHawk.out","w",stdout); read(); work(); return 0; }