跳到正文

题解

T773477 GESP爱情小故事1 题解

awa__pwq_banana约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年7月4日
更新
2026年8月11日
篇幅
约 1 分钟
获赞
1

版本

  1. v3当前
  2. v2
  3. v1

这道题很水

从最大玫瑰数开始找,找到输出,找不到输出−1。

CE Code

C++
#include<bits/stdc++.h>
using namespace std;
int a,b,m;
int main(){
	cin>>a>>b>>m;
	\\从最大可能的玫瑰数量开始向下枚举
	for(int x=m/a;x>=0;x--){  
		if((m-x*a)%b==0){    
			printf("%lld\n",x);    
          return 0;       
		}  
	}
	printf("-1\n");
    return 0;
}
原文