The maximum common divisor of T7316 yyy (by) and t7127yyy

Source: Internet
Author: User

The maximum common divisor of T7316 yyy (by) and t7127yyy
Background

Brute force attack

Description

Input/Output Format

Input Format:

 

 

Output Format:

 

 

Input and Output sample input sample #1:
Output sample #1: 

Description 

 

 

This question uses the principle of rejection and linear screening,

It indicates that I didn't understand it ,...

 

 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<algorithm> 6 #include<queue> 7 #include<stack> 8 #include<cstdlib> 9 #define lli long long int 10 using namespace std;11 const int mod = 998244353;12 const lli maxn=0x7fffff;13 14 const lli MAXN=10000001;15 inline void read(lli &n)16 {17     char c='+';lli x=0;bool flag=0;18     while(c<'0'||c>'9'){c=getchar();if(c=='-')flag=1;}19     while(c>='0'&&c<='9')20     x=(x<<1)+(x<<3)+c-48,c=getchar();21     flag==1?n=-x:n=x;22 }23 lli n,m;24 lli ans=0;25 lli now[MAXN];26 int main()27 {28     read(n);29     read(m);30     if(n>m)31         swap(n,m);32         33     for(lli i=n;i>=1;i--)34     {35         now[i]=1ll*(n/i)*(m/i);36         for(lli j=i+i;j<=n;j+=i)37             now[i]-=now[j];38         ans+=now[i]*i;39     }40     printf("%lld",ans%mod);41     return 0;42 }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.