281 题目链接
这题用了穷举,40;
优化后:40;
换种思路:40;
望各路大佬相助!
我的代码:
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int i=1;
while(1){
if((i+1)%a==0&&(i+1)/a>=1){
cout<<(i+1)/a;
break;
}
i+=b;
}
return 0;
}
(2):
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int i=1;
while(1){
if((i*a)%b==1){
cout<<i;
break;
}
i++;
}
return 0;
}