第十一届蓝桥杯 ——互质(gcd求最大公约数)

__gcd最大公约数_Rudy的博客-CSDN博客_gcdhttps://blog.csdn.net/xiaoyue_/article/details/83239172?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164594672016780265452028%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=164594672016780265452028&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-2-83239172.pc_search_result_cache&utm_term=gcd&spm=1018.2226.3001.4187第十一届蓝桥杯 ——互质_六级不考550+不改名-CSDN博客https://blog.csdn.net/weixin_46239370/article/details/115719120

#include
#include
using namespace std;


int main()
{
	int ans =0;
	for(int i =1;i<=2020;i++)
	{
		if(__gcd(i,1018)==1)
			ans++;
	}
	cout<
#include
#include
using namespace std;

int gcd(int a,int b)//a是除数  b是余数 
{
	return b ? gcd(b,a%b) : a ;
}
int main()
{
	int ans =0;
	for(int i =1;i<=2020;i++)
	{
		if(gcd(i,1018)==1)
			ans++;
	}
	cout<

你可能感兴趣的:(蓝桥杯)