QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#662770#9408. Hero of the KingdomTheShuMo#WA 0ms3768kbC++142.2kb2024-10-21 10:12:182024-10-21 10:12:24

Judging History

你现在查看的是最新测评结果

  • [2024-10-21 10:12:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3768kb
  • [2024-10-21 10:12:18]
  • 提交

answer

#include<bits/stdc++.h>
#define fo(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define rep(i,l,r) for(ll i(l),i##end(r);i<=i##end;++i)
#define per(i,r,l) for(ll i(r),i##end(l);i>=i##end;--i)
#define dbg(x) cerr<<#x<<" "<<x<<'\n';
#define ll __int128
#define gc getchar
#define pc putchar
using namespace std;
namespace WrongIO
{
	#define Ts template<typename Ty,typename... Ar>
	#define Tp template<typename Ty>
	Tp Ty wmax(Ty a,Ty b){return a>=b? a:b;}
	Tp Ty wmin(Ty a,Ty b){return a<=b? a:b;}
	Tp void read(Ty &x){x=0;Ty opt=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();if(c=='-')opt=-1,c=gc();while(isdigit(c))x=(x<<3)+(x<<1),x+=c-'0',c=gc();x*=opt;return;}
	Tp void write(Ty x){short OI_USE[150],OI_top=0;if(x<=0) if(x==0)pc('0');else pc('-'),x*=-1;while(x)OI_USE[++OI_top]=x%10,x/=10;while(OI_top--)pc(OI_USE[OI_top+1]+'0');return;}
    void writec(char c[]){int len=strlen(c);for(int i=0;i<len;i++)pc(c[i]);}
    void writes(string s){int len=s.length();for(int i=0;i<len;i++)pc(s[i]);}
    void readc(char &c,int l,int r){c=gc(); while(c!=EOF&&(c<l||c>r)) c=gc();}
    void readc(char &c,char val){c=gc();while(c!=EOF&&c!=val) c=gc();}
    void readc(char val){char c;c=gc();while(c!=EOF&&c!=val) c=gc();}
    void readls(string &s){char c=gc();while(c!='\n') s.push_back(c),c=gc();}
    Ts void read(Ty &x,Ar &...y) {read(x),read(y...);}
    Tp void writeln(Ty x) {write(x),pc('\n');}
    Tp void writesp(Ty x) {write(x),pc(' ');} 
    #undef Ts
	#undef Tp
} using namespace WrongIO;
ll T;
ll p,a,b,q,c,d,m,t;
void solve()
{
	read(p,a,b,q,c,d,m,t);
	while(t)
	{
		ll num=m/p;
		if(num==0) break;
		ll k=(p-m%p)/(q-p)/num;
		if((p-m%p)%((q-p)*num)!=0) k++;
		if(t>=k*(num*(a+c)+b+d))
		{
			t-=k*(num*(a+c)+b+d);
			m+=k*num*(q-p);
		}else{
			if(k!=0) k--;
			t-=k*(num*(a+c)+b+d);
			m+=k*num*(q-p);
			t-=b+d;
			ll ksk=(t/(a+c)); if(ksk<0) ksk=0;
			m+=(q-p)*ksk;
			break;
		}
//		if(m/p==0) break;
//		t-=b+d;
//		if(t<=0) break;
//		if(t>=(m/p)*(a+c))
//		{
//			t-=(m/p)*(a+c);
//			m+=(q-p)*(m/p);
//		}
//		else
//		{
//			ll ksk=t/(a+c);
//			m+=ksk*(q-p);
//			break;
//		}
	}
	writeln(m);
}
int main()
{
	read(T);
	while(T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3540kb

input:

3
5 2 3
8 1 5
14 36
5 2 0
8 1 3
17 6
100 1 0
10000 1 0
99 100000

output:

32
20
99

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3768kb

input:

500
252 34074578 3386884
628907 1207868 18
279 125908043
17268783 50414369 277106
17532337 45 0
17268784 4606
5506 3465964 19
5543 4786900 7
8109756 50825
23718927 66546966 0
23718931 96 0
117090491 99433206
537909 33389755 4
537910 1362118 0
538731 3
47 117 17333
1724743 7699 402536
79710763 684241...

output:

1886244
34399794
8109756
118594619
1075817
136625731
586
25929035
17864
7905961573
77468528
670869825
18459
88588674
4502
3995
6379706119
1235992
141371427
495166
324797075
156
598405696216
53895
3503164
7368205
124349483
3764139838369
2840566939118
96376002
8289144
996195
54156125533
32693
21629928...

result:

wrong answer 2nd lines differ - expected: '17268784', found: '34399794'