QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#409855#8111. CoachesDinalWA 0ms3900kbC++14551b2024-05-12 19:40:152024-05-12 19:40:15

Judging History

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

  • [2024-05-12 19:40:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3900kb
  • [2024-05-12 19:40:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
long long panduan(long long c,long long a,long long b,long long d){
	for(int i=0;i<b;++i)if((c+a*i)%b>=d){
		return c+a*i;
	}
	return LLONG_MAX;
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		long long n;
		int a,b;
		scanf("%lld%d%d",&n,&a,&b);
		long long l=1ll*a*b/__gcd(a,b);
		long long yc=n/a+n/b-2*(n/l);
		int ra=n%a,rb=n%b;
		long long rl=n%l;
		int ys=0;
		if(panduan(ra,a,b,rb)<rl)ys=2;
		if(panduan(rb,b,a,ra)<rl)ys=2;
		printf("%lld\n",n-yc+ys);
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3900kb

input:

2
5 2 3
10 7 2

output:

2
6

result:

wrong answer 1st numbers differ - expected: '3', found: '2'