Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int gcd (int a,int b){
- while (b != 0){
- int t = b;
- b = a % b;
- a = t;
- }
- return a;
- }
- int main()
- {
- int kase;
- int a,b,n,i, sum;
- cin >> kase;
- if(kase > 20)
- goto ERR;
- for(int j=1;j<=kase;j++){
- sum = 0;
- cin >> n >> a >> b;
- if ((a>=1) && (b>=a) && (n>=b) && (n<(10^12))){
- for (int i = a; i<= b; i++){
- if (gcd(n,i) == 1){
- sum = sum + i;
- }
- }
- cout << sum % 1000000007<<endl;
- }
- }
- ERR:
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement