#18906: 無法輸出


rexwu1104@gmail.com (黑雪公主 Black Lotus)

學校 : 新北市私立南山高級中學
編號 : 93041
來源 : [118.166.54.130]
最後登入時間 :
2022-06-06 20:48:09
c244. 來自深淵【序】尋寶記 -- 106學年度板橋高中校內資訊學科能力競賽310573sao | From: [220.141.87.19] | 發表日期 : 2019-08-12 21:15

#import <ios>
#define g() (p1==p2&&(p2=(p1=buf)+fread_unlocked(buf,1,1<<15,stdin),p1==p2)?EOF:*p1++)
char buf[1<<25],*p1=buf,*p2=buf;
inline bool redn(uint_fast64_t *a) {
uint_fast64_t ret=0; char ch=getchar_unlocked();
if(ch == EOF)return0;
while(ch>='0'&&ch<='9') ret=ret*10+ch-'0', ch=getchar_unlocked();
*a=ret;
return1;
}
inline void wrtn(uint_fast64_t x) {
uint_fast64_t y=10, len=1;
while(y<=x) y*=10, len++;
while(len--) y/=10, putchar_unlocked(x/y+48), x%=y;
}
inline void wrtn(const char *x) {
uint_fast64_t y=0;
while(x[y]) y++;
for(uint_fast64_t i=0;i<y;i++) putchar_unlocked(x[i]);
}
inline uint_fast64_t The_big(uint_fast64_t a, uint_fast64_t b, uint_fast64_t c, uint_fast64_t d, uint_fast64_t e) {
uint_fast64_t alb(a), vase(alb/b), big;
alb%=b, big=c*vase+e*alb/d;
uint_fast64_t _vase(alb);
do{
vase--, alb+=b;
uint_fast64_t _=c*vase+e*alb%d;
if(_>big) big=_;
}while(1);
return big;
}
int main() {
  uint_fast64_t t;
for(;redn(&t);){
uint_fast64_t s, s1, v1, s2, v2;
for(uint_fast64_t i=1;i<=t;i++){
redn(&s), redn(&s1), redn(&v1), redn(&s2), redn(&v2);
wrtn("Case #"), wrtn(i), wrtn(": "), wrtn(The_big(s, s1, v1, s2, v2)), putchar_unlocked(10);
}
}
}
 
ZeroJudge Forum